RawScoreGeneScorer implements GeneScorer { @Override public Function<Gene, List<GeneScore>> scoreGene() { return gene -> { if (inheritanceModes.isEmpty() || inheritanceModes.equals(JUST_ANY)) { GeneScore geneScore = calculateGeneScore(gene, ModeOfInheritance.ANY); logger.debug("{}", geneScore); return Collections.singletonList(geneScore); } List<GeneScore> geneScores = new ArrayList<>(inheritanceModes.size()); for (ModeOfInheritance modeOfInheritance : inheritanceModes) { GeneScore geneScore = calculateGeneScore(gene, modeOfInheritance); logger.debug("{}", geneScore); geneScores.add(geneScore); } return geneScores; }; } RawScoreGeneScorer(SampleIdentifier probandSampleIdentifier, InheritanceModeAnnotator inheritanceModeAnnotator); @Override Function<Gene, List<GeneScore>> scoreGene();  }
@Test public void testScoreGeneWithoutPriorityResultsOrVariantsUninitialised() { Gene gene = newGene(); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithoutPriorityResultsOrVariantsAutosomalDominant() { Gene gene = newGene(); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_DOMINANT, 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithoutPriorityResultsOrVariantsAutosomalRecessive() { Gene gene = newGene(); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSingleFailedVariantUninitialised() { Gene gene = newGene(failFreq()); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSingleFailedVariantAutosomalDominant() { Gene gene = newGene(failFreq()); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_DOMINANT, 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSingleFailedVariantAutosomalRecessive() { Gene gene = newGene(failFreq()); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSinglePassedVariantUninitialised() { VariantEvaluation passAllFrameshift = passAllFrameShift(); Gene gene = newGene(passAllFrameshift); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); float variantScore = passAllFrameshift.getVariantScore(); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSinglePassedVariantAutosomalDominant() { VariantEvaluation passAllFrameshift = passAllFrameShift(); passAllFrameshift.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); Gene gene = newGene(passAllFrameshift); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_DOMINANT, 0); float variantScore = passAllFrameshift.getVariantScore(); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSinglePassedVariantAutosomalRecessiveHomAlt() { List<Allele> alleles = buildAlleles("A", "T"); Genotype proband = buildUnPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(1)); assertThat(proband.getType(), equalTo(GenotypeType.HOM_VAR)); Genotype mother = buildUnPhasedSampleGenotype("Eve", alleles.get(0), alleles.get(1)); assertThat(mother.getType(), equalTo(GenotypeType.HET)); Genotype father = buildUnPhasedSampleGenotype("Adam", alleles.get(1), alleles.get(0)); assertThat(father.getType(), equalTo(GenotypeType.HET)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband, mother, father); System.out.println("Built variant context " + variantContext); System.out.println("Proband sample 0 has genotype " + variantContext.getGenotype(0).getGenotypeString()); Individual probandIndividual = Individual.builder().id("Cain").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.AFFECTED).build(); Individual motherIndividual = Individual.builder().id("Eve").fatherId("").motherId("").sex(Sex.FEMALE).status(Status.UNAFFECTED).build(); Individual fatherIndividual = Individual.builder().id("Adam").fatherId("").motherId("").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Pedigree pedigree = Pedigree.of(probandIndividual, motherIndividual, fatherIndividual); VariantEvaluation probandHomAlt = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext, VariantEffect.MISSENSE_VARIANT); probandHomAlt.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_RECESSIVE)); Gene gene = newGene(probandHomAlt); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, SampleIdentifier.of(probandIndividual.getId(), 0), pedigree); float variantScore = probandHomAlt.getVariantScore(); assertThat(probandHomAlt.contributesToGeneScore(), is(true)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(probandHomAlt)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSinglePassedVariantAutosomalRecessiveHet() { VariantEvaluation passAllFrameShift = passAllFrameShift(); Gene gene = newGene(passAllFrameShift); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0); assertThat(passAllFrameShift.contributesToGeneScore(), is(false)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithSinglePassedAndSingleFailedVariantOnlyPassedVariantIsConsidered() { VariantEvaluation passAllFrameshift = passAllFrameShift(); Gene gene = newGene(passAllFrameshift, failFreq()); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); float variantScore = passAllFrameshift.getVariantScore(); assertThat(passAllFrameshift.contributesToGeneScore(), is(true)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithTwoPassedVariantsUninitialisedInheritance() { VariantEvaluation passAllMissense = passAllMissense(); VariantEvaluation passAllFrameshift = passAllFrameShift(); Gene gene = newGene(passAllFrameshift, passAllMissense); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); float variantScore = passAllFrameshift.getVariantScore(); assertThat(passAllFrameshift.contributesToGeneScore(), is(true)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithTwoPassedVariantsAutosomalDominantInheritance() { VariantEvaluation passAllMissense = passAllMissense(); passAllMissense.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); VariantEvaluation passAllFrameshift = passAllFrameShift(); passAllFrameshift.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); Gene gene = newGene(passAllFrameshift, passAllMissense); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_DOMINANT, 0); float variantScore = passAllFrameshift.getVariantScore(); assertThat(passAllFrameshift.contributesToGeneScore(), is(true)); assertThat(passAllFrameshift.contributesToGeneScoreUnderMode(ModeOfInheritance.AUTOSOMAL_DOMINANT), is(true)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_DOMINANT) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithTwoPassedVariantsXDominantInheritance() { VariantEvaluation passAllMissense = passAllMissense(); passAllMissense.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.X_DOMINANT)); VariantEvaluation passAllFrameshift = passAllFrameShift(); passAllFrameshift.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.X_DOMINANT)); Gene gene = newGene(passAllFrameshift, passAllMissense); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.X_DOMINANT, 0); float variantScore = passAllFrameshift.getVariantScore(); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.X_DOMINANT) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithTwoPassedVariantsAutosomalRecessiveInheritance() { VariantEvaluation passAllMissense = passAllMissense(); passAllMissense.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); VariantEvaluation passAllFrameshift = passAllFrameShift(); passAllFrameshift.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); Gene gene = newGene(passAllMissense, passAllFrameshift); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0); float variantScore = (passAllFrameshift.getVariantScore() + passAllMissense.getVariantScore()) / 2f; GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllMissense, passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithThreePassedVariantsAutosomalRecessiveInheritance() { VariantEvaluation passAllMissense = passAllMissense(); passAllMissense.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); VariantEvaluation passAllSynonymous = passAllSynonymous(); passAllSynonymous.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); VariantEvaluation passAllFrameshift = passAllFrameShift(); passAllFrameshift.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); Gene gene = newGene(passAllMissense, passAllSynonymous, passAllFrameshift); List<GeneScore> geneScores = scoreGene(gene, ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0); float variantScore = (passAllFrameshift.getVariantScore() + passAllMissense.getVariantScore()) / 2f; assertThat(passAllFrameshift.contributesToGeneScore(), is(true)); assertThat(passAllFrameshift.contributesToGeneScoreUnderMode(ModeOfInheritance.AUTOSOMAL_RECESSIVE), is(true)); assertThat(passAllMissense.contributesToGeneScore(), is(true)); assertThat(passAllMissense.contributesToGeneScoreUnderMode(ModeOfInheritance.AUTOSOMAL_RECESSIVE), is(true)); assertThat(passAllSynonymous.contributesToGeneScore(), is(false)); assertThat(passAllSynonymous.contributesToGeneScoreUnderMode(ModeOfInheritance.AUTOSOMAL_RECESSIVE), is(false)); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.AUTOSOMAL_RECESSIVE) .variantScore(variantScore) .phenotypeScore(0f) .combinedScore(variantScore / 2) .contributingVariants(ImmutableList.of(passAllMissense, passAllFrameshift)) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testCalculateCombinedScoreFromUnoptimisedPrioritiser() { Gene gene = newGene(); gene.addPriorityResult(new MockPriorityResult(PriorityType.OMIM_PRIORITY, gene.getEntrezGeneID(), gene.getGeneSymbol(), 1d)); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); GeneScore expected = GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(0f) .phenotypeScore(1f) .combinedScore(0.5f) .build(); assertThat(geneScores, equalTo(ImmutableList.of(expected))); }
@Test public void testScoreGeneWithoutPriorityResultsOrVariantsAllInheritanceModes() { Gene gene = newGene(); EnumSet<ModeOfInheritance> inheritanceModes = EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE, ModeOfInheritance.X_DOMINANT, ModeOfInheritance.X_RECESSIVE, ModeOfInheritance.MITOCHONDRIAL); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.defaults(), 0); List<GeneScore> expected = inheritanceModes.stream() .map(mode -> GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(mode) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build()) .collect(toList()); assertThat(geneScores, equalTo(expected)); }
@Test public void testScoreGeneWithoutPriorityResultsOrVariantsOrInheritanceModes() { Gene gene = newGene(); List<GeneScore> geneScores = scoreGene(gene, InheritanceModeOptions.empty(), 0); List<GeneScore> expected = ImmutableList.of( GeneScore.builder() .geneIdentifier(gene.getGeneIdentifier()) .modeOfInheritance(ModeOfInheritance.ANY) .variantScore(0f) .phenotypeScore(0f) .combinedScore(0f) .contributingVariants(Collections.emptyList()) .build() ); assertThat(geneScores, equalTo(expected)); }