Allowing the GATK to have non-required outputs

Modified the SAMFileWriterArgumentTypeDescriptor to accept output bam files that are null if they're not required (in the @Output annotation).

This change enables the nWayOut parameter for the IndeRealigner and ReduceReads to operate optionally while maintaining the original single way out.

[#DEV-10 transition:31 resolution:1]
This commit is contained in:
Mauricio Carneiro 2012-10-12 13:50:10 -04:00
parent a234bacb02
commit 80d92e0c63
3 changed files with 27 additions and 23 deletions

View File

@ -124,32 +124,28 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
// This parser has been passed a null filename and the GATK is not responsible for creating a type default for the object; // This parser has been passed a null filename and the GATK is not responsible for creating a type default for the object;
// therefore, the user must have failed to specify a type default // therefore, the user must have failed to specify a type default
if(writerFileName == null) { if(writerFileName == null && generateMD5)
if(!source.isRequired())
throw new MissingArgumentValueException(bamArgumentDefinition);
if(generateMD5)
throw new ArgumentException("MD5 generation specified, but no output file specified. If md5 generation is desired, please specify a BAM output file and an md5 file will be written alongside."); throw new ArgumentException("MD5 generation specified, but no output file specified. If md5 generation is desired, please specify a BAM output file and an md5 file will be written alongside.");
}
// Create the stub and set parameters. // Create the stub and set parameters.
SAMFileWriterStub stub; SAMFileWriterStub stub = null; // stub = new SAMFileWriterStub(engine, defaultOutputStream);
if ( writerFileName != null )
if ( writerFileName != null ) {
stub = new SAMFileWriterStub(engine, new File(writerFileName)); stub = new SAMFileWriterStub(engine, new File(writerFileName));
else
stub = new SAMFileWriterStub(engine, defaultOutputStream);
if ( compressionLevel != null ) if ( compressionLevel != null )
stub.setCompressionLevel(compressionLevel); stub.setCompressionLevel(compressionLevel);
if ( indexOnTheFly ) if ( indexOnTheFly )
stub.setIndexOnTheFly(indexOnTheFly); stub.setIndexOnTheFly(indexOnTheFly);
if ( generateMD5 ) if ( generateMD5 )
stub.setGenerateMD5(generateMD5); stub.setGenerateMD5(generateMD5);
if ( simplifyBAM ) if ( simplifyBAM )
stub.setSimplifyBAM(simplifyBAM); stub.setSimplifyBAM(simplifyBAM);
// WARNING: Side effects required by engine! // WARNING: Side effects required by engine!
parsingEngine.addTags(stub,getArgumentTags(matches)); parsingEngine.addTags(stub,getArgumentTags(matches));
engine.addOutput(stub); engine.addOutput(stub);
}
return stub; return stub;
} }

View File

@ -370,8 +370,6 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
currentInterval = intervals.hasNext() ? intervals.next() : null; currentInterval = intervals.hasNext() ? intervals.next() : null;
writerToUse = writer;
if ( N_WAY_OUT != null ) { if ( N_WAY_OUT != null ) {
boolean createIndex = true; boolean createIndex = true;
@ -383,9 +381,9 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
createIndex, generateMD5s,createProgramRecord(),KEEP_ALL_PG_RECORDS); createIndex, generateMD5s,createProgramRecord(),KEEP_ALL_PG_RECORDS);
} }
} else { } else {
// set up the output writer // set up the output writer
setupWriter(getToolkit().getSAMFileHeader()); setupWriter(getToolkit().getSAMFileHeader());
writerToUse = writer;
} }
manager = new ConstrainedMateFixingManager(writerToUse, getToolkit().getGenomeLocParser(), MAX_ISIZE_FOR_MOVEMENT, MAX_POS_MOVE_ALLOWED, MAX_RECORDS_IN_MEMORY); manager = new ConstrainedMateFixingManager(writerToUse, getToolkit().getGenomeLocParser(), MAX_ISIZE_FOR_MOVEMENT, MAX_POS_MOVE_ALLOWED, MAX_RECORDS_IN_MEMORY);

View File

@ -113,4 +113,14 @@ public class IndelRealignerIntegrationTest extends WalkerTest {
executeTest(String.format("realigner [%s]", entry.getKey()), spec); executeTest(String.format("realigner [%s]", entry.getKey()), spec);
} }
} }
@Test
public void testNWayOut() {
WalkerTestSpec spec1 = new WalkerTestSpec(
baseCommandPrefix + " -nWayOut .clean.bam ",
1,
Arrays.asList("d41d8cd98f00b204e9800998ecf8427e"));
executeTest("test realigner nWayOut", spec1);
}
} }