use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class FilterByOrientationBias method apply.
/**
* Just adds the Pre Adapter Q annotation to the variant and creates a new variant.
*
* Note: the writing of the VCF is not done here, since we need to aggregate once we have OxoQ scores.
* Note: No variant is dropped, if no additional annotation was needed, then the original format field is
* preserved
* @param variant See {@link VariantWalker}
* @param readsContext See {@link VariantWalker}
* @param referenceContext See {@link VariantWalker}
* @param featureContext See {@link VariantWalker}
*/
@Override
public void apply(VariantContext variant, ReadsContext readsContext, ReferenceContext referenceContext, FeatureContext featureContext) {
final VariantContext updatedVariant = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(variant, relevantTransitions, transitionToPreAdapterScoreMap);
firstPassVariants.add(updatedVariant);
// See onTraversalSuccess for the actual filtering.
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class FilterByOrientationBias method onTraversalSuccess.
@Override
public Object onTraversalSuccess() {
logger.info("Tagging whether genotypes are in one of the artifact modes.");
// Calculate how many artifacts need to be cut
double fdrThreshold = 0.01;
final List<VariantContext> finalVariants = OrientationBiasFilterer.annotateVariantContextsWithFilterResults(fdrThreshold, relevantTransitions, firstPassVariants, transitionToPreAdapterScoreMap);
logger.info("Writing variants to VCF...");
finalVariants.forEach(vcfWriter::add);
logger.info("Writing a simple summary table...");
List<String> sampleNames = new ArrayList<>();
if (finalVariants.size() != 0) {
sampleNames = finalVariants.get(0).getSampleNamesOrderedByName();
}
final List<Pair<String, Transition>> sampleTransitionCombinations = new ArrayList<>();
for (Transition relevantTransition : relevantTransitions) {
for (String sampleName : sampleNames) {
sampleTransitionCombinations.add(Pair.of(sampleName, relevantTransition));
}
}
OrientationBiasUtils.writeOrientationBiasSummaryTable(sampleTransitionCombinations, finalVariants, transitionToPreAdapterScoreMap, new File(outputFile.getAbsolutePath() + SUMMARY_FILE_SUFFIX));
return null;
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class SVVCFWriter method writeVCF.
/**
* FASTA and Broadcast references are both required because 2bit Broadcast references currently order their
* sequence dictionaries in a scrambled order, see https://github.com/broadinstitute/gatk/issues/2037.
*/
public static void writeVCF(final PipelineOptions pipelineOptions, final String vcfFileName, final String fastaReference, final JavaRDD<VariantContext> variantContexts, final Logger logger) {
final SAMSequenceDictionary referenceSequenceDictionary = new ReferenceMultiSource(pipelineOptions, fastaReference, ReferenceWindowFunctions.IDENTITY_FUNCTION).getReferenceSequenceDictionary(null);
final List<VariantContext> sortedVariantsList = sortVariantsByCoordinate(variantContexts.collect(), referenceSequenceDictionary);
logNumOfVarByTypes(sortedVariantsList, logger);
writeVariants(pipelineOptions, vcfFileName, sortedVariantsList, referenceSequenceDictionary);
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class GenotypingEngineUnitTest method init.
@BeforeTest
public void init() {
genotypingEngine = getGenotypingEngine();
final int deletionSize = refAllele.length() - altT.length();
final int start = 1;
final VariantContext deletionVC = new VariantContextBuilder("testDeletion", "1", start, start + deletionSize, allelesDel).make();
genotypingEngine.recordDeletion(deletionSize, deletionVC);
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class ApplyVQSRIntegrationTest method testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered.
@Test
public void testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered() throws Exception {
ArgumentsBuilder args = new ArgumentsBuilder();
File tempOut = createTempFile("testApplyRecalibrationSnpAndIndelTogetherExcludeFiltered", ".vcf");
args.add("--variant");
args.add(new File(getToolTestDataDir() + "VQSR.mixedTest.input.vcf"));
args.add("-L");
args.add("20:1000100-1000500");
args.add("-mode");
args.add("BOTH");
args.add("--excludeFiltered");
args.add("-ts_filter_level");
args.add("90.0");
args.add("-tranchesFile ");
args.add(getToolTestDataDir() + "VQSR.mixedTest.tranches");
args.add("-recalFile");
args.add(getToolTestDataDir() + "VQSR.mixedTest.recal.vcf");
args.addOutput(tempOut);
runCommandLine(args);
try (FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(tempOut)) {
for (VariantContext feature : featureSource) {
// there should only be unfiltered records in the output VCF file
Assert.assertTrue(feature.isNotFiltered());
}
}
}
Aggregations