From baf2c4c338d49ce5321054dffa0318de25ccc47b Mon Sep 17 00:00:00 2001 From: Guillermo del Angel Date: Fri, 1 Feb 2013 11:13:10 -0500 Subject: [PATCH] Add option to specify maximum STR length to RepeatCovariates from command line to ease testing --- .../bqsr/RecalibrationArgumentCollection.java | 12 ++++++++++++ .../recalibration/covariates/RepeatCovariate.java | 6 ++++-- .../recalibration/RepeatCovariatesUnitTest.java | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/RecalibrationArgumentCollection.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/RecalibrationArgumentCollection.java index 4c98a70a0..95b54102f 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/RecalibrationArgumentCollection.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/bqsr/RecalibrationArgumentCollection.java @@ -223,6 +223,18 @@ public class RecalibrationArgumentCollection { @Output(fullName = "recal_table_update_log", shortName = "recal_table_update_log", required = false, doc = "If provided, log all updates to the recalibration tables to the given file. For debugging/testing purposes only") public PrintStream RECAL_TABLE_UPDATE_LOG = null; + /** + * The repeat covariate will use a context of this size to calculate it's covariate value for base insertions and deletions + */ + @Hidden + @Argument(fullName = "max_str_unit_length", shortName = "maxstr", doc = "Max size of the k-mer context to be used for repeat covariates", required = false) + public int MAX_STR_UNIT_LENGTH = 8; + + @Hidden + @Argument(fullName = "max_repeat_length", shortName = "maxrep", doc = "Max number of repetitions to be used for repeat covariates", required = false) + public int MAX_REPEAT_LENGTH = 20; + + public File existingRecalibrationReport = null; public GATKReportTable generateReportTable(final String covariateNames) { diff --git a/protected/java/src/org/broadinstitute/sting/utils/recalibration/covariates/RepeatCovariate.java b/protected/java/src/org/broadinstitute/sting/utils/recalibration/covariates/RepeatCovariate.java index 0eeb18251..9672bc5f3 100644 --- a/protected/java/src/org/broadinstitute/sting/utils/recalibration/covariates/RepeatCovariate.java +++ b/protected/java/src/org/broadinstitute/sting/utils/recalibration/covariates/RepeatCovariate.java @@ -61,8 +61,8 @@ import java.util.Map; import java.util.Set; public abstract class RepeatCovariate implements ExperimentalCovariate { - public static final int MAX_REPEAT_LENGTH = 20; - public static final int MAX_STR_UNIT_LENGTH = 8; + protected int MAX_REPEAT_LENGTH; + protected int MAX_STR_UNIT_LENGTH; private final HashMap repeatLookupTable = new HashMap(); private final HashMap repeatReverseLookupTable = new HashMap(); private int nextId = 0; @@ -70,6 +70,8 @@ public abstract class RepeatCovariate implements ExperimentalCovariate { // Initialize any member variables using the command-line arguments passed to the walkers @Override public void initialize(final RecalibrationArgumentCollection RAC) { + MAX_STR_UNIT_LENGTH = RAC.MAX_STR_UNIT_LENGTH; + MAX_REPEAT_LENGTH = RAC.MAX_REPEAT_LENGTH; } @Override diff --git a/protected/java/test/org/broadinstitute/sting/utils/recalibration/RepeatCovariatesUnitTest.java b/protected/java/test/org/broadinstitute/sting/utils/recalibration/RepeatCovariatesUnitTest.java index 6d13fe96c..ea70deeea 100644 --- a/protected/java/test/org/broadinstitute/sting/utils/recalibration/RepeatCovariatesUnitTest.java +++ b/protected/java/test/org/broadinstitute/sting/utils/recalibration/RepeatCovariatesUnitTest.java @@ -139,8 +139,8 @@ public class RepeatCovariatesUnitTest { @Test(enabled = true) public void testManyObservations() { final int NUM_UNITS = 10; - final int MAX_REPEAT_UNIT_LENGTH = RepeatCovariate.MAX_STR_UNIT_LENGTH; - final int MAX_NUM_REPETITIONS = RepeatCovariate.MAX_REPEAT_LENGTH; + final int MAX_REPEAT_UNIT_LENGTH = RAC.MAX_STR_UNIT_LENGTH; + final int MAX_NUM_REPETITIONS = RAC.MAX_REPEAT_LENGTH; final int NUM_TEST_CASES = 100; Random random = new Random(); @@ -207,7 +207,7 @@ public class RepeatCovariatesUnitTest { int fw = GATKVariantContextUtils.findNumberofRepetitions(ruValM.getBytes(), readBases.substring(offset+1,readLength).getBytes(),true); int bw = GATKVariantContextUtils.findNumberofRepetitions(ruValM.getBytes(), readBases.substring(0,offset+1).getBytes(),false); - Assert.assertEquals(Math.min(fw+bw,RepeatCovariate.MAX_REPEAT_LENGTH),(int)Integer.valueOf(rlValM)); + Assert.assertEquals(Math.min(fw+bw,RAC.MAX_REPEAT_LENGTH),(int)Integer.valueOf(rlValM)); } }