OncoDrivers { @NotNull static DriverCatalog geneDriver(long sampleSNVCount, long sampleIndelCount, @NotNull final String gene, @NotNull final DndsDriverGeneLikelihood geneLikelihood, @NotNull final List<SomaticVariant> geneVariants, @Nullable GeneCopyNumber geneCopyNumber) { final Map<DriverImpact, Long> variantCounts = DriverCatalogFactory.driverImpactCount(geneVariants); long missenseVariants = variantCounts.getOrDefault(DriverImpact.MISSENSE, 0L); long nonsenseVariants = variantCounts.getOrDefault(DriverImpact.NONSENSE, 0L); long spliceVariants = variantCounts.getOrDefault(DriverImpact.SPLICE, 0L); long inframeVariants = variantCounts.getOrDefault(DriverImpact.INFRAME, 0L); long frameshiftVariants = variantCounts.getOrDefault(DriverImpact.FRAMESHIFT, 0L); final ImmutableDriverCatalog.Builder builder = ImmutableDriverCatalog.builder() .chromosome(geneVariants.get(0).chromosome()) .chromosomeBand(geneCopyNumber == null ? Strings.EMPTY : geneCopyNumber.chromosomeBand()) .gene(gene) .driver(DriverType.MUTATION) .category(DriverCategory.ONCO) .driverLikelihood(1) .dndsLikelihood(0) .missense(missenseVariants) .nonsense(nonsenseVariants) .splice(spliceVariants) .inframe(inframeVariants) .frameshift(frameshiftVariants) .biallelic(geneVariants.stream().anyMatch(SomaticVariant::biallelic)) .minCopyNumber(geneCopyNumber == null ? 0 : geneCopyNumber.minCopyNumber()) .maxCopyNumber(geneCopyNumber == null ? 0 : geneCopyNumber.maxCopyNumber()) .likelihoodMethod(LikelihoodMethod.DNDS); if (geneVariants.stream().anyMatch(SomaticVariant::isHotspot)) { return builder.likelihoodMethod(LikelihoodMethod.HOTSPOT).build(); } if (geneVariants.stream().anyMatch(OncoDrivers::isKnownInframeIndel)) { return builder.likelihoodMethod(LikelihoodMethod.INFRAME).build(); } double driverLikelihood = 0; for (SomaticVariant variant : geneVariants) { final DriverImpact impact = DriverImpact.select(variant); final DndsDriverImpactLikelihood likelihood = geneLikelihood.select(impact); final long sampleVariantCount = impact == DriverImpact.FRAMESHIFT || impact == DriverImpact.INFRAME ? sampleIndelCount : sampleSNVCount; driverLikelihood = Math.max(driverLikelihood, probabilityDriverVariant(sampleVariantCount, likelihood)); } return builder.driverLikelihood(driverLikelihood).build(); } OncoDrivers(DriverGenePanel genePanel);   }
@Test public void favourHotspot() { DriverCatalog victim = OncoDrivers.geneDriver(10000, 0, "Gene", likelihood, Lists.newArrayList(frameshiftHotspot, frameshiftNearHotspot, inframe, missense), null); assertEquals(LikelihoodMethod.HOTSPOT, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void doNotFavourNearHotspot() { DriverCatalog victim = OncoDrivers.geneDriver(10000, 0, "Gene", likelihood, Lists.newArrayList(frameshiftNearHotspot, inframe, missense), null); assertEquals(LikelihoodMethod.INFRAME, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void favourValidInframe() { DriverCatalog victim = OncoDrivers.geneDriver(10000, 0, "Gene", likelihood, Lists.newArrayList(inframe, missense), null); assertEquals(LikelihoodMethod.INFRAME, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void favourHighest() { DriverCatalog victim = OncoDrivers.geneDriver(SNV_SAMPLE_COUNT, INDEL_SAMPLE_COUNT, "Gene", likelihood, Lists.newArrayList(frameshift, missense), null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertLikelihood(0.001, INDEL_SAMPLE_COUNT, victim.driverLikelihood()); }
@Test public void ignoreFrameshiftAndInvalidInframe() { DriverCatalog victim = OncoDrivers.geneDriver(SNV_SAMPLE_COUNT, INDEL_SAMPLE_COUNT, "Gene", likelihood, Lists.newArrayList(unKnownInframe), null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertLikelihood(0.001, INDEL_SAMPLE_COUNT, victim.driverLikelihood()); }
@Test public void singleMissense() { DriverCatalog victim = OncoDrivers.geneDriver(SNV_SAMPLE_COUNT, INDEL_SAMPLE_COUNT, "Gene", likelihood, Lists.newArrayList(missense), null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertLikelihood(0.002, SNV_SAMPLE_COUNT, victim.driverLikelihood()); }
@Test public void multiMissense() { DriverCatalog victim = OncoDrivers.geneDriver(SNV_SAMPLE_COUNT, INDEL_SAMPLE_COUNT, "Gene", likelihood, Lists.newArrayList(missense, missense), null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertLikelihood(0.002, SNV_SAMPLE_COUNT, victim.driverLikelihood()); }