From 3bcd4c5d752f516a4dcb5e04d81ff17cdfa12d9b Mon Sep 17 00:00:00 2001 From: depristo Date: Sat, 26 Mar 2011 14:57:18 +0000 Subject: [PATCH] --simplifyBAM is now in the SAMFileWriterArgumentTypeDescriptor, as suggested by map. PrintReads has an integrationtest now that writes out a 1 MB bit of HiSeq normally, with compress 0, and with simplifyBAM on. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5521 348d0f76-0448-11de-a6fe-93d51630548a --- .../arguments/GATKArgumentCollection.java | 7 ---- .../SAMFileWriterArgumentTypeDescriptor.java | 23 +++++++++- .../gatk/io/stubs/SAMFileWriterStub.java | 11 ++++- .../walkers/PrintReadsIntegrationTest.java | 42 +++++++++++++++++++ 4 files changed, 74 insertions(+), 9 deletions(-) create mode 100755 java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsIntegrationTest.java diff --git a/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java b/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java index 890b0830f..4e81b8294 100755 --- a/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java +++ b/java/src/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollection.java @@ -118,10 +118,6 @@ public class GATKArgumentCollection { @Input(fullName = "DBSNP", shortName = "D", doc = "DBSNP file", required = false) public String DBSNPFile = null; - @Element(required = false) - @Argument(fullName = "simplifyBAM", shortName = "simplifyBAM", doc = "If provided, output BAM files will be simplified to include just key reads for downstream variation discovery analyses (removing duplicates, PF-, non-primary reads), as well stripping all extended tags from the kept reads except the read group identifier", required = false) - public boolean simplifyBAM = false; - /** * The override mechanism in the GATK, by default, populates the command-line arguments, then * the defaults from the walker annotations. Unfortunately, walker annotations should be trumped @@ -439,9 +435,6 @@ public class GATKArgumentCollection { if (enableLowMemorySharding != other.enableLowMemorySharding) return false; - if ( simplifyBAM != other.simplifyBAM ) - return false; - return true; } diff --git a/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterArgumentTypeDescriptor.java b/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterArgumentTypeDescriptor.java index 0ba01b22f..13d10961c 100644 --- a/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterArgumentTypeDescriptor.java +++ b/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterArgumentTypeDescriptor.java @@ -48,6 +48,9 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor public static final String COMPRESSION_FULLNAME = "bam_compression"; public static final String COMPRESSION_SHORTNAME = "compress"; + public static final String SIMPLIFY_BAM_FULLNAME = "simplifyBAM"; + public static final String SIMPLIFY_BAM_SHORTNAME = SIMPLIFY_BAM_FULLNAME; + public static final String CREATE_INDEX_FULLNAME = "index_output_bam_on_the_fly"; /** @@ -79,7 +82,8 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor public List createArgumentDefinitions( ArgumentSource source ) { return Arrays.asList( createBAMArgumentDefinition(source), createBAMCompressionArgumentDefinition(source), - createWriteIndexArgumentDefinition(source)); + createWriteIndexArgumentDefinition(source), + createSimplifyBAMArgumentDefinition(source)); } @Override @@ -114,6 +118,7 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor stub.setCompressionLevel(compressionLevel); stub.setIndexOnTheFly(argumentIsPresent(createWriteIndexArgumentDefinition(source),matches)); + stub.setSimplifyBAM(argumentIsPresent(createSimplifyBAMArgumentDefinition(source),matches)); // WARNING: Side effects required by engine! parsingEngine.addTags(stub,getArgumentTags(matches)); @@ -181,4 +186,20 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor null, null ); } + + private ArgumentDefinition createSimplifyBAMArgumentDefinition(ArgumentSource source) { + return new ArgumentDefinition( ArgumentIOType.ARGUMENT, + boolean.class, + SIMPLIFY_BAM_FULLNAME, + SIMPLIFY_BAM_SHORTNAME, + "If provided, output BAM files will be simplified to include just key reads for downstream variation discovery analyses (removing duplicates, PF-, non-primary reads), as well stripping all extended tags from the kept reads except the read group identifier", + false, + false, + false, + source.isHidden(), + null, + null, + null, + null ); + } } diff --git a/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterStub.java b/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterStub.java index 7d9908f82..e11f53a4b 100644 --- a/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterStub.java +++ b/java/src/org/broadinstitute/sting/gatk/io/stubs/SAMFileWriterStub.java @@ -107,6 +107,11 @@ public class SAMFileWriterStub implements Stub, StingSAMFileWrite */ BAQ baqHMM = new BAQ(); + /** + * Should we simplify the BAM file while writing it out? + */ + private boolean simplifyBAM = false; + /** * Create a new stub given the requested SAM file and compression level. * @param engine source of header data, maybe other data about input files. @@ -138,7 +143,11 @@ public class SAMFileWriterStub implements Stub, StingSAMFileWrite } public boolean simplifyBAM() { - return engine.getArguments().simplifyBAM; + return simplifyBAM; + } + + public void setSimplifyBAM(boolean v) { + simplifyBAM = v; } public OutputStream getSAMOutputStream() { diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsIntegrationTest.java new file mode 100755 index 000000000..760be86b2 --- /dev/null +++ b/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsIntegrationTest.java @@ -0,0 +1,42 @@ +package org.broadinstitute.sting.gatk.walkers; + +import org.broadinstitute.sting.WalkerTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.HashMap; + +public class PrintReadsIntegrationTest extends WalkerTest { + private static class PRTest { + final static String REF = hg18Reference; + final static String BAM = validationDataLocation + "HiSeq.1mb.bam"; + String args; + String md5; + + private PRTest(String args, String md5) { + this.args = args; + this.md5 = md5; + } + } + + @DataProvider(name = "PRTest") + public Object[][] createData1() { + return new Object[][]{ + {new PRTest("", "dc8e5451dd29757c336013146010f73a")}, + {new PRTest(" -compress 0", "fde82269c78c9e91e57286433531b4af")}, + {new PRTest(" -simplifyBAM", "0531717b32a7e21c0de70b1526b0751f")} }; + } + + @Test(dataProvider = "PRTest") + public void testPrintReads(PRTest params) { + WalkerTestSpec spec = new WalkerTestSpec( + "-T PrintReads -R " + params.REF + + " -I " + params.BAM + + params.args + + " -o %s", + Arrays.asList(params.md5)); + executeTest("testVariantRecalibrator-"+params.args, spec).getFirst(); + } +} +