Updating the recalibrator to make use of StingSAMFileWriter.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2566 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
rpoplin 2010-01-12 20:58:27 +00:00
parent c8ad025ad0
commit b51f4aae11
1 changed files with 9 additions and 18 deletions

View File

@ -7,6 +7,7 @@ import org.broadinstitute.sting.gatk.walkers.WalkerName;
import org.broadinstitute.sting.gatk.walkers.Requires;
import org.broadinstitute.sting.gatk.walkers.DataSource;
import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource;
import org.broadinstitute.sting.gatk.io.StingSAMFileWriter;
import org.broadinstitute.sting.utils.cmdLine.*;
import org.broadinstitute.sting.utils.*;
@ -70,8 +71,8 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
/////////////////////////////
// Command Line Arguments
/////////////////////////////
@Argument(fullName="output_bam", shortName="outputBam", doc="output BAM file", required=true)
private String OUTPUT_BAM_FILE = null;
@Argument(fullName="output_bam", shortName="outputBam", doc="The output BAM file", required=true)
private StingSAMFileWriter OUTPUT_BAM;
@Argument(fullName="preserve_qscores_less_than", shortName="pQ",
doc="Bases with quality scores less than this threshold won't be recalibrated, default=5. In general it's unsafe to change qualities scores below < 5, since base callers use these values to indicate random or bad bases", required=false)
private int PRESERVE_QSCORES_LESS_THAN = 5;
@ -79,9 +80,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
private int SMOOTHING = 1;
@Argument(fullName="max_quality_score", shortName="maxQ", required = false, doc="The integer value at which to cap the quality scores, default is 40")
private int MAX_QUALITY_SCORE = 40;
@Argument(fullName="compression_level", shortName="compress", required = false, doc="Compression level parameter passed to SAMFileWriter, higher value means more compression at added cost in run time, default is 5")
private int COMPRESSION_LEVEL = 5;
/////////////////////////////
// Debugging-only Arguments
/////////////////////////////
@ -96,8 +95,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
private static final Pattern COMMENT_PATTERN = Pattern.compile("^#.*");
private static final Pattern OLD_RECALIBRATOR_HEADER = Pattern.compile("^rg,.*");
private static final Pattern COVARIATE_PATTERN = Pattern.compile("^ReadGroup,QualityScore,.*");
private static final String versionString = "v2.2.8"; // Major version, minor version, and build number
private SAMFileWriter OUTPUT_BAM = null;// The File Writer that will write out the recalibrated bam
private static final String versionString = "v2.2.9"; // Major version, minor version, and build number
private Random coinFlip; // Random number generator is used to remove reference bias in solid bams
private static final long RANDOM_SEED = 1032861495;
@ -247,14 +245,10 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
commandLineString += "smoothing = " + SMOOTHING;
programRecord.setCommandLine( commandLineString );
header.addProgramRecord( programRecord );
}
// Create the SAMFileWriter that we will be using to output the reads
if( OUTPUT_BAM_FILE != null ) {
final SAMFileWriterFactory factory = new SAMFileWriterFactory();
OUTPUT_BAM = factory.makeBAMWriter( header, true, new File(OUTPUT_BAM_FILE), COMPRESSION_LEVEL );
// write out the new header
OUTPUT_BAM.writeHeader( header );
}
}
/**
@ -353,7 +347,7 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
* @param key The list of Comparables that were calculated from the covariates
* @return A recalibrated quality score as a byte
*/
private byte performSequentialQualityCalculation(final Object... key ) {
private byte performSequentialQualityCalculation( final Object... key ) {
final byte qualFromRead = (byte)Integer.parseInt(key[1].toString());
final Object[] readGroupCollapsedKey = new Object[1];
@ -454,12 +448,9 @@ public class TableRecalibrationWalker extends ReadWalker<SAMRecord, SAMFileWrite
}
/**
* Close the output bam file
* Do nothing
* @param output The SAMFileWriter that outputs the bam file
*/
public void onTraversalDone(SAMFileWriter output) {
if( output != null ) {
output.close();
}
}
}