use of com.hartwig.hmftools.patientreporter.SampleReport in project hmftools by hartwigmedical.
the class PDFWriterTest method canGenerateSequenceReport.
@Test
public void canGenerateSequenceReport() throws DRException, IOException {
final double pathologyTumorPercentage = 0.6;
final double impliedTumorPurity = 0.58;
final int mutationalLoad = 361;
final double microsatelliteIndicator = 2.1;
final HmfReporterData reporterData = testHmfReporterData();
final BaseReporterData baseReporterData = testBaseReporterData();
final FittedPurity fittedPurity = createFittedPurity(impliedTumorPurity);
final List<VariantReport> variants = createTestVariants(new PurityAdjuster(Gender.MALE, fittedPurity));
final List<GeneCopyNumber> copyNumbers = createTestCopyNumbers();
final List<GeneDisruptionData> disruptions = createTestDisruptions();
final List<GeneFusionData> fusions = createTestFusions();
final SampleReport sampleReport = testSampleReport(pathologyTumorPercentage);
final List<Alteration> alterations = RUN_CIVIC_ANALYSIS ? PatientReporterTestUtil.runCivicAnalysis(variants, copyNumbers, disruptions, fusions, reporterData.panelGeneModel(), sampleReport.cancerType()) : mockedAlterations();
final SequencedPatientReport patientReport = ImmutableSequencedPatientReport.of(sampleReport, variants, mutationalLoad, microsatelliteIndicator, copyNumbers, disruptions, fusions, PatientReportFormat.formatPercent(impliedTumorPurity), alterations, Resources.getResource("circos" + File.separator + "circos_example.png").getPath(), Optional.of("this is a test report and does not relate to any real CPCT patient"), baseReporterData.signaturePath());
final JasperReportBuilder mainReport = PDFWriter.generatePatientReport(patientReport, reporterData);
assertNotNull(mainReport);
final JasperReportBuilder evidenceReport = EvidenceReport.generate(patientReport);
assertNotNull(evidenceReport);
if (SHOW_AND_PRINT) {
mainReport.show().print();
}
if (WRITE_TO_PDF) {
mainReport.toPdf(new FileOutputStream(REPORT_BASE_DIR + File.separator + "test_report.pdf"));
evidenceReport.toPdf(new FileOutputStream(REPORT_BASE_DIR + File.separator + "test_evidence_report.pdf"));
}
}
use of com.hartwig.hmftools.patientreporter.SampleReport in project hmftools by hartwigmedical.
the class PatientReporter method run.
@NotNull
public SequencedPatientReport run(@NotNull final String runDirectory, @Nullable final String comments) throws IOException {
final RunContext run = ProductionRunContextFactory.fromRunDirectory(runDirectory);
final GenomeAnalysis genomeAnalysis = analyseGenomeData(run.tumorSample(), runDirectory);
assert run.isSomaticRun() && run.tumorSample().equals(genomeAnalysis.sample());
final String tumorSample = genomeAnalysis.sample();
final VariantAnalysis variantAnalysis = genomeAnalysis.variantAnalysis();
final PurpleAnalysis purpleAnalysis = genomeAnalysis.purpleAnalysis();
final StructuralVariantAnalysis structuralVariantAnalysis = genomeAnalysis.structuralVariantAnalysis();
final List<GeneFusionData> reportableFusions = structuralVariantAnalysis.reportableFusions().stream().sorted(fusionComparator()).map(GeneFusionData::from).collect(Collectors.toList());
final List<GeneDisruptionData> reportableDisruptions = structuralVariantAnalysis.reportableDisruptions().stream().sorted(disruptionComparator(reporterData().panelGeneModel().transcriptMap())).map(GeneDisruptionData::from).collect(Collectors.toList());
final int passedVariantCount = variantAnalysis.passedVariants().size();
final int mutationalLoad = variantAnalysis.mutationalLoad();
final int consequentialVariantCount = variantAnalysis.consequentialVariants().size();
final int structuralVariantCount = structuralVariantAnalysis.annotations().size();
final String cancerType = PatientReporterHelper.extractCancerType(baseReporterData().patientsCancerTypes(), tumorSample);
final TumorLocationDoidMapping doidMapping = TumorLocationDoidMapping.fromResource("/tumor_location_doid_mapping.csv");
final List<Alteration> alterations = civicAnalyzer().run(variantAnalysis.findings(), purpleAnalysis.reportableGeneCopyNumbers(), reportableDisruptions, reportableFusions, reporterData().panelGeneModel(), doidMapping.doidsForTumorType(cancerType));
LOGGER.info(" Printing analysis results:");
LOGGER.info(" Number of passed variants : " + Integer.toString(passedVariantCount));
LOGGER.info(" Number of missense variants (mutational load) : " + Integer.toString(mutationalLoad));
LOGGER.info(" Number of consequential variants to report : " + Integer.toString(consequentialVariantCount));
LOGGER.info(" Determined copy number stats for " + Integer.toString(purpleAnalysis.genePanelSize()) + " genes which led to " + Integer.toString(purpleAnalysis.reportableGeneCopyNumbers().size()) + " copy numbers.");
LOGGER.info(" Number of unreported structural variants : " + Integer.toString(structuralVariantCount));
LOGGER.info(" Number of gene fusions to report : " + Integer.toString(reportableFusions.size()));
LOGGER.info(" Number of gene disruptions to report : " + Integer.toString(reportableDisruptions.size()));
LOGGER.info(" Number of CIViC alterations to report : " + alterations.size());
LOGGER.info(" Microsatellite analysis results: " + variantAnalysis.indelsPerMb() + " indels per MB");
final Lims lims = baseReporterData().limsModel();
final Double tumorPercentage = lims.tumorPercentageForSample(tumorSample);
final List<VariantReport> purpleEnrichedVariants = purpleAnalysis.enrichSomaticVariants(variantAnalysis.findings());
final String sampleRecipient = baseReporterData().centerModel().getAddresseeStringForSample(tumorSample);
final SampleReport sampleReport = ImmutableSampleReport.of(tumorSample, cancerType, tumorPercentage, lims.arrivalDateForSample(tumorSample), lims.arrivalDateForSample(run.refSample()), lims.labProceduresForSample(tumorSample), sampleRecipient);
return ImmutableSequencedPatientReport.of(sampleReport, purpleEnrichedVariants, mutationalLoad, variantAnalysis.indelsPerMb(), purpleAnalysis.reportableGeneCopyNumbers(), reportableDisruptions, reportableFusions, purpleAnalysis.purityString(), alterations, PatientReporterHelper.findCircosPlotPath(runDirectory, tumorSample), Optional.ofNullable(comments), baseReporterData().signaturePath());
}
use of com.hartwig.hmftools.patientreporter.SampleReport in project hmftools by hartwigmedical.
the class NotSequenceableReporter method run.
public NotSequencedPatientReport run(@NotNull final String sample, @NotNull final NotSequenceableReason reason, @Nullable final String comments) {
final NotSequenceableStudy study = NotSequenceableStudy.fromSample(sample);
assert study != null;
final String cancerType = PatientReporterHelper.extractCancerType(baseReporterData().patientsCancerTypes(), sample);
final Lims lims = baseReporterData().limsModel();
final Double tumorPercentage = lims.tumorPercentageForSample(sample);
final String sampleRecipient = baseReporterData().centerModel().getAddresseeStringForSample(sample);
final SampleReport sampleReport = ImmutableSampleReport.of(sample, cancerType, tumorPercentage, lims.arrivalDateForSample(sample), null, lims.labProceduresForSample(sample), sampleRecipient);
return ImmutableNotSequencedPatientReport.of(sampleReport, reason, study, Optional.ofNullable(comments), baseReporterData().signaturePath());
}
Aggregations