Fixing 2 bugs in the SAMRecord printing argument descriptor code (as reported by Kristian):

* For some reason, the original implementor decided to use Booleans instead of booleans and didn't always check for null so we'd occasionally get a NPE.  Switched over to booleans.
* We'd also generate a NPE if SAMRecord writing specific arguments (e.g. --simplifyBAM) were used while writing to sdout.
This commit is contained in:
Eric Banks 2012-05-18 11:55:41 -04:00
parent 26968ae8eb
commit 3af3834d50
2 changed files with 13 additions and 9 deletions

View File

@ -116,9 +116,9 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
String compressionLevelText = getArgumentValue( createBAMCompressionArgumentDefinition(source), matches );
Integer compressionLevel = compressionLevelText != null ? Integer.valueOf(compressionLevelText) : null;
Boolean indexOnTheFly = !argumentIsPresent(disableWriteIndexArgumentDefinition(source),matches) ? true : null;
Boolean generateMD5 = argumentIsPresent(this.enableMD5GenerationArgumentDefinition(source),matches) ? true : null;
Boolean simplifyBAM = argumentIsPresent(createSimplifyBAMArgumentDefinition(source),matches);
boolean indexOnTheFly = !argumentIsPresent(disableWriteIndexArgumentDefinition(source),matches);
boolean generateMD5 = argumentIsPresent(this.enableMD5GenerationArgumentDefinition(source),matches);
boolean simplifyBAM = argumentIsPresent(createSimplifyBAMArgumentDefinition(source),matches);
// Validate the combination of parameters passed in.
@ -132,15 +132,19 @@ public class SAMFileWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor
}
// Create the stub and set parameters.
SAMFileWriterStub stub = new SAMFileWriterStub(engine, new File(writerFileName));
SAMFileWriterStub stub;
if ( writerFileName != null )
stub = new SAMFileWriterStub(engine, new File(writerFileName));
else
stub = new SAMFileWriterStub(engine, defaultOutputStream);
if( compressionLevel != null )
if ( compressionLevel != null )
stub.setCompressionLevel(compressionLevel);
if(indexOnTheFly != null)
if ( indexOnTheFly )
stub.setIndexOnTheFly(indexOnTheFly);
if(generateMD5 != null)
if ( generateMD5 )
stub.setGenerateMD5(generateMD5);
if(simplifyBAM != null)
if ( simplifyBAM )
stub.setSimplifyBAM(simplifyBAM);
// WARNING: Side effects required by engine!

View File

@ -92,7 +92,7 @@ import java.util.TreeSet;
@Requires({DataSource.READS, DataSource.REFERENCE})
public class PrintReadsWalker extends ReadWalker<GATKSAMRecord, SAMFileWriter> {
@Output(doc="Write output to this BAM filename instead of STDOUT")
@Output(doc="Write output to this BAM filename instead of STDOUT", required = true)
SAMFileWriter out;
@Argument(fullName = "readGroup", shortName = "readGroup", doc="Exclude all reads with this read group from the output", required = false)