Search in sources :

Example 1 with RunContext

use of com.hartwig.hmftools.common.context.RunContext 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());
}
Also used : ImmutableSampleReport(com.hartwig.hmftools.patientreporter.ImmutableSampleReport) SampleReport(com.hartwig.hmftools.patientreporter.SampleReport) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) Lims(com.hartwig.hmftools.common.lims.Lims) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) ImmutablePurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.ImmutablePurpleAnalysis) PurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.PurpleAnalysis) VariantAnalysis(com.hartwig.hmftools.patientreporter.variants.VariantAnalysis) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) RunContext(com.hartwig.hmftools.common.context.RunContext) TumorLocationDoidMapping(com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with RunContext

use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.

the class AmberCheckerTest method extractDataFromAmberWorksForSomatic.

@Test
public void extractDataFromAmberWorksForSomatic() throws IOException {
    final RunContext runContext = TestRunContextFactory.forSomaticTest(BASE_DIRECTORY, REF_SAMPLE, TUMOR_SAMPLE);
    final BaseResult result = checker.run(runContext);
    assertEquals(CheckType.AMBER, result.checkType());
    final HealthCheck check = ((SingleValueResult) result).check();
    assertCheck(check, "0.4951");
}
Also used : BaseResult(com.hartwig.hmftools.healthchecker.result.BaseResult) SingleValueResult(com.hartwig.hmftools.healthchecker.result.SingleValueResult) RunContext(com.hartwig.hmftools.common.context.RunContext) Test(org.junit.Test)

Example 3 with RunContext

use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.

the class AmberCheckerTest method testMalformed.

@Test(expected = MalformedFileException.class)
public void testMalformed() throws IOException {
    final RunContext runContext = TestRunContextFactory.forSomaticTest(BASE_DIRECTORY, REF_SAMPLE, "malformed");
    checker.run(runContext);
}
Also used : RunContext(com.hartwig.hmftools.common.context.RunContext) Test(org.junit.Test)

Example 4 with RunContext

use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.

the class PurpleCheckerTest method testMalformed.

@Test(expected = MalformedFileException.class)
public void testMalformed() throws IOException {
    final RunContext runContext = TestRunContextFactory.forSomaticTest(BASE_DIRECTORY, REF_SAMPLE, "malformed");
    checker.run(runContext);
}
Also used : RunContext(com.hartwig.hmftools.common.context.RunContext) Test(org.junit.Test)

Example 5 with RunContext

use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.

the class StrelkaCheckerTest method canAnalyseTypicalSomaticVariantVCF.

@Test
public void canAnalyseTypicalSomaticVariantVCF() throws IOException {
    final RunContext runContext = TestRunContextFactory.forSomaticTest(RUN_DIRECTORY, REF_SAMPLE, TUMOR_SAMPLE);
    final BaseResult result = checker.run(runContext);
    final List<HealthCheck> checks = ((MultiValueResult) result).checks();
    Assert.assertEquals(CheckType.STRELKA, result.checkType());
    assertEquals(EXPECTED_NUM_CHECKS, checks.size());
    assertCheck(checks, StrelkaCheck.SOMATIC_SNP_COUNT.toString(), 990);
    assertCheck(checks, StrelkaCheck.SOMATIC_SNP_DBSNP_COUNT.toString(), 820);
    assertCheck(checks, StrelkaCheck.SOMATIC_INDEL_COUNT.toString(), 67);
    assertCheck(checks, StrelkaCheck.SOMATIC_INDEL_DBSNP_COUNT.toString(), 42);
    assertCheck(checks, StrelkaCheck.SOMATIC_MNP_COUNT.toString(), 1);
    assertCheck(checks, StrelkaCheck.SOMATIC_MNP_DBSNP_COUNT.toString(), 0);
}
Also used : BaseResult(com.hartwig.hmftools.healthchecker.result.BaseResult) MultiValueResult(com.hartwig.hmftools.healthchecker.result.MultiValueResult) RunContext(com.hartwig.hmftools.common.context.RunContext) Test(org.junit.Test)

Aggregations

RunContext (com.hartwig.hmftools.common.context.RunContext)16 Test (org.junit.Test)9 File (java.io.File)5 CommandLine (org.apache.commons.cli.CommandLine)5 HelpFormatter (org.apache.commons.cli.HelpFormatter)5 Options (org.apache.commons.cli.Options)5 BaseResult (com.hartwig.hmftools.healthchecker.result.BaseResult)4 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)4 MultiValueResult (com.hartwig.hmftools.healthchecker.result.MultiValueResult)3 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 CpctEcrfModel (com.hartwig.hmftools.common.ecrf.CpctEcrfModel)2 Lims (com.hartwig.hmftools.common.lims.Lims)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 EcrfPatient (com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient)1 ValidationFinding (com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding)1 TumorLocationDoidMapping (com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping)1 FormStatusModel (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusModel)1 FormStatusReader (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusReader)1