use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class OrientationBiasFiltererUnitTest method testAnnotateVariantContextWithPreprocessingValues.
@Test
public void testAnnotateVariantContextWithPreprocessingValues() {
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2Vcf));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('G', 'T'));
final Map<Transition, Double> preAdapterQFakeScoreMap = new HashMap<>();
final double amGTPreAdapterQ = 20.0;
// preAdapterQ suppression will do nothing.
preAdapterQFakeScoreMap.put(Transition.transitionOf('G', 'T'), amGTPreAdapterQ);
for (final VariantContext vc : featureDataSource) {
final VariantContext updatedVariantContext = OrientationBiasFilterer.annotateVariantContextWithPreprocessingValues(vc, relevantTransitions, preAdapterQFakeScoreMap);
final Genotype genotypeTumor = updatedVariantContext.getGenotype("TUMOR");
final Genotype genotypeNormal = updatedVariantContext.getGenotype("NORMAL");
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.FOB, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
Assert.assertNotEquals(genotypeTumor.getExtendedAttribute(OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME, VCFConstants.EMPTY_ALLELE), VCFConstants.EMPTY_ALLELE);
assertArtifact(amGTPreAdapterQ, genotypeTumor, Transition.transitionOf('G', 'T'));
// The NORMAL is always ref/ref in the example file.
assertNormal(genotypeNormal);
}
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class OrientationBiasUtilsUnitTest method testCountNumTransition.
@Test
public void testCountNumTransition() {
// Setup the test
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(new File(smallM2VcfMore));
SortedSet<Transition> relevantTransitions = new TreeSet<>();
relevantTransitions.add(Transition.transitionOf('T', 'A'));
final List<VariantContext> variantContexts = getVariantContexts(featureDataSource);
// Should be one, since one of the variants was filtered.
Assert.assertEquals(OrientationBiasUtils.calculateNumTransition("TUMOR", variantContexts, relevantTransitions.first()), 1);
Assert.assertEquals(OrientationBiasUtils.calculateNumTransition("NORMAL", variantContexts, relevantTransitions.first()), 0);
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class SVVariantConsensusDiscoveryUnitTest method seeIfItWorks_integrative.
// -----------------------------------------------------------------------------------------------
// Integrative test
// -----------------------------------------------------------------------------------------------
private static void seeIfItWorks_integrative(final Tuple4<AlignedAssembly.AlignmentInterval, AlignedAssembly.AlignmentInterval, NovelAdjacencyReferenceLocations, String> testData, final List<String> expectedAttributeKeys) throws IOException {
final AlignedAssembly.AlignmentInterval region1 = testData._1();
final AlignedAssembly.AlignmentInterval region2 = testData._2();
// hack, as the contig sequence is really not necessary for this test purpose
final byte[] contigSeq = null;
final Iterable<ChimericAlignment> evidence = Collections.singletonList(new ChimericAlignment(region1, region2, Collections.emptyList(), testData._4()));
final NovelAdjacencyReferenceLocations breakpoints = testData._3();
final VariantContext variantContext = SVVariantConsensusDiscovery.discoverVariantsFromConsensus(new Tuple2<>(breakpoints, evidence), SparkContextFactory.getTestSparkContext().broadcast(SVDiscoveryTestDataProvider.reference));
final List<String> attributeKeys = variantContext.getAttributes().keySet().stream().sorted().collect(Collectors.toList());
Assert.assertEquals(attributeKeys, expectedAttributeKeys);
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class StructuralVariationDiscoveryPipelineSparkIntegrationTest method svDiscoveryVCFEquivalenceTest.
public static void svDiscoveryVCFEquivalenceTest(final String generatedVCFPath, final String expectedVCFPath, final List<String> attributesToIgnore, final boolean onHDFS) throws Exception {
VCFFileReader fileReader;
CloseableIterator<VariantContext> iterator;
final List<VariantContext> actualVcs;
if (onHDFS) {
final File tempLocalVCF = BaseTest.createTempFile("variants", "vcf");
tempLocalVCF.deleteOnExit();
BucketUtils.copyFile(generatedVCFPath, tempLocalVCF.getAbsolutePath());
fileReader = new VCFFileReader(tempLocalVCF, false);
} else {
fileReader = new VCFFileReader(new File(generatedVCFPath), false);
}
iterator = fileReader.iterator();
actualVcs = Utils.stream(iterator).collect(Collectors.toList());
CloserUtil.close(iterator);
CloserUtil.close(fileReader);
fileReader = new VCFFileReader(new File(expectedVCFPath), false);
iterator = fileReader.iterator();
final List<VariantContext> expectedVcs = Utils.stream(iterator).collect(Collectors.toList());
CloserUtil.close(iterator);
CloserUtil.close(fileReader);
BaseTest.assertCondition(actualVcs, expectedVcs, (a, e) -> VariantContextTestUtils.assertVariantContextsAreEqual(a, e, attributesToIgnore));
}
use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.
the class GenotypeGVCFsIntegrationTest method runGenotypeGVCFSAndAssertSomething.
private void runGenotypeGVCFSAndAssertSomething(String input, File expected, List<String> additionalArguments, BiConsumer<VariantContext, VariantContext> assertion, String reference) throws IOException {
final File output = createTempFile("genotypegvcf", ".vcf");
final ArgumentsBuilder args = new ArgumentsBuilder();
args.addReference(new File(reference)).addArgument("V", input).addOutput(output);
additionalArguments.forEach(args::add);
Utils.resetRandomGenerator();
runCommandLine(args);
final List<VariantContext> expectedVC = getVariantContexts(expected);
final List<VariantContext> actualVC = getVariantContexts(output);
assertForEachElementInLists(actualVC, expectedVC, assertion);
}
Aggregations