Search in sources :

Example 1 with PassingVariantFilter

use of htsjdk.variant.variantcontext.filter.PassingVariantFilter in project hmftools by hartwigmedical.

the class SomaticVariantFactory method passOnlyInstance.

@NotNull
public static SomaticVariantFactory passOnlyInstance() {
    final CompoundFilter filter = new CompoundFilter(true);
    filter.add(new ChromosomeFilter());
    filter.add(new PassingVariantFilter());
    return new SomaticVariantFactory(filter);
}
Also used : PassingVariantFilter(htsjdk.variant.variantcontext.filter.PassingVariantFilter) CompoundFilter(htsjdk.variant.variantcontext.filter.CompoundFilter) ChromosomeFilter(com.hartwig.hmftools.common.variant.filter.ChromosomeFilter) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PassingVariantFilter

use of htsjdk.variant.variantcontext.filter.PassingVariantFilter in project hmftools by hartwigmedical.

the class LoadSomaticVariants 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 String vcfFileLocation = cmd.getOptionValue(VCF_FILE);
    final String highConfidenceBed = cmd.getOptionValue(HIGH_CONFIDENCE_BED);
    final String fastaFileLocation = cmd.getOptionValue(REF_GENOME);
    final String sample = cmd.getOptionValue(SAMPLE);
    final DatabaseAccess dbAccess = databaseAccess(cmd);
    final CompoundFilter filter = new CompoundFilter(true);
    if (cmd.hasOption(PASS_FILTER)) {
        filter.add(new PassingVariantFilter());
    }
    if (cmd.hasOption(SOMATIC_FILTER)) {
        filter.add(new SomaticFilter());
    }
    LOGGER.info("Reading somatic VCF File");
    final List<SomaticVariant> variants = SomaticVariantFactory.filteredInstance(filter).fromVCFFile(sample, vcfFileLocation);
    LOGGER.info("Reading high confidence bed file");
    final Multimap<String, GenomeRegion> highConfidenceRegions = BEDFileLoader.fromBedFile(highConfidenceBed);
    LOGGER.info("Loading indexed fasta reference file");
    IndexedFastaSequenceFile indexedFastaSequenceFile = new IndexedFastaSequenceFile(new File(fastaFileLocation));
    LOGGER.info("Querying purple database");
    final PurityContext purityContext = dbAccess.readPurityContext(sample);
    if (purityContext == null) {
        LOGGER.warn("Unable to retrieve purple data. Enrichment may be incomplete.");
    }
    final PurityAdjuster purityAdjuster = purityContext == null ? new PurityAdjuster(Gender.FEMALE, 1, 1) : new PurityAdjuster(purityContext.gender(), purityContext.bestFit().purity(), purityContext.bestFit().normFactor());
    final Multimap<String, PurpleCopyNumber> copyNumbers = Multimaps.index(dbAccess.readCopynumbers(sample), PurpleCopyNumber::chromosome);
    final Multimap<String, FittedRegion> copyNumberRegions = Multimaps.index(dbAccess.readCopyNumberRegions(sample), FittedRegion::chromosome);
    LOGGER.info("Incorporating purple purity");
    final PurityAdjustedSomaticVariantFactory purityAdjustmentFactory = new PurityAdjustedSomaticVariantFactory(purityAdjuster, copyNumbers, copyNumberRegions);
    final List<PurityAdjustedSomaticVariant> purityAdjustedVariants = purityAdjustmentFactory.create(variants);
    final double clonalPloidy = ClonalityCutoffKernel.clonalCutoff(purityAdjustedVariants);
    LOGGER.info("Enriching variants");
    final EnrichedSomaticVariantFactory enrichedSomaticVariantFactory = new EnrichedSomaticVariantFactory(highConfidenceRegions, indexedFastaSequenceFile, new ClonalityFactory(purityAdjuster, clonalPloidy), CanonicalTranscriptFactory.create(HmfGenePanelSupplier.allGeneList()));
    final List<EnrichedSomaticVariant> enrichedVariants = enrichedSomaticVariantFactory.enrich(purityAdjustedVariants);
    LOGGER.info("Persisting variants to database");
    dbAccess.writeSomaticVariants(sample, enrichedVariants);
    LOGGER.info("Complete");
}
Also used : Options(org.apache.commons.cli.Options) EnrichedSomaticVariant(com.hartwig.hmftools.common.variant.EnrichedSomaticVariant) PassingVariantFilter(htsjdk.variant.variantcontext.filter.PassingVariantFilter) FittedRegion(com.hartwig.hmftools.common.purple.region.FittedRegion) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) SomaticFilter(com.hartwig.hmftools.common.variant.filter.SomaticFilter) PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) PurityAdjustedSomaticVariant(com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariant) SomaticVariant(com.hartwig.hmftools.common.variant.SomaticVariant) EnrichedSomaticVariant(com.hartwig.hmftools.common.variant.EnrichedSomaticVariant) PurityAdjustedSomaticVariantFactory(com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariantFactory) CompoundFilter(htsjdk.variant.variantcontext.filter.CompoundFilter) PurityAdjustedSomaticVariant(com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariant) CommandLine(org.apache.commons.cli.CommandLine) GenomeRegion(com.hartwig.hmftools.common.region.GenomeRegion) PurityContext(com.hartwig.hmftools.common.purple.purity.PurityContext) EnrichedSomaticVariantFactory(com.hartwig.hmftools.common.variant.EnrichedSomaticVariantFactory) ClonalityFactory(com.hartwig.hmftools.common.variant.ClonalityFactory) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile)

Example 3 with PassingVariantFilter

use of htsjdk.variant.variantcontext.filter.PassingVariantFilter in project hmftools by hartwigmedical.

the class PurityPloidyEstimateApplication method somaticVariants.

@NotNull
private static List<SomaticVariant> somaticVariants(@NotNull final ConfigSupplier configSupplier) throws IOException {
    final SomaticConfig config = configSupplier.somaticConfig();
    if (config.file().isPresent()) {
        String filename = config.file().get().toString();
        LOGGER.info("Loading somatic variants from {}", filename);
        SomaticVariantFactory factory = SomaticVariantFactory.filteredInstance(new PassingVariantFilter(), new NTFilter(), new SGTFilter());
        return factory.fromVCFFile(configSupplier.commonConfig().tumorSample(), filename);
    } else {
        LOGGER.info("Somatic variants support disabled.");
        return Collections.emptyList();
    }
}
Also used : SomaticConfig(com.hartwig.hmftools.purple.config.SomaticConfig) SGTFilter(com.hartwig.hmftools.common.variant.filter.SGTFilter) SomaticVariantFactory(com.hartwig.hmftools.common.variant.SomaticVariantFactory) PurityAdjustedSomaticVariantFactory(com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariantFactory) PassingVariantFilter(htsjdk.variant.variantcontext.filter.PassingVariantFilter) NTFilter(com.hartwig.hmftools.common.variant.filter.NTFilter) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PassingVariantFilter (htsjdk.variant.variantcontext.filter.PassingVariantFilter)3 PurityAdjustedSomaticVariantFactory (com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariantFactory)2 CompoundFilter (htsjdk.variant.variantcontext.filter.CompoundFilter)2 NotNull (org.jetbrains.annotations.NotNull)2 PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)1 PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)1 PurityContext (com.hartwig.hmftools.common.purple.purity.PurityContext)1 FittedRegion (com.hartwig.hmftools.common.purple.region.FittedRegion)1 GenomeRegion (com.hartwig.hmftools.common.region.GenomeRegion)1 ClonalityFactory (com.hartwig.hmftools.common.variant.ClonalityFactory)1 EnrichedSomaticVariant (com.hartwig.hmftools.common.variant.EnrichedSomaticVariant)1 EnrichedSomaticVariantFactory (com.hartwig.hmftools.common.variant.EnrichedSomaticVariantFactory)1 PurityAdjustedSomaticVariant (com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariant)1 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)1 SomaticVariantFactory (com.hartwig.hmftools.common.variant.SomaticVariantFactory)1 ChromosomeFilter (com.hartwig.hmftools.common.variant.filter.ChromosomeFilter)1 NTFilter (com.hartwig.hmftools.common.variant.filter.NTFilter)1 SGTFilter (com.hartwig.hmftools.common.variant.filter.SGTFilter)1 SomaticFilter (com.hartwig.hmftools.common.variant.filter.SomaticFilter)1 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)1