Search in sources :

Example 1 with GeneCopyNumber

use of com.hartwig.hmftools.common.gene.GeneCopyNumber in project hmftools by hartwigmedical.

the class PDFWriterTest method createTestCopyNumbers.

@NotNull
private static List<GeneCopyNumber> createTestCopyNumbers() {
    final GeneCopyNumber copyNumber1 = createCopyNumberBuilder().chromosome("9").chromosomeBand("p21.3").gene("CDKN2A").minCopyNumber(0).build();
    final GeneCopyNumber copyNumber2 = createCopyNumberBuilder().chromosome("17").chromosomeBand("q12").gene("ERBB2").minCopyNumber(9).build();
    return Lists.newArrayList(copyNumber1, copyNumber2);
}
Also used : GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) ImmutableGeneCopyNumber(com.hartwig.hmftools.common.gene.ImmutableGeneCopyNumber) Assert.assertNotNull(org.junit.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GeneCopyNumber

use of com.hartwig.hmftools.common.gene.GeneCopyNumber 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"));
    }
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) ImmutableSequencedPatientReport(com.hartwig.hmftools.patientreporter.ImmutableSequencedPatientReport) SequencedPatientReport(com.hartwig.hmftools.patientreporter.SequencedPatientReport) NotSequencedPatientReport(com.hartwig.hmftools.patientreporter.NotSequencedPatientReport) ImmutableNotSequencedPatientReport(com.hartwig.hmftools.patientreporter.ImmutableNotSequencedPatientReport) PatientReporterTestUtil.testBaseReporterData(com.hartwig.hmftools.patientreporter.PatientReporterTestUtil.testBaseReporterData) BaseReporterData(com.hartwig.hmftools.patientreporter.BaseReporterData) ImmutableSampleReport(com.hartwig.hmftools.patientreporter.ImmutableSampleReport) SampleReport(com.hartwig.hmftools.patientreporter.SampleReport) GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) ImmutableGeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.ImmutableGeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) ImmutableVariantReport(com.hartwig.hmftools.patientreporter.variants.ImmutableVariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) JasperReportBuilder(net.sf.dynamicreports.jasper.builder.JasperReportBuilder) HmfReporterData(com.hartwig.hmftools.patientreporter.HmfReporterData) PatientReporterTestUtil.testHmfReporterData(com.hartwig.hmftools.patientreporter.PatientReporterTestUtil.testHmfReporterData) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) ImmutableGeneFusionData(com.hartwig.hmftools.patientreporter.report.data.ImmutableGeneFusionData) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) ImmutableGeneCopyNumber(com.hartwig.hmftools.common.gene.ImmutableGeneCopyNumber) FileOutputStream(java.io.FileOutputStream) ImmutableFittedPurity(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) Test(org.junit.Test)

Example 3 with GeneCopyNumber

use of com.hartwig.hmftools.common.gene.GeneCopyNumber 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;
}
Also used : GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) GeneModel(com.hartwig.hmftools.common.gene.GeneModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) List(java.util.List) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) CivicVariantWithEvidence(com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Observable(io.reactivex.Observable) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) DiseaseOntologyApiWrapper(com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with GeneCopyNumber

use of com.hartwig.hmftools.common.gene.GeneCopyNumber in project hmftools by hartwigmedical.

the class LoadPurpleData method main.

public static void main(@NotNull final String[] args) throws ParseException, IOException, SQLException {
    final Options options = createBasicOptions();
    final CommandLine cmd = createCommandLine(args, options);
    final DatabaseAccess dbAccess = databaseAccess(cmd);
    final String tumorSample = cmd.getOptionValue(SAMPLE);
    final String purplePath = cmd.getOptionValue(PURPLE_DIR);
    LOGGER.info("Persisting purity data");
    final PurpleQC purpleQC = PurpleQCFile.read(PurpleQCFile.generateFilename(purplePath, tumorSample));
    final PurityContext purityContext = FittedPurityFile.read(purplePath, tumorSample);
    final List<FittedPurity> bestFitPerPurity = FittedPurityRangeFile.read(purplePath, tumorSample);
    dbAccess.writePurity(tumorSample, purityContext, purpleQC);
    dbAccess.writeBestFitPerPurity(tumorSample, bestFitPerPurity);
    LOGGER.info("Persisting copy numbers");
    final List<PurpleCopyNumber> copyNumbers = PurpleCopyNumberFile.read(purplePath, tumorSample);
    dbAccess.writeCopynumbers(tumorSample, copyNumbers);
    LOGGER.info("Persisting gene copy numbers");
    final List<GeneCopyNumber> geneCopyNumbers = GeneCopyNumberFile.read(GeneCopyNumberFile.generateFilename(purplePath, tumorSample));
    dbAccess.writeGeneCopynumberRegions(tumorSample, geneCopyNumbers);
    LOGGER.info("Complete");
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) PurpleQC(com.hartwig.hmftools.common.purple.qc.PurpleQC) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) PurityContext(com.hartwig.hmftools.common.purple.purity.PurityContext) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber)

Example 5 with GeneCopyNumber

use of com.hartwig.hmftools.common.gene.GeneCopyNumber in project hmftools by hartwigmedical.

the class BachelorEligibility method processCopyNumbers.

@NotNull
Collection<EligibilityReport> processCopyNumbers(final String patient, final List<GeneCopyNumber> copyNumbers) {
    final List<EligibilityReport> results = Lists.newArrayList();
    for (final GeneCopyNumber copyNumber : copyNumbers) {
        // TODO: verify the germline check
        final boolean isGermline = copyNumber.germlineHet2HomRegions() + copyNumber.germlineHomRegions() > 0;
        final List<String> matchingPrograms = programs.stream().filter(program -> program.copyNumberProcessor().test(copyNumber)).map(BachelorProgram::name).collect(Collectors.toList());
        final List<EligibilityReport> interimResults = matchingPrograms.stream().map(p -> ImmutableEligibilityReport.builder().patient(patient).source(isGermline ? GERMLINE_DELETION : SOMATIC_DELETION).program(p).id("").genes(copyNumber.gene()).chrom(copyNumber.chromosome()).pos(copyNumber.start()).ref("").alts("").effects("").build()).collect(Collectors.toList());
        results.addAll(interimResults);
    }
    return results;
}
Also used : ProgramPanel(nl.hartwigmedicalfoundation.bachelor.ProgramPanel) Genotype(htsjdk.variant.variantcontext.Genotype) CloseableIterator(htsjdk.samtools.util.CloseableIterator) SOMATIC_DELETION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.SOMATIC_DELETION) SOMATIC_DISRUPTION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.SOMATIC_DISRUPTION) VCFFileReader(htsjdk.variant.vcf.VCFFileReader) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Multimap(com.google.common.collect.Multimap) StructuralVariant(com.hartwig.hmftools.common.variant.structural.StructuralVariant) HmfGenePanelSupplier(com.hartwig.hmftools.genepanel.HmfGenePanelSupplier) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) GenomePosition(com.hartwig.hmftools.common.position.GenomePosition) VariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation) Map(java.util.Map) StructuralVariantType(com.hartwig.hmftools.common.variant.structural.StructuralVariantType) GenomePositions(com.hartwig.hmftools.common.position.GenomePositions) SnpEffect(nl.hartwigmedicalfoundation.bachelor.SnpEffect) GERMLINE_DELETION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.GERMLINE_DELETION) SortedSetMultimap(com.google.common.collect.SortedSetMultimap) OtherEffect(nl.hartwigmedicalfoundation.bachelor.OtherEffect) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Program(nl.hartwigmedicalfoundation.bachelor.Program) Set(java.util.Set) WhitelistPredicate(com.hartwig.hmftools.bachelor.predicates.WhitelistPredicate) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) GeneIdentifier(nl.hartwigmedicalfoundation.bachelor.GeneIdentifier) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) VariantContext(htsjdk.variant.variantcontext.VariantContext) HmfExonRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfExonRegion) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) BlacklistPredicate(com.hartwig.hmftools.bachelor.predicates.BlacklistPredicate) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)8 HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)4 NotNull (org.jetbrains.annotations.NotNull)4 Lists (com.google.common.collect.Lists)3 Sets (com.google.common.collect.Sets)3 FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)3 StructuralVariant (com.hartwig.hmftools.common.variant.structural.StructuralVariant)3 Alteration (com.hartwig.hmftools.patientreporter.report.data.Alteration)3 GeneDisruptionData (com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData)3 GeneFusionData (com.hartwig.hmftools.patientreporter.report.data.GeneFusionData)3 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)3 Collection (java.util.Collection)3 List (java.util.List)3 Set (java.util.Set)3 Predicate (java.util.function.Predicate)3 Collectors (java.util.stream.Collectors)3 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 HashMultimap (com.google.common.collect.HashMultimap)2 Maps (com.google.common.collect.Maps)2