SomaticVariants { @NotNull public static List<ReportableVariant> sort(@NotNull List<ReportableVariant> variants) { return variants.stream().sorted((variant1, variant2) -> { if (Math.abs(variant1.driverLikelihood() - variant2.driverLikelihood()) > 0.001) { return (variant1.driverLikelihood() - variant2.driverLikelihood()) < 0 ? 1 : -1; } else { if (variant1.gene().equals(variant2.gene())) { return extractCodonField(variant1.canonicalHgvsCodingImpact()) - extractCodonField(variant2.canonicalHgvsCodingImpact()) < 0 ? -1 : 1; } else { return variant1.gene().compareTo(variant2.gene()); } } }).collect(Collectors.toList()); } private  SomaticVariants(); @NotNull static List<ReportableVariant> sort(@NotNull List<ReportableVariant> variants); static boolean hasNotifiableGermlineVariant(@NotNull List<ReportableVariant> variants); @NotNull static String geneDisplayString(@NotNull ReportableVariant variant); @NotNull static String copyNumberString(double copyNumber, boolean hasReliablePurity); @NotNull static String vafString(@NotNull ReportableVariant variant, boolean hasReliablePurity); @NotNull static String hotspotString(@NotNull Hotspot hotspot); @NotNull static String biallelicString(boolean biallelic, boolean hasReliablePurity); @NotNull static String clonalString(double clonalLikelihood); @NotNull static Set<String> driverGenesWithVariant(@NotNull List<ReportableVariant> variants); static int countReportableVariants(@NotNull List<ReportableVariant> variants);  }
@Test public void sortCorrectlyOnCodon() { ReportableVariant variant1 = PatientReporterTestFactory.createTestReportableVariantBuilder().canonicalHgvsCodingImpact("c.-300T>A").build(); ReportableVariant variant2 = PatientReporterTestFactory.createTestReportableVariantBuilder().canonicalHgvsCodingImpact("c.4000T>A").build(); ReportableVariant variant3 = PatientReporterTestFactory.createTestReportableVariantBuilder().canonicalHgvsCodingImpact("c.500T>A").build(); List<ReportableVariant> variants = Lists.newArrayList(variant1, variant2, variant3); List<ReportableVariant> sortedVariants = SomaticVariants.sort(variants); assertEquals(variant1, sortedVariants.get(0)); assertEquals(variant3, sortedVariants.get(1)); assertEquals(variant2, sortedVariants.get(2)); }