Context covariate optimizations were not suited for multiple threads, so I removed them (since that ended up being much, much easier than trying to make the covariates thread local). Added -nt 2 layer to BQSR integration tests to confirm that it now works with multiple threads.

This commit is contained in:
Eric Banks 2012-07-25 13:38:07 -04:00
parent e0c07f5567
commit a5721a8846
4 changed files with 32 additions and 27 deletions

View File

@ -28,6 +28,17 @@ public class BQSRIntegrationTest extends WalkerTest {
this.md5 = md5; this.md5 = md5;
} }
public String getCommandLine() {
return " -T BaseRecalibrator" +
" -R " + reference +
" -I " + bam +
" -L " + interval +
args +
" --no_plots" +
" -knownSites " + (reference.equals(b36KGReference) ? b36dbSNP129 : hg18dbSNP132) +
" -o %s";
}
@Override @Override
public String toString() { public String toString() {
return String.format("BQSR(bam='%s', args='%s')", bam, args); return String.format("BQSR(bam='%s', args='%s')", bam, args);
@ -59,16 +70,14 @@ public class BQSRIntegrationTest extends WalkerTest {
@Test(dataProvider = "BQSRTest") @Test(dataProvider = "BQSRTest")
public void testBQSR(BQSRTest params) { public void testBQSR(BQSRTest params) {
WalkerTestSpec spec = new WalkerTestSpec( WalkerTestSpec spec = new WalkerTestSpec(
" -T BaseRecalibrator" + params.getCommandLine(),
" -R " + params.reference +
" -I " + params.bam +
" -L " + params.interval +
params.args +
" --no_plots" +
" -knownSites " + (params.reference.equals(b36KGReference) ? b36dbSNP129 : hg18dbSNP132) +
" -o %s",
Arrays.asList(params.md5)); Arrays.asList(params.md5));
executeTest("testBQSR-"+params.args, spec).getFirst(); executeTest("testBQSR-"+params.args, spec).getFirst();
WalkerTestSpec specNT2 = new WalkerTestSpec(
params.getCommandLine() + " -nt 2",
Arrays.asList(params.md5));
executeTest("testBQSR-nt2-"+params.args, specNT2).getFirst();
} }
@Test @Test

View File

@ -11,7 +11,6 @@ import org.broadinstitute.sting.gatk.io.ThreadLocalOutputTracker;
import org.broadinstitute.sting.gatk.walkers.TreeReducible; import org.broadinstitute.sting.gatk.walkers.TreeReducible;
import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.StingException;
import org.broadinstitute.sting.utils.threading.ThreadPoolMonitor; import org.broadinstitute.sting.utils.threading.ThreadPoolMonitor;
import java.util.Collection; import java.util.Collection;

View File

@ -111,16 +111,16 @@ public class BaseRecalibrator extends LocusWalker<Long, Long> implements TreeRed
private QuantizationInfo quantizationInfo; // an object that keeps track of the information necessary for quality score quantization private QuantizationInfo quantizationInfo; // an object that keeps track of the information necessary for quality score quantization
private RecalibrationTables recalibrationTables; private RecalibrationTables recalibrationTables;
private Covariate[] requestedCovariates; // list to hold the all the covariate objects that were requested (required + standard + experimental) private Covariate[] requestedCovariates; // list to hold the all the covariate objects that were requested (required + standard + experimental)
private RecalibrationEngine recalibrationEngine; private RecalibrationEngine recalibrationEngine;
private int minimumQToUse; private int minimumQToUse;
protected static final String SKIP_RECORD_ATTRIBUTE = "SKIP"; // used to label reads that should be skipped. protected static final String SKIP_RECORD_ATTRIBUTE = "SKIP"; // used to label reads that should be skipped.
protected static final String SEEN_ATTRIBUTE = "SEEN"; // used to label reads as processed. protected static final String SEEN_ATTRIBUTE = "SEEN"; // used to label reads as processed.
protected static final String COVARS_ATTRIBUTE = "COVARS"; // used to store covariates array as a temporary attribute inside GATKSAMRecord.\ protected static final String COVARS_ATTRIBUTE = "COVARS"; // used to store covariates array as a temporary attribute inside GATKSAMRecord.\
private static final String NO_DBSNP_EXCEPTION = "This calculation is critically dependent on being able to skip over known variant sites. Please provide a VCF file containing known sites of genetic variation."; private static final String NO_DBSNP_EXCEPTION = "This calculation is critically dependent on being able to skip over known variant sites. Please provide a VCF file containing known sites of genetic variation.";

View File

@ -51,10 +51,6 @@ public class ContextCovariate implements StandardCovariate {
private static final int LENGTH_BITS = 4; private static final int LENGTH_BITS = 4;
private static final int LENGTH_MASK = 15; private static final int LENGTH_MASK = 15;
// temporary lists to use for creating context covariate keys
private final ArrayList<Integer> mismatchKeys = new ArrayList<Integer>(200);
private final ArrayList<Integer> indelKeys = new ArrayList<Integer>(200);
// the maximum context size (number of bases) permitted; we need to keep the leftmost base free so that values are // the maximum context size (number of bases) permitted; we need to keep the leftmost base free so that values are
// not negative and we reserve 4 more bits to represent the length of the context; it takes 2 bits to encode one base. // not negative and we reserve 4 more bits to represent the length of the context; it takes 2 bits to encode one base.
static final private int MAX_DNA_CONTEXT = 13; static final private int MAX_DNA_CONTEXT = 13;
@ -91,10 +87,8 @@ public class ContextCovariate implements StandardCovariate {
if (negativeStrand) if (negativeStrand)
bases = BaseUtils.simpleReverseComplement(bases); bases = BaseUtils.simpleReverseComplement(bases);
mismatchKeys.clear(); final ArrayList<Integer> mismatchKeys = contextWith(bases, mismatchesContextSize, mismatchesKeyMask);
indelKeys.clear(); final ArrayList<Integer> indelKeys = contextWith(bases, indelsContextSize, indelsKeyMask);
contextWith(bases, mismatchesContextSize, mismatchKeys, mismatchesKeyMask);
contextWith(bases, indelsContextSize, indelKeys, indelsKeyMask);
final int readLength = bases.length; final int readLength = bases.length;
for (int i = 0; i < readLength; i++) { for (int i = 0; i < readLength; i++) {
@ -139,17 +133,19 @@ public class ContextCovariate implements StandardCovariate {
* *
* @param bases the bases in the read to build the context from * @param bases the bases in the read to build the context from
* @param contextSize context size to use building the context * @param contextSize context size to use building the context
* @param keys list to store the keys
* @param mask mask for pulling out just the context bits * @param mask mask for pulling out just the context bits
*/ */
private static void contextWith(final byte[] bases, final int contextSize, final ArrayList<Integer> keys, final int mask) { private static ArrayList<Integer> contextWith(final byte[] bases, final int contextSize, final int mask) {
final int readLength = bases.length;
final ArrayList<Integer> keys = new ArrayList<Integer>(readLength);
// the first contextSize-1 bases will not have enough previous context // the first contextSize-1 bases will not have enough previous context
for (int i = 1; i < contextSize && i <= bases.length; i++) for (int i = 1; i < contextSize && i <= readLength; i++)
keys.add(-1); keys.add(-1);
if (bases.length < contextSize) if (readLength < contextSize)
return; return keys;
final int newBaseOffset = 2 * (contextSize - 1) + LENGTH_BITS; final int newBaseOffset = 2 * (contextSize - 1) + LENGTH_BITS;
@ -171,7 +167,6 @@ public class ContextCovariate implements StandardCovariate {
} }
} }
final int readLength = bases.length;
for (int currentIndex = contextSize; currentIndex < readLength; currentIndex++) { for (int currentIndex = contextSize; currentIndex < readLength; currentIndex++) {
final int baseIndex = BaseUtils.simpleBaseToBaseIndex(bases[currentIndex]); final int baseIndex = BaseUtils.simpleBaseToBaseIndex(bases[currentIndex]);
if (baseIndex == -1) { // ignore non-ACGT bases if (baseIndex == -1) { // ignore non-ACGT bases
@ -191,6 +186,8 @@ public class ContextCovariate implements StandardCovariate {
keys.add(-1); keys.add(-1);
} }
} }
return keys;
} }
public static int keyFromContext(final String dna) { public static int keyFromContext(final String dna) {