(Slightly) better exception text when SAM/BAM output file can't be created.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4392 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-09-30 18:43:22 +00:00
parent 1fb8c86f6d
commit 14e19f4605
1 changed files with 11 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import net.sf.samtools.util.CloseableIterator;
import java.io.*; import java.io.*;
import net.sf.samtools.util.RuntimeIOException;
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterStub; import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterStub;
import org.broadinstitute.sting.utils.exceptions.UserException; import org.broadinstitute.sting.utils.exceptions.UserException;
@ -63,10 +64,15 @@ public class SAMFileWriterStorage implements SAMFileWriter, Storage<SAMFileWrite
if(stub.getSAMFile().getPath().equals("/dev/null")) if(stub.getSAMFile().getPath().equals("/dev/null"))
factory.setCreateIndex(false); factory.setCreateIndex(false);
if( stub.getCompressionLevel() != null ) try {
this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() ); if( stub.getCompressionLevel() != null )
else this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() );
this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file ); else
this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file );
}
catch(RuntimeIOException ex) {
throw new UserException.CouldNotCreateOutputFile(file,"file could not be created",ex);
}
} }
else if(stub.getSAMOutputStream() != null){ else if(stub.getSAMOutputStream() != null){
this.writer = factory.makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream()); this.writer = factory.makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream());