SomaticVariantAnalyzer { @NotNull public static List<DriverSomaticVariant> run(@NotNull List<SomaticVariant> variants, @NotNull List<DriverCatalog> purpleDriverCatalog) { List<DriverSomaticVariant> driverSomaticVariants = Lists.newArrayList(); for (SomaticVariant variant : variants) { if (variant.reported()) { DriverCatalog entry = catalogEntryForGene(purpleDriverCatalog, variant.gene()); driverSomaticVariants.add(ImmutableDriverSomaticVariant.builder() .variant(variant) .driverLikelihood(entry.driverLikelihood()) .build()); } } return driverSomaticVariants; } private  SomaticVariantAnalyzer(); @NotNull static List<DriverSomaticVariant> run(@NotNull List<SomaticVariant> variants, @NotNull List<DriverCatalog> purpleDriverCatalog);  }
@Test public void canAnalyzeSomaticVariants() { double driverLikelihood = 0.8; SomaticVariant variant = createTestSomaticVariantBuilder().gene("GENE").reported(true).build(); DriverCatalog driver = createTestDriverCatalogBuilder().gene("GENE").driverLikelihood(driverLikelihood).build(); List<DriverSomaticVariant> drivers = SomaticVariantAnalyzer.run(Lists.newArrayList(variant), Lists.newArrayList(driver)); assertEquals(1, drivers.size()); assertEquals(variant, drivers.get(0).variant()); assertEquals(driverLikelihood, drivers.get(0).driverLikelihood(), 1.0E-10); }
@Test (expected = IllegalStateException.class) public void crashOnMissingDriverCatalogEntry() { SomaticVariant variant = createTestSomaticVariantBuilder().gene("GENE").reported(true).build(); SomaticVariantAnalyzer.run(Lists.newArrayList(variant), Lists.newArrayList()); }