use of com.hartwig.hmftools.common.variant.EnrichedSomaticVariant 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");
}
use of com.hartwig.hmftools.common.variant.EnrichedSomaticVariant in project hmftools by hartwigmedical.
the class SomaticVariantDAO method write.
void write(@NotNull final String sample, @NotNull List<EnrichedSomaticVariant> variants) {
Timestamp timestamp = new Timestamp(new Date().getTime());
context.delete(SOMATICVARIANT).where(SOMATICVARIANT.SAMPLEID.eq(sample)).execute();
for (List<EnrichedSomaticVariant> splitRegions : Iterables.partition(variants, DB_BATCH_INSERT_SIZE)) {
InsertValuesStepN inserter = context.insertInto(SOMATICVARIANT, SOMATICVARIANT.SAMPLEID, SOMATICVARIANT.CHROMOSOME, SOMATICVARIANT.POSITION, SOMATICVARIANT.FILTER, SOMATICVARIANT.TYPE, SOMATICVARIANT.REF, SOMATICVARIANT.ALT, SOMATICVARIANT.GENE, SOMATICVARIANT.GENESEFFECTED, SOMATICVARIANT.COSMICID, SOMATICVARIANT.DBSNPID, SOMATICVARIANT.WORSTEFFECT, SOMATICVARIANT.WORSTCODINGEFFECT, SOMATICVARIANT.WORSTEFFECTTRANSCRIPT, SOMATICVARIANT.CANONICALEFFECT, SOMATICVARIANT.CANONICALCODINGEFFECT, SOMATICVARIANT.ALLELEREADCOUNT, SOMATICVARIANT.TOTALREADCOUNT, SOMATICVARIANT.ADJUSTEDCOPYNUMBER, SOMATICVARIANT.ADJUSTEDVAF, SOMATICVARIANT.HIGHCONFIDENCE, SOMATICVARIANT.TRINUCLEOTIDECONTEXT, SOMATICVARIANT.MICROHOMOLOGY, SOMATICVARIANT.REPEATSEQUENCE, SOMATICVARIANT.REPEATCOUNT, SOMATICVARIANT.CLONALITY, SOMATICVARIANT.BIALLELIC, SOMATICVARIANT.HOTSPOT, SOMATICVARIANT.MAPPABILITY, SOMATICVARIANT.GERMLINESTATUS, SOMATICVARIANT.MINORALLELEPLOIDY, SOMATICVARIANT.MODIFIED);
splitRegions.forEach(x -> addRecord(timestamp, inserter, sample, x));
inserter.execute();
}
}
Aggregations