OmimPriority implements Prioritiser<OmimPriorityResult> { @Override public void prioritizeGenes(List<String> hpoIds, List<Gene> genes) { for (Gene gene : genes) { OmimPriorityResult result = prioritiseGene().apply(gene); gene.addPriorityResult(result); } } OmimPriority(PriorityService priorityService); @Override PriorityType getPriorityType(); @Override void prioritizeGenes(List<String> hpoIds, List<Gene> genes); @Override Stream<OmimPriorityResult> prioritise(List<String> hpoIds, List<Gene> genes); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void prioritizeGenesUnrecognisedGene() { List<Gene> genes = Lists.newArrayList(new Gene("Wibble", 999999999)); instance.prioritizeGenes(Collections.emptyList(), genes); genes.forEach(gene -> { OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); System.out.printf("%s %s %s%n", gene.getGeneSymbol(), gene.getCompatibleInheritanceModes(), result); OmimPriorityResult expected = omimResultForGene(gene, 1.0, allModesScoreOne()); assertThat(result, equalTo(expected)); }); }
@Test public void prioritizeGenesNoInheritanceModes() { List<Gene> genes = getGenes(); instance.prioritizeGenes(Collections.emptyList(), genes); genes.forEach(gene -> { OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); System.out.printf("%s %s %s%n", gene.getGeneSymbol(), gene.getCompatibleInheritanceModes(), result); OmimPriorityResult expected = omimResultForGene(gene, 1.0, allModesScoreOne()); assertThat(result, equalTo(expected)); }); }
@Test public void prioritizeGenesNoAssociatedDiseases() { Gene gene = new Gene("ZNF738", 148203); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); OmimPriorityResult expected = omimResultForGene(gene, 1.0, allModesScoreOne()); assertThat(result, equalTo(expected)); }
@Test public void prioritizeGenesRECESSIVEModeIsCompatible() { Gene gene = new Gene("ROR2", 4920); gene.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_RECESSIVE)); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); Map<ModeOfInheritance, Double> scores = new EnumMap<>(ModeOfInheritance.class); scores.put(ModeOfInheritance.AUTOSOMAL_DOMINANT, 0.5); scores.put(ModeOfInheritance.AUTOSOMAL_RECESSIVE, 1.0); scores.put(ModeOfInheritance.X_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_DOMINANT, 0.5); scores.put(ModeOfInheritance.MITOCHONDRIAL, 0.5); OmimPriorityResult expected = omimResultForGene(gene, 1.0, scores); assertThat(result, equalTo(expected)); }
@Test public void prioritizeGenesDOMINANTModeIsCompatible() { Gene gene = new Gene("ROR2", 4920); gene.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); Map<ModeOfInheritance, Double> scores = new EnumMap<>(ModeOfInheritance.class); scores.put(ModeOfInheritance.AUTOSOMAL_DOMINANT, 1.0); scores.put(ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_DOMINANT, 0.5); scores.put(ModeOfInheritance.MITOCHONDRIAL, 0.5); OmimPriorityResult expected = omimResultForGene(gene, 1.0, scores); assertThat(result, equalTo(expected)); }
@Test public void prioritizeGenesMultipleModesCompatible() { Gene gene = new Gene("ROR2", 4920); gene.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); Map<ModeOfInheritance, Double> scores = new EnumMap<>(ModeOfInheritance.class); scores.put(ModeOfInheritance.AUTOSOMAL_DOMINANT, 1.0); scores.put(ModeOfInheritance.AUTOSOMAL_RECESSIVE, 1.0); scores.put(ModeOfInheritance.X_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_DOMINANT, 0.5); scores.put(ModeOfInheritance.MITOCHONDRIAL, 0.5); OmimPriorityResult expected = omimResultForGene(gene, 1.0, scores); assertThat(result, equalTo(expected)); }
@Test public void prioritizeGenesNoModeSet() { Gene gene = new Gene("ROR2", 4920); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); Map<ModeOfInheritance, Double> scores = allModesScoreOne(); OmimPriorityResult expected = omimResultForGene(gene, 1.0, scores); assertThat(result, equalTo(expected)); }
@Test public void prioritizeGenesInheritanceModeIsNotCompatible() { Gene gene = new Gene("FREM2", 341640); gene.setCompatibleInheritanceModes(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); List<Gene> genes = Lists.newArrayList(gene); instance.prioritizeGenes(Collections.emptyList(), genes); OmimPriorityResult result = (OmimPriorityResult) gene.getPriorityResult(PriorityType.OMIM_PRIORITY); Map<ModeOfInheritance, Double> scores = new EnumMap<>(ModeOfInheritance.class); scores.put(ModeOfInheritance.AUTOSOMAL_DOMINANT, 0.5); scores.put(ModeOfInheritance.AUTOSOMAL_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_RECESSIVE, 0.5); scores.put(ModeOfInheritance.X_DOMINANT, 0.5); scores.put(ModeOfInheritance.MITOCHONDRIAL, 0.5); OmimPriorityResult expected = omimResultForGene(gene, 0.5, scores); assertThat(result, equalTo(expected)); }