AnalysedPatientReporter { @NotNull AnalysedPatientReport run(@NotNull SampleMetadata sampleMetadata, @NotNull String purplePurityTsv, @NotNull String purpleQCFile, @NotNull String purpleGeneCnvTsv, @NotNull String purpleDriverCatalogTsv, @NotNull String somaticVariantVcf, @NotNull String bachelorTsv, @NotNull String linxFusionTsv, @NotNull String linxDisruptionTsv, @NotNull String linxViralInsertionTsv, @NotNull String linxDriversTsv, @NotNull String chordPredictionTxt, @NotNull String circosFile, @Nullable String comments, boolean correctedReport) throws IOException { PatientTumorLocation patientTumorLocation = PatientTumorLocationFunctions.findTumorLocationForSample(reportData.patientTumorLocations(), sampleMetadata.tumorSampleId()); SampleReport sampleReport = SampleReportFactory.fromLimsModel(sampleMetadata, reportData.limsModel(), patientTumorLocation); List<DriverCatalog> purpleDriverCatalog = readDriverCatalog(purpleDriverCatalogTsv); PurpleAnalysis purpleAnalysis = analyzePurple(purplePurityTsv, purpleQCFile, purpleGeneCnvTsv, patientTumorLocation, purpleDriverCatalog); List<DriverSomaticVariant> driverSomaticVariants = analyzeSomaticVariants(sampleMetadata.tumorSampleId(), somaticVariantVcf, purpleDriverCatalog); ChordAnalysis chordAnalysis = analyzeChord(chordPredictionTxt); ChordStatus chordStatus = chordAnalysis.hrStatus(); LimsGermlineReportingLevel germlineChoice = reportData.limsModel().germlineReportingChoice(sampleMetadata.tumorSampleBarcode()); List<DriverGermlineVariant> driverGermlineVariants = analyzeGermlineVariants(bachelorTsv, purpleAnalysis, driverSomaticVariants, chordStatus, germlineChoice); ReportableVariantAnalysis reportableVariantsAnalysis = ReportableVariantAnalyzer.mergeSomaticAndGermlineVariants( driverSomaticVariants, driverGermlineVariants, reportData.germlineReportingModel(), germlineChoice, reportData.actionabilityAnalyzer(), patientTumorLocation); SvAnalysis svAnalysis = analyzeStructuralVariants(linxFusionTsv, linxDisruptionTsv, patientTumorLocation); List<ReportableHomozygousDisruption> reportableHomozygousDisruptions = extractHomozygousDisruptionsFromLinxDrivers(linxDriversTsv); List<ViralInsertion> viralInsertions = analyzeViralInsertions(linxViralInsertionTsv, reportData.limsModel().reportViralInsertions(sampleMetadata.tumorSampleBarcode())); String clinicalSummary = reportData.summaryModel().findSummaryForSample(sampleMetadata.tumorSampleId()); List<EvidenceItem> allEvidenceItems = Lists.newArrayList(); allEvidenceItems.addAll(reportableVariantsAnalysis.evidenceItems()); allEvidenceItems.addAll(purpleAnalysis.evidenceItems()); allEvidenceItems.addAll(svAnalysis.evidenceItems()); List<EvidenceItem> allEvidenceItemsFiltered = ReportableEvidenceItemFactory.filterBlacklistedEvidence(allEvidenceItems); List<EvidenceItem> nonTrials = ReportableEvidenceItemFactory.extractNonTrials(allEvidenceItemsFiltered); AnalysedPatientReport report = ImmutableAnalysedPatientReport.builder() .sampleReport(sampleReport) .qsFormNumber(determineForNumber(purpleAnalysis)) .impliedPurity(purpleAnalysis.purity()) .hasReliablePurity(purpleAnalysis.hasReliablePurity()) .hasReliableQuality(purpleAnalysis.hasReliableQuality()) .averageTumorPloidy(purpleAnalysis.ploidy()) .clinicalSummary(clinicalSummary) .tumorSpecificEvidence(nonTrials.stream().filter(EvidenceItem::isOnLabel).collect(Collectors.toList())) .clinicalTrials(ClinicalTrialFactory.extractOnLabelTrials(allEvidenceItemsFiltered)) .offLabelEvidence(nonTrials.stream().filter(item -> !item.isOnLabel()).collect(Collectors.toList())) .reportableVariants(reportableVariantsAnalysis.variantsToReport()) .microsatelliteIndelsPerMb(purpleAnalysis.purpleSignatures().microsatelliteIndelsPerMb()) .microsatelliteStatus(purpleAnalysis.purpleSignatures().microsatelliteStatus()) .tumorMutationalLoad(purpleAnalysis.purpleSignatures().tumorMutationalLoad()) .tumorMutationalLoadStatus(purpleAnalysis.purpleSignatures().tumorMutationalLoadStatus()) .tumorMutationalBurden(purpleAnalysis.purpleSignatures().tumorMutationalBurdenPerMb()) .chordHrdValue(chordAnalysis.hrdValue()) .chordHrdStatus(chordStatus) .gainsAndLosses(purpleAnalysis.reportableGainsAndLosses()) .geneFusions(svAnalysis.reportableFusions()) .geneDisruptions(svAnalysis.reportableDisruptions()) .homozygousDisruptions(reportableHomozygousDisruptions) .viralInsertions(viralInsertions) .circosPath(circosFile) .comments(Optional.ofNullable(comments)) .isCorrectedReport(correctedReport) .signaturePath(reportData.signaturePath()) .logoRVAPath(reportData.logoRVAPath()) .logoCompanyPath(reportData.logoCompanyPath()) .build(); printReportState(report); return report; } AnalysedPatientReporter(@NotNull final AnalysedReportData reportData);   }
@Test public void canRunOnRunDirectory() throws IOException { AnalysedPatientReporter reporter = new AnalysedPatientReporter(testAnalysedReportData()); SampleMetadata sampleMetadata = ImmutableSampleMetadata.builder() .refSampleId(REF_SAMPLE_ID) .refSampleBarcode(Strings.EMPTY) .tumorSampleId(TUMOR_SAMPLE_ID) .tumorSampleBarcode(Strings.EMPTY) .build(); assertNotNull(reporter.run(sampleMetadata, PURPLE_PURITY_TSV, PURPLE_QC_FILE, PURPLE_GENE_CNV_TSV, PURPLE_DRIVER_CATALOG_TSV, SOMATIC_VARIANT_VCF, BACHELOR_TSV, LINX_FUSIONS_TSV, LINX_DISRUPTIONS_TSV, LINX_VIRAL_INSERTION_TSV, LINX_DRIVERS_TSV, CHORD_PREDICTION_TXT, CIRCOS_FILE, null, false)); }