The Indel Realigner now lets the engine do all of the setup for args affecting the SAM writer. Thanks, Matt!
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4141 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
a3d9d23b0f
commit
427a2f85e9
|
|
@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.refdata.*;
|
||||||
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
||||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||||
import org.broadinstitute.sting.gatk.filters.BadMateFilter;
|
import org.broadinstitute.sting.gatk.filters.BadMateFilter;
|
||||||
|
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
|
||||||
import org.broadinstitute.sting.utils.*;
|
import org.broadinstitute.sting.utils.*;
|
||||||
import org.broadinstitute.sting.utils.interval.IntervalFileMergingIterator;
|
import org.broadinstitute.sting.utils.interval.IntervalFileMergingIterator;
|
||||||
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
||||||
|
|
@ -70,22 +71,15 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
protected double MISMATCH_THRESHOLD = 0.15;
|
protected double MISMATCH_THRESHOLD = 0.15;
|
||||||
|
|
||||||
@Output(required=false, doc="Output bam")
|
@Output(required=false, doc="Output bam")
|
||||||
protected String writerFilename = null;
|
protected StingSAMFileWriter writer = null;
|
||||||
|
|
||||||
@Argument(fullName="output",shortName="O",doc="Please use --out instead")
|
@Argument(fullName="output",shortName="O",doc="Please use --out instead")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected String oldOArg;
|
protected String oldOArg;
|
||||||
|
|
||||||
@Argument(fullName="bam_compression", shortName="compress", required=false, doc="Compression level to use for output bams [default:5]")
|
|
||||||
protected Integer compressionLevel = 5;
|
|
||||||
|
|
||||||
@Argument(fullName="useOnlyKnownIndels", shortName="knownsOnly", required=false, doc="Don't run 'Smith-Waterman' to generate alternate consenses; use only known indels provided as RODs for constructing the alternate references.")
|
@Argument(fullName="useOnlyKnownIndels", shortName="knownsOnly", required=false, doc="Don't run 'Smith-Waterman' to generate alternate consenses; use only known indels provided as RODs for constructing the alternate references.")
|
||||||
protected boolean USE_KNOWN_INDELS_ONLY = false;
|
protected boolean USE_KNOWN_INDELS_ONLY = false;
|
||||||
|
|
||||||
@Argument(fullName="maxReadsInRam", shortName="maxInRam", doc="max reads allowed to be kept in memory at a time by the SAMFileWriter. "+
|
|
||||||
"If too low, the tool may run out of system file descriptors needed to perform sorting; if too high, the tool may run out of memory.", required=false)
|
|
||||||
protected int MAX_RECORDS_IN_RAM = 500000;
|
|
||||||
|
|
||||||
// ADVANCED OPTIONS FOLLOW
|
// ADVANCED OPTIONS FOLLOW
|
||||||
|
|
||||||
@Argument(fullName="maxConsensuses", shortName="maxConsensuses", doc="max alternate consensuses to try (necessary to improve performance in deep coverage)", required=false)
|
@Argument(fullName="maxConsensuses", shortName="maxConsensuses", doc="max alternate consensuses to try (necessary to improve performance in deep coverage)", required=false)
|
||||||
|
|
@ -141,9 +135,6 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
private final ArrayList<SAMRecord> readsNotToClean = new ArrayList<SAMRecord>();
|
private final ArrayList<SAMRecord> readsNotToClean = new ArrayList<SAMRecord>();
|
||||||
private final IdentityHashMap<Object, VariantContext> knownIndelsToTry = new IdentityHashMap<Object, VariantContext>();
|
private final IdentityHashMap<Object, VariantContext> knownIndelsToTry = new IdentityHashMap<Object, VariantContext>();
|
||||||
|
|
||||||
// the wrapper around the SAM writer
|
|
||||||
private SAMFileWriter writer = null;
|
|
||||||
|
|
||||||
// random number generator
|
// random number generator
|
||||||
private static final long RANDOM_SEED = 1252863495;
|
private static final long RANDOM_SEED = 1252863495;
|
||||||
private static final Random generator = new Random(RANDOM_SEED);
|
private static final Random generator = new Random(RANDOM_SEED);
|
||||||
|
|
@ -187,14 +178,8 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
currentInterval = intervals.hasNext() ? intervals.next() : null;
|
currentInterval = intervals.hasNext() ? intervals.next() : null;
|
||||||
|
|
||||||
// set up the output writer(s)
|
// set up the output writer(s)
|
||||||
if ( writerFilename != null ) {
|
if ( writer != null )
|
||||||
SAMFileWriterFactory factory = new SAMFileWriterFactory();
|
setupWriter(getToolkit().getSAMFileHeader());
|
||||||
factory.setMaxRecordsInRam(MAX_RECORDS_IN_RAM);
|
|
||||||
|
|
||||||
SAMFileHeader header = getToolkit().getSAMFileHeader();
|
|
||||||
File file = new File(writerFilename);
|
|
||||||
writer = makeWriter(factory, header, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( OUT_INDELS != null ) {
|
if ( OUT_INDELS != null ) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -225,7 +210,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SAMFileWriter makeWriter(SAMFileWriterFactory factory, SAMFileHeader header, File file) {
|
private void setupWriter(SAMFileHeader header) {
|
||||||
if ( SORT_IN_COORDINATE_ORDER )
|
if ( SORT_IN_COORDINATE_ORDER )
|
||||||
header.setSortOrder(SAMFileHeader.SortOrder.coordinate);
|
header.setSortOrder(SAMFileHeader.SortOrder.coordinate);
|
||||||
else
|
else
|
||||||
|
|
@ -249,9 +234,8 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
header.setProgramRecords(newRecords);
|
header.setProgramRecords(newRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
SAMFileWriter writer = factory.makeBAMWriter(header, false, file, compressionLevel);
|
writer.writeHeader(header);
|
||||||
|
writer.setPresorted(false);
|
||||||
return writer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emit(final SAMRecord read) {
|
private void emit(final SAMRecord read) {
|
||||||
|
|
@ -371,9 +355,6 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
emit(readsNotToClean);
|
emit(readsNotToClean);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( writer != null )
|
|
||||||
writer.close();
|
|
||||||
|
|
||||||
if ( OUT_INDELS != null ) {
|
if ( OUT_INDELS != null ) {
|
||||||
try {
|
try {
|
||||||
indelOutput.close();
|
indelOutput.close();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue