From 90e19321bcca6f6266c541f4273e354d86907c38 Mon Sep 17 00:00:00 2001 From: Dror Kessler Date: Mon, 19 Jun 2023 10:14:23 +0300 Subject: [PATCH] --include-qc-failed-reads option --- .../featuremapping/FlowFeatureMapper.java | 12 +++++++ .../FlowFeatureMapperIntegrationTest.java | 31 +++++++++++++++++++ .../snv_feature_mapper_qc_failed_output.vcf | 3 ++ ...nv_feature_mapper_qc_failed_output.vcf.idx | 3 ++ 4 files changed, 49 insertions(+) create mode 100644 src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf create mode 100644 src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf.idx diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapper.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapper.java index b3ddc3e21b6..82ce79ad5d6 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapper.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapper.java @@ -103,6 +103,9 @@ public final class FlowFeatureMapper extends ReadWalker { private static final String VCF_SMQ_RIGHT_MEAN = "X_SMQ_RIGHT_MEAN"; private static final Double LOWEST_PROB = 0.0001; + private static final int VENDOR_QUALITY_CHECK_FLAG = 0x200; + + private static final String INCLUDE_QC_FAILED_READS_FULL_NAME = "include-qc-failed-reads"; @Argument(fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, @@ -131,6 +134,10 @@ public final class FlowFeatureMapper extends ReadWalker { @Argument(fullName=HaplotypeCallerArgumentCollection.OUTPUT_BLOCK_LOWER_BOUNDS, doc = "Output the band lower bound for each GQ block regardless of the data it represents", optional = true) public boolean floorBlocks = false; + @Advanced + @Argument(fullName=INCLUDE_QC_FAILED_READS_FULL_NAME, doc = "include reads with QC failed flag", optional = true) + public boolean includeQcFailedReads = false; + @ArgumentCollection public FlowBasedArgumentCollection fbargs = new FlowBasedArgumentCollection(); @@ -337,6 +344,11 @@ public void apply(final GATKRead read, final ReferenceContext referenceContext, return; } + // include qc-failed reads? + if ( ((read.getFlags() & VENDOR_QUALITY_CHECK_FLAG) != 0) && !includeQcFailedReads ) { + return; + } + // flush qeues up to this read flushQueue(read, referenceContext); diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapperIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapperIntegrationTest.java index 9958102b311..3663150b599 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapperIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/featuremapping/FlowFeatureMapperIntegrationTest.java @@ -116,4 +116,35 @@ public void testSurroundingAllQuality() throws IOException { } } + @Test + public void testQCFailed() throws IOException { + + final File outputDir = createTempDir("testFlowFeatureMapperTest"); + final File expectedFile = new File(testDir + "/snv_feature_mapper_qc_failed_output.vcf"); + final File outputFile = UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ? expectedFile : new File(outputDir + "/snv_feature_mapper_qc_failed_output.vcf"); + + final String[] args = new String[] { + "-R", largeFileTestDir + "/Homo_sapiens_assembly38.fasta.gz", + "-O", outputFile.getAbsolutePath(), + "-I", testDir + "/snv_feature_mapper_input.bam", + "--copy-attr", "tr", + "--limit-score", "100", + "--min-score", "0", + "--snv-identical-bases", "10", + "--debug-negatives", "false", + "--debug-read-name", "150451-BC94-0645901755", + "--include-qc-failed-reads", "true" + }; + + // run the tool + runCommandLine(args); // no assert, just make sure we don't throw + + // make sure we've generated the otuput file + Assert.assertTrue(outputFile.exists()); + + // walk the output and expected files, compare non-comment lines + if ( !UPDATE_EXACT_MATCH_EXPECTED_OUTPUTS ) { + IntegrationTestSpec.assertEqualTextFiles(outputFile, expectedFile, "#"); + } + } } diff --git a/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf b/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf new file mode 100644 index 00000000000..0d5f50fceed --- /dev/null +++ b/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:405fb1bf62168e22c504e0e4ae0d9d6b9ab4f7ac32ff18dcd77f071618d964da +size 5051930 diff --git a/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf.idx b/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf.idx new file mode 100644 index 00000000000..d31b3036198 --- /dev/null +++ b/src/test/resources/large/featureMapping/snv_feature_mapper_qc_failed_output.vcf.idx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7aba6151d662570d8e4a25cbb4717c65009c2d217375a287667b1f47c2db9925 +size 120123