setMaxRecordsInRam now a member of StingSAMFileWriter.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4138 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-08-27 14:50:41 +00:00
parent 467405094a
commit 6f4af47aac
3 changed files with 37 additions and 3 deletions

View File

@ -22,4 +22,10 @@ public interface StingSAMFileWriter extends SAMFileWriter {
* @param presorted True if the BAM file is presorted. False otherwise.
*/
public void setPresorted(boolean presorted);
/**
* Set how many records in RAM the BAM file stores when sorting on-the-fly.
* @param maxRecordsInRam Max number of records in RAM.
*/
public void setMaxRecordsInRam(int maxRecordsInRam);
}

View File

@ -49,14 +49,18 @@ public class SAMFileWriterStorage implements SAMFileWriter, Storage<SAMFileWrite
public SAMFileWriterStorage( SAMFileWriterStub stub, File file ) {
this.file = file;
SAMFileWriterFactory factory = new SAMFileWriterFactory();
if(stub.getMaxRecordsInRam() != null)
factory.setMaxRecordsInRam(stub.getMaxRecordsInRam());
if(stub.getSAMFile() != null) {
if( stub.getCompressionLevel() != null )
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() );
this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file, stub.getCompressionLevel() );
else
this.writer = new SAMFileWriterFactory().makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file );
this.writer = factory.makeBAMWriter( stub.getFileHeader(), stub.isPresorted(), file );
}
else if(stub.getSAMOutputStream() != null){
this.writer = new SAMFileWriterFactory().makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream());
this.writer = factory.makeSAMWriter( stub.getFileHeader(), stub.isPresorted(), stub.getSAMOutputStream());
}
else
throw new StingException("Unable to write to SAM file; neither a target file nor a stream has been specified");

View File

@ -75,6 +75,12 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
*/
private boolean presorted = true;
/**
* How many records should the BAM writer store in RAM while
* sorting the BAM on-the-fly?
*/
private Integer maxRecordsInRam = null;
/**
* Connects this stub with an external stream capable of serving the
* requests of the consumer of this stub.
@ -166,6 +172,24 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
this.presorted = presorted;
}
/**
* Get the maximum number of reads to hold in RAM when sorting a BAM on-the-fly.
* @return Max records in RAM, or null if unset.
*/
public Integer getMaxRecordsInRam() {
return this.maxRecordsInRam;
}
/**
* Sets the maximum number of reads to hold in RAM when sorting a BAM on-the-fly.
* @param maxRecordsInRam Max number of records in RAM.
*/
public void setMaxRecordsInRam(int maxRecordsInRam) {
if(writeStarted)
throw new StingException("User attempted to change the max records in RAM of a file with alignments already in it.");
this.maxRecordsInRam = maxRecordsInRam;
}
/**
* Registers the given streamConnector with this stub.
* @param outputTracker The connector used to provide an appropriate stream.