Resolve protected->public dependencies for BQSR by wrapping the BQSR-specific arguments in a new class.

Instead of the GATK Engine creating a new BaseRecalibrator (not clean), it just keeps track of the arguments (clean).

There are still some dependency issues, but it looks like they are related to Ami's code.  Need to look into it further.
This commit is contained in:
Eric Banks 2013-01-08 16:23:29 -05:00
parent ee7d85c6e6
commit 264cc9e78d
4 changed files with 93 additions and 13 deletions

View File

@ -14,12 +14,15 @@ import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
*/
public class BQSRReadTransformer extends ReadTransformer {
private boolean enabled;
private BaseRecalibration bqsr;
private BaseRecalibration bqsr = null;
@Override
public ApplicationTime initializeSub(final GenomeAnalysisEngine engine, final Walker walker) {
this.enabled = engine.hasBaseRecalibration();
this.bqsr = engine.getBaseRecalibration();
this.enabled = engine.hasBQSRArgumentSet();
if ( enabled ) {
final BQSRArgumentSet args = engine.getBQSRArgumentSet();
this.bqsr = new BaseRecalibration(args.getRecalFile(), args.getQuantizationLevels(), args.shouldDisableIndelQuals(), args.getPreserveQscoresLessThan(), args.shouldEmitOriginalQuals());
}
final BQSRMode mode = WalkerManager.getWalkerAnnotation(walker, BQSRMode.class);
return mode.ApplicationTime();
}

View File

@ -58,7 +58,7 @@ import org.broadinstitute.sting.utils.collections.Pair;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.interval.IntervalUtils;
import org.broadinstitute.sting.utils.recalibration.BaseRecalibration;
import org.broadinstitute.sting.utils.recalibration.BQSRArgumentSet;
import org.broadinstitute.sting.utils.threading.ThreadEfficiencyMonitor;
import java.io.File;
@ -209,11 +209,11 @@ public class GenomeAnalysisEngine {
/**
* Base Quality Score Recalibration helper object
*/
private BaseRecalibration baseRecalibration = null;
public BaseRecalibration getBaseRecalibration() { return baseRecalibration; }
public boolean hasBaseRecalibration() { return baseRecalibration != null; }
public void setBaseRecalibration(final File recalFile, final int quantizationLevels, final boolean disableIndelQuals, final int preserveQLessThan, final boolean emitOriginalQuals) {
baseRecalibration = new BaseRecalibration(recalFile, quantizationLevels, disableIndelQuals, preserveQLessThan, emitOriginalQuals);
private BQSRArgumentSet bqsrArgumentSet = null;
public BQSRArgumentSet getBQSRArgumentSet() { return bqsrArgumentSet; }
public boolean hasBQSRArgumentSet() { return bqsrArgumentSet != null; }
public void setBaseRecalibration(final GATKArgumentCollection args) {
bqsrArgumentSet = new BQSRArgumentSet(args);
}
/**
@ -242,7 +242,7 @@ public class GenomeAnalysisEngine {
// if the use specified an input BQSR recalibration table then enable on the fly recalibration
if (args.BQSR_RECAL_FILE != null)
setBaseRecalibration(args.BQSR_RECAL_FILE, args.quantizationLevels, args.disableIndelQuals, args.PRESERVE_QSCORES_LESS_THAN, args.emitOriginalQuals);
setBaseRecalibration(args);
// Determine how the threads should be divided between CPU vs. IO.
determineThreadAllocation();

View File

@ -284,15 +284,15 @@ public class GATKArgumentCollection {
@Argument(fullName = "preserve_qscores_less_than", shortName = "preserveQ", doc = "Bases with quality scores less than this threshold won't be recalibrated (with -BQSR)", required = false)
public int PRESERVE_QSCORES_LESS_THAN = QualityUtils.MIN_USABLE_Q_SCORE;
@Argument(fullName="defaultBaseQualities", shortName = "DBQ", doc = "If reads are missing some or all base quality scores, this value will be used for all base quality scores", required=false)
public byte defaultBaseQualities = -1;
// --------------------------------------------------------------------------------------------------------------
//
// Other utility arguments
//
// --------------------------------------------------------------------------------------------------------------
@Argument(fullName="defaultBaseQualities", shortName = "DBQ", doc = "If reads are missing some or all base quality scores, this value will be used for all base quality scores", required=false)
public byte defaultBaseQualities = -1;
@Argument(fullName = "validation_strictness", shortName = "S", doc = "How strict should we be with validation", required = false)
public SAMFileReader.ValidationStringency strictnessLevel = SAMFileReader.ValidationStringency.SILENT;

View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2010 The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.utils.recalibration;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
import java.io.File;
public class BQSRArgumentSet {
// declare public, STL-style for easier and more efficient access:
private File BQSR_RECAL_FILE;
private int quantizationLevels;
private boolean disableIndelQuals;
private boolean emitOriginalQuals;
private int PRESERVE_QSCORES_LESS_THAN;
public BQSRArgumentSet(final GATKArgumentCollection args) {
this.BQSR_RECAL_FILE = args.BQSR_RECAL_FILE;
this.quantizationLevels = args.quantizationLevels;
this.disableIndelQuals = args.disableIndelQuals;
this.emitOriginalQuals = args.emitOriginalQuals;
this.PRESERVE_QSCORES_LESS_THAN = args.PRESERVE_QSCORES_LESS_THAN;
}
public File getRecalFile() { return BQSR_RECAL_FILE; }
public int getQuantizationLevels() { return quantizationLevels; }
public boolean shouldDisableIndelQuals() { return disableIndelQuals; }
public boolean shouldEmitOriginalQuals() { return emitOriginalQuals; }
public int getPreserveQscoresLessThan() { return PRESERVE_QSCORES_LESS_THAN; }
public void setRecalFile(final File BQSR_RECAL_FILE) {
this.BQSR_RECAL_FILE = BQSR_RECAL_FILE;
}
public void setQuantizationLevels(final int quantizationLevels) {
this.quantizationLevels = quantizationLevels;
}
public void setDisableIndelQuals(final boolean disableIndelQuals) {
this.disableIndelQuals = disableIndelQuals;
}
public void setEmitOriginalQuals(final boolean emitOriginalQuals) {
this.emitOriginalQuals = emitOriginalQuals;
}
public void setPreserveQscoresLessThan(final int PRESERVE_QSCORES_LESS_THAN) {
this.PRESERVE_QSCORES_LESS_THAN = PRESERVE_QSCORES_LESS_THAN;
}
}