use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk by broadinstitute.
the class AnnotateVcfWithBamDepthIntegrationTest method test.
// test on the DREAM bam 1 and accompanying variants
// depths verified manually in IGV
@Test
public void test() {
final File bam = new File(DREAM_BAMS_DIR, "tumor_1.bam");
final File vcf = new File(DREAM_VCFS_DIR, "sample_1.vcf");
final File outputVcf = createTempFile("annotated", ".vcf");
final String[] arguments = { "-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME, vcf.getAbsolutePath(), "-" + StandardArgumentDefinitions.INPUT_SHORT_NAME, bam.getAbsolutePath(), "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, outputVcf.getAbsolutePath() };
runCommandLine(arguments);
final List<VariantContext> input = StreamSupport.stream(new FeatureDataSource<VariantContext>(vcf).spliterator(), false).collect(Collectors.toList());
final List<VariantContext> output = StreamSupport.stream(new FeatureDataSource<VariantContext>(outputVcf).spliterator(), false).collect(Collectors.toList());
Assert.assertEquals(input.size(), output.size());
final List<String> inputKeys = input.stream().map(vc -> keyForVariant(vc)).collect(Collectors.toList());
final List<String> outputKeys = output.stream().map(vc -> keyForVariant(vc)).collect(Collectors.toList());
Assert.assertEquals(inputKeys, outputKeys);
final List<Integer> bamDepths = output.stream().map(vc -> vc.getAttributeAsInt(AnnotateVcfWithBamDepth.POOLED_BAM_DEPTH_ANNOTATION_NAME, -1)).collect(Collectors.toList());
final List<Integer> firstSeveralDepthsFromIGV = Arrays.asList(33, 39, 19, 35, 25, 27);
Assert.assertEquals(bamDepths.subList(0, firstSeveralDepthsFromIGV.size()), firstSeveralDepthsFromIGV);
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk-protected by broadinstitute.
the class FilterByOrientationBiasIntegrationTest method testHighPloidyRun.
@Test
public void testHighPloidyRun() throws IOException {
final File outputFile = File.createTempFile("ob_high_ploidy", ".vcf");
final List<String> arguments = new ArrayList<>();
arguments.add("-" + FilterByOrientationBias.PRE_ADAPTER_METRICS_DETAIL_FILE_SHORT_NAME);
arguments.add(preAdapterQFile);
arguments.add("-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME);
arguments.add(smallHighDiploid);
arguments.add("-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME);
arguments.add(outputFile.getAbsolutePath());
runCommandLine(arguments);
Assert.assertTrue(outputFile.exists());
final List<VariantContext> variantContexts = new ArrayList<>();
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(outputFile);
for (final VariantContext vc : featureDataSource) {
variantContexts.add(vc);
}
Assert.assertEquals(variantContexts.size(), 1);
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk-protected by broadinstitute.
the class FilterByOrientationBiasIntegrationTest method testMultiallelic.
@Test
public void testMultiallelic() throws IOException {
final File outputFile = File.createTempFile("ob_ma", ".vcf");
final List<String> arguments = new ArrayList<>();
arguments.add("-" + FilterByOrientationBias.PRE_ADAPTER_METRICS_DETAIL_FILE_SHORT_NAME);
arguments.add(preAdapterQFile);
arguments.add("-" + FilterByOrientationBias.ARTIFACT_MODES_SHORT_NAME);
arguments.add("C/T");
arguments.add("-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME);
arguments.add(smallMA);
arguments.add("-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME);
arguments.add(outputFile.getAbsolutePath());
runCommandLine(arguments);
Assert.assertTrue(outputFile.exists());
final List<VariantContext> variantContexts = new ArrayList<>();
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(outputFile);
for (final VariantContext vc : featureDataSource) {
variantContexts.add(vc);
}
// It is important to remember that the filter only looks at the first alternate allele.
Assert.assertEquals(variantContexts.size(), 5);
// The first variant should have a null in the been OB filter annotation.
Assert.assertTrue(variantContexts.get(0).getGenotype(0).getExtendedAttribute("OBAMRC").toString().equals("false"));
Assert.assertTrue(variantContexts.get(0).getGenotype(0).getExtendedAttribute("OBQRC").toString().equals("100.00"));
// The second variant should not be filtered
Assert.assertTrue(variantContexts.get(1).getGenotype(0).getExtendedAttribute("OBAMRC").toString().equals("true"));
Assert.assertTrue(variantContexts.get(2).getGenotype(0).getExtendedAttribute("GT") == null);
Assert.assertTrue(Double.parseDouble(variantContexts.get(1).getGenotype(0).getExtendedAttribute("OBQRC").toString()) < 100.0);
// The third variant should be filtered
Assert.assertTrue(variantContexts.get(2).getGenotype(0).getExtendedAttribute("OBAMRC").toString().equals("true"));
Assert.assertTrue(Double.parseDouble(variantContexts.get(2).getGenotype(0).getExtendedAttribute("OBQRC").toString()) < 100.0);
// fourth is in artifact mode
Assert.assertTrue(variantContexts.get(3).getGenotype(0).getExtendedAttribute("OBAMRC").toString().equals("false"));
Assert.assertTrue(variantContexts.get(3).getGenotype(0).getExtendedAttribute("OBAM").toString().equals("true"));
Assert.assertTrue(Double.parseDouble(variantContexts.get(3).getGenotype(0).getExtendedAttribute("OBQ").toString()) < 100.0);
Assert.assertTrue(variantContexts.get(4).getGenotype(0).getExtendedAttribute("OBAM").toString().equals("false"));
Assert.assertTrue(variantContexts.get(4).getGenotype(0).getExtendedAttribute("OBQ").toString().equals("100.00"));
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk-protected by broadinstitute.
the class FilterByOrientationBiasIntegrationTest method testNoVariantsNoSamplesRun.
@Test
public void testNoVariantsNoSamplesRun() throws IOException {
final File outputFile = File.createTempFile("ob_no_variants_no_sample", ".vcf");
final List<String> arguments = new ArrayList<>();
arguments.add("-" + FilterByOrientationBias.PRE_ADAPTER_METRICS_DETAIL_FILE_SHORT_NAME);
arguments.add(preAdapterQFile);
arguments.add("-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME);
arguments.add(emptyVcfNoSamples);
arguments.add("-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME);
arguments.add(outputFile.getAbsolutePath());
runCommandLine(arguments);
Assert.assertTrue(outputFile.exists());
final List<VariantContext> variantContexts = new ArrayList<>();
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(outputFile);
for (final VariantContext vc : featureDataSource) {
variantContexts.add(vc);
}
Assert.assertEquals(variantContexts.size(), 0);
Assert.assertTrue(FileUtils.sizeOf(outputFile) > 0);
final File summaryFile = new File(outputFile.getAbsolutePath() + FilterByOrientationBias.SUMMARY_FILE_SUFFIX);
Assert.assertTrue(summaryFile.exists());
Assert.assertTrue(FileUtils.sizeOf(summaryFile) > 0);
final List<OrientationSampleTransitionSummary> summaries = OrientationBiasUtils.readOrientationBiasSummaryTable(summaryFile);
Assert.assertEquals(summaries.size(), 0);
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk-protected by broadinstitute.
the class AnnotateVcfWithBamDepthIntegrationTest method test.
// test on the DREAM bam 1 and accompanying variants
// depths verified manually in IGV
@Test
public void test() {
final File bam = new File(DREAM_BAMS_DIR, "tumor_1.bam");
final File vcf = new File(DREAM_VCFS_DIR, "sample_1.vcf");
final File outputVcf = createTempFile("annotated", ".vcf");
final String[] arguments = { "-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME, vcf.getAbsolutePath(), "-" + StandardArgumentDefinitions.INPUT_SHORT_NAME, bam.getAbsolutePath(), "-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME, outputVcf.getAbsolutePath() };
runCommandLine(arguments);
final List<VariantContext> input = StreamSupport.stream(new FeatureDataSource<VariantContext>(vcf).spliterator(), false).collect(Collectors.toList());
final List<VariantContext> output = StreamSupport.stream(new FeatureDataSource<VariantContext>(outputVcf).spliterator(), false).collect(Collectors.toList());
Assert.assertEquals(input.size(), output.size());
final List<String> inputKeys = input.stream().map(vc -> keyForVariant(vc)).collect(Collectors.toList());
final List<String> outputKeys = output.stream().map(vc -> keyForVariant(vc)).collect(Collectors.toList());
Assert.assertEquals(inputKeys, outputKeys);
final List<Integer> bamDepths = output.stream().map(vc -> vc.getAttributeAsInt(AnnotateVcfWithBamDepth.POOLED_BAM_DEPTH_ANNOTATION_NAME, -1)).collect(Collectors.toList());
final List<Integer> firstSeveralDepthsFromIGV = Arrays.asList(33, 39, 19, 35, 25, 27);
Assert.assertEquals(bamDepths.subList(0, firstSeveralDepthsFromIGV.size()), firstSeveralDepthsFromIGV);
}
Aggregations