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:
parent
467405094a
commit
6f4af47aac
|
|
@ -22,4 +22,10 @@ public interface StingSAMFileWriter extends SAMFileWriter {
|
||||||
* @param presorted True if the BAM file is presorted. False otherwise.
|
* @param presorted True if the BAM file is presorted. False otherwise.
|
||||||
*/
|
*/
|
||||||
public void setPresorted(boolean presorted);
|
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);
|
||||||
}
|
}
|
||||||
|
|
@ -49,14 +49,18 @@ public class SAMFileWriterStorage implements SAMFileWriter, Storage<SAMFileWrite
|
||||||
|
|
||||||
public SAMFileWriterStorage( SAMFileWriterStub stub, File file ) {
|
public SAMFileWriterStorage( SAMFileWriterStub stub, File file ) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
SAMFileWriterFactory factory = new SAMFileWriterFactory();
|
||||||
|
if(stub.getMaxRecordsInRam() != null)
|
||||||
|
factory.setMaxRecordsInRam(stub.getMaxRecordsInRam());
|
||||||
|
|
||||||
if(stub.getSAMFile() != null) {
|
if(stub.getSAMFile() != null) {
|
||||||
if( stub.getCompressionLevel() != 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
|
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){
|
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
|
else
|
||||||
throw new StingException("Unable to write to SAM file; neither a target file nor a stream has been specified");
|
throw new StingException("Unable to write to SAM file; neither a target file nor a stream has been specified");
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
|
||||||
*/
|
*/
|
||||||
private boolean presorted = true;
|
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
|
* Connects this stub with an external stream capable of serving the
|
||||||
* requests of the consumer of this stub.
|
* requests of the consumer of this stub.
|
||||||
|
|
@ -166,6 +172,24 @@ public class SAMFileWriterStub implements Stub<SAMFileWriter>, StingSAMFileWrite
|
||||||
this.presorted = presorted;
|
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.
|
* Registers the given streamConnector with this stub.
|
||||||
* @param outputTracker The connector used to provide an appropriate stream.
|
* @param outputTracker The connector used to provide an appropriate stream.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue