From 2b6842596bfb4d8db5fdbed606157a6e4530151c Mon Sep 17 00:00:00 2001 From: Jonathan Baber Date: Wed, 24 Jul 2019 09:54:42 +1000 Subject: [PATCH] load somatic variants no longer needs ref genome --- .../VariantContextEnrichmentComplete.java | 49 ------------------- .../VariantContextEnrichmentLoadSomatics.java | 41 ++++++++++++++++ .../patientdb/LoadSomaticVariants.java | 13 +---- 3 files changed, 43 insertions(+), 60 deletions(-) delete mode 100644 hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentComplete.java create mode 100644 hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentLoadSomatics.java diff --git a/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentComplete.java b/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentComplete.java deleted file mode 100644 index 799971815b..0000000000 --- a/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentComplete.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.hartwig.hmftools.common.variant.enrich; - -import java.util.function.Consumer; - -import com.google.common.collect.Multimap; -import com.hartwig.hmftools.common.region.GenomeRegion; - -import org.jetbrains.annotations.NotNull; - -import htsjdk.samtools.reference.IndexedFastaSequenceFile; -import htsjdk.variant.variantcontext.VariantContext; -import htsjdk.variant.vcf.VCFHeader; - -public class VariantContextEnrichmentComplete implements VariantContextEnrichment { - - public static VariantContextEnrichmentFactory factory(@NotNull final IndexedFastaSequenceFile reference, - @NotNull final Multimap highConfidenceRegions) { - return consumer -> new VariantContextEnrichmentComplete(reference, highConfidenceRegions, consumer); - } - - private final KataegisEnrichment kataegisEnrichment; - private final SomaticRefContextEnrichment somaticRefContextEnrichment; - private final HighConfidenceEnrichment highConfidenceEnrichment; - - VariantContextEnrichmentComplete(@NotNull final IndexedFastaSequenceFile reference, - @NotNull final Multimap highConfidenceRegions, @NotNull final Consumer consumer) { - highConfidenceEnrichment = new HighConfidenceEnrichment(highConfidenceRegions, consumer); - kataegisEnrichment = new KataegisEnrichment(highConfidenceEnrichment); - somaticRefContextEnrichment = new SomaticRefContextEnrichment(reference, kataegisEnrichment); - } - - @Override - public void flush() { - somaticRefContextEnrichment.flush(); - kataegisEnrichment.flush(); - highConfidenceEnrichment.flush(); - } - - @NotNull - @Override - public VCFHeader enrichHeader(@NotNull final VCFHeader template) { - return highConfidenceEnrichment.enrichHeader(kataegisEnrichment.enrichHeader(somaticRefContextEnrichment.enrichHeader(template))); - } - - @Override - public void accept(@NotNull final VariantContext context) { - somaticRefContextEnrichment.accept(context); - } -} diff --git a/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentLoadSomatics.java b/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentLoadSomatics.java new file mode 100644 index 0000000000..d323388885 --- /dev/null +++ b/hmf-common/src/main/java/com/hartwig/hmftools/common/variant/enrich/VariantContextEnrichmentLoadSomatics.java @@ -0,0 +1,41 @@ +package com.hartwig.hmftools.common.variant.enrich; + +import java.util.function.Consumer; + +import com.google.common.collect.Multimap; +import com.hartwig.hmftools.common.region.GenomeRegion; + +import org.jetbrains.annotations.NotNull; + +import htsjdk.variant.variantcontext.VariantContext; +import htsjdk.variant.vcf.VCFHeader; + +public class VariantContextEnrichmentLoadSomatics implements VariantContextEnrichment { + + public static VariantContextEnrichmentFactory factory(@NotNull final Multimap highConfidenceRegions) { + return consumer -> new VariantContextEnrichmentLoadSomatics(highConfidenceRegions, consumer); + } + + private final HighConfidenceEnrichment highConfidenceEnrichment; + + private VariantContextEnrichmentLoadSomatics(@NotNull final Multimap highConfidenceRegions, + @NotNull final Consumer consumer) { + highConfidenceEnrichment = new HighConfidenceEnrichment(highConfidenceRegions, consumer); + } + + @Override + public void flush() { + highConfidenceEnrichment.flush(); + } + + @NotNull + @Override + public VCFHeader enrichHeader(@NotNull final VCFHeader template) { + return highConfidenceEnrichment.enrichHeader(template); + } + + @Override + public void accept(@NotNull final VariantContext context) { + highConfidenceEnrichment.accept(context); + } +} diff --git a/patient-db/src/main/java/com/hartwig/hmftools/patientdb/LoadSomaticVariants.java b/patient-db/src/main/java/com/hartwig/hmftools/patientdb/LoadSomaticVariants.java index 9f28d9ce5b..bfa98d8d45 100644 --- a/patient-db/src/main/java/com/hartwig/hmftools/patientdb/LoadSomaticVariants.java +++ b/patient-db/src/main/java/com/hartwig/hmftools/patientdb/LoadSomaticVariants.java @@ -1,6 +1,5 @@ package com.hartwig.hmftools.patientdb; -import java.io.File; import java.io.IOException; import java.sql.SQLException; import java.util.List; @@ -19,7 +18,7 @@ import com.hartwig.hmftools.common.variant.SomaticVariantFactory; import com.hartwig.hmftools.common.variant.enrich.CompoundEnrichment; import com.hartwig.hmftools.common.variant.enrich.HotspotEnrichment; -import com.hartwig.hmftools.common.variant.enrich.VariantContextEnrichmentComplete; +import com.hartwig.hmftools.common.variant.enrich.VariantContextEnrichmentLoadSomatics; import com.hartwig.hmftools.common.variant.filter.SomaticFilter; import com.hartwig.hmftools.patientdb.dao.DatabaseAccess; @@ -32,7 +31,6 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; -import htsjdk.samtools.reference.IndexedFastaSequenceFile; import htsjdk.variant.variantcontext.filter.CompoundFilter; import htsjdk.variant.variantcontext.filter.PassingVariantFilter; @@ -43,7 +41,6 @@ public class LoadSomaticVariants { private static final String SAMPLE = "sample"; private static final String HOTSPOT = "hotspot"; private static final String VCF_FILE = "vcf_file"; - private static final String REF_GENOME = "ref_genome"; private static final String PASS_FILTER = "pass_filter"; private static final String SOMATIC_FILTER = "somatic_filter"; private static final String HIGH_CONFIDENCE_BED = "high_confidence_bed"; @@ -57,7 +54,6 @@ public static void main(@NotNull final String[] args) throws ParseException, IOE 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); @@ -78,14 +74,10 @@ public static void main(@NotNull final String[] args) throws ParseException, IOE LOGGER.info("Reading high confidence bed file: {}", highConfidenceBed); final Multimap highConfidenceRegions = BEDFileLoader.fromBedFile(highConfidenceBed); - LOGGER.info("Loading indexed fasta reference file: {}", fastaFileLocation); - IndexedFastaSequenceFile indexedFastaSequenceFile = new IndexedFastaSequenceFile(new File(fastaFileLocation)); - LOGGER.info("Reading somatic VCF file: {}", vcfFileLocation); final List variants = SomaticVariantFactory.filteredInstanceWithEnrichment(filter, compoundEnrichment, - VariantContextEnrichmentComplete.factory(indexedFastaSequenceFile, highConfidenceRegions)) - .fromVCFFile(sample, vcfFileLocation); + VariantContextEnrichmentLoadSomatics.factory(highConfidenceRegions)).fromVCFFile(sample, vcfFileLocation); LOGGER.info("Querying purple database"); final List geneCopyNumbers = dbAccess.readGeneCopynumbers(sample); @@ -118,7 +110,6 @@ public static void main(@NotNull final String[] args) throws ParseException, IOE @NotNull private static Options createBasicOptions() { final Options options = new Options(); - options.addOption(REF_GENOME, true, "Path to the ref genome fasta file."); options.addOption(VCF_FILE, true, "Path to the vcf file."); options.addOption(HIGH_CONFIDENCE_BED, true, "Path to the high confidence bed file."); options.addOption(DB_USER, true, "Database user name.");