use of com.hartwig.hmftools.patientreporter.report.data.Alteration 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.report.data.Alteration 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.report.data.Alteration in project hmftools by hartwigmedical.
the class CivicAnalyzer method civicVariantAlterations.
@NotNull
private static List<Alteration> civicVariantAlterations(@NotNull final List<VariantReport> reportedVariants, @NotNull final Collection<HmfGenomeRegion> geneRegions, @NotNull final Set<String> relevantDoids) {
LOGGER.info(" Fetching civic variant alterations...");
final List<Alteration> alterations = Lists.newArrayList();
final CivicApiWrapper civicApi = new CivicApiWrapper();
for (final HmfGenomeRegion region : geneRegions) {
final List<VariantReport> reportedVariantsInGene = reportedVariants.stream().filter(variantReport -> region.gene().equals(variantReport.gene())).collect(Collectors.toList());
if (!reportedVariantsInGene.isEmpty()) {
for (final VariantReport variantReport : reportedVariantsInGene) {
alterations.addAll(queryCivicAlteration(region.entrezId(), variantList -> Alteration.from(variantReport, variantList, relevantDoids), " Failed to get civic variants for variant: " + variantReport.variant().chromosomePosition()));
}
}
}
civicApi.releaseResources();
return alterations;
}
use of com.hartwig.hmftools.patientreporter.report.data.Alteration in project hmftools by hartwigmedical.
the class CivicAnalyzer method civicCopyNumberAlterations.
@NotNull
private static List<Alteration> civicCopyNumberAlterations(@NotNull final List<GeneCopyNumber> copyNumbers, @NotNull final Collection<HmfGenomeRegion> geneRegions, @NotNull final Set<String> relevantDoids) {
LOGGER.info(" Fetching civic copy number alterations...");
final List<Alteration> alterations = Lists.newArrayList();
for (final GeneCopyNumber copyNumberReport : copyNumbers) {
for (final HmfGenomeRegion region : geneRegions) {
if (region.gene().equals(copyNumberReport.gene())) {
alterations.addAll(queryCivicAlteration(region.entrezId(), variantList -> Alteration.from(copyNumberReport, variantList, relevantDoids), " Failed to get civic variants for copy number: " + copyNumberReport.gene()));
}
}
}
return alterations;
}
use of com.hartwig.hmftools.patientreporter.report.data.Alteration in project hmftools by hartwigmedical.
the class CivicAnalyzer method civicWildTypeAlterations.
@NotNull
private static List<Alteration> civicWildTypeAlterations(@NotNull final List<HmfGenomeRegion> nonWildTypeGenes, @NotNull final Set<String> relevantDoids) {
LOGGER.info(" Fetching civic wild type alterations...");
final CivicApiWrapper civicApi = new CivicApiWrapper();
final Set<String> nonWildTypeEntrezIds = nonWildTypeGenes.stream().flatMap(hmfGenomeRegion -> hmfGenomeRegion.entrezId().stream().map(Object::toString)).collect(Collectors.toSet());
final List<Alteration> wildTypeAlterations = civicApi.getAllWildTypeVariants().filter(civicVariant -> !nonWildTypeEntrezIds.contains(civicVariant.entrezId())).groupBy(CivicVariantWithEvidence::gene).flatMap(pair -> pair.toList().map(variantList -> Alteration.fromWildType(pair.getKey(), variantList, relevantDoids)).filter(alteration -> !alteration.getMatches().isEmpty()).toObservable()).toList().blockingGet();
civicApi.releaseResources();
return wildTypeAlterations;
}
Aggregations