Merge pull request #520 from broadinstitute/jt_fix_failing_tests_post_maven

Fix for the Array Out of Bounds test error
This commit is contained in:
droazen 2014-02-14 14:02:17 -05:00
commit 688792c5b0
8 changed files with 57 additions and 5 deletions

View File

@ -78,6 +78,14 @@ public class ReadCovariates {
}
};
/**
* The keys cache is only valid for a single covariate count. Normally this will remain constant for the analysis.
* If running multiple analyses (or the unit test suite), it's necessary to clear the cache.
*/
public static void clearKeysCache() {
keysCache.remove();
}
/**
* Our keys, indexed by event type x read length x covariate
*/
@ -108,6 +116,10 @@ public class ReadCovariates {
/**
* Update the keys for mismatch, insertion, and deletion for the current covariate at read offset
*
* NOTE: no checks are performed on the number of covariates, for performance reasons. If the count increases
* after the keysCache has been accessed, this method will throw an ArrayIndexOutOfBoundsException. This currently
* only occurs in the testing harness, and we don't anticipate that it will become a part of normal runs.
*
* @param mismatch the mismatch key value
* @param insertion the insertion key value
* @param deletion the deletion key value

View File

@ -53,6 +53,7 @@ import org.broadinstitute.sting.utils.recalibration.ReadCovariates;
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@ -62,6 +63,11 @@ import java.util.EnumMap;
import java.util.List;
public final class ReadRecalibrationInfoUnitTest extends BaseTest {
@BeforeMethod
public void init() {
ReadCovariates.clearKeysCache();
}
@DataProvider(name = "InfoProvider")
public Object[][] createCombineTablesProvider() {
List<Object[]> tests = new ArrayList<Object[]>();
@ -74,7 +80,6 @@ public final class ReadRecalibrationInfoUnitTest extends BaseTest {
return tests.toArray(new Object[][]{});
}
@Test(dataProvider = "InfoProvider")
public void testReadInfo(final int readLength, final boolean includeIndelErrors) {
final ReadCovariates covariates = new ReadCovariates(readLength, 2);

View File

@ -55,6 +55,7 @@ import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@ -70,7 +71,11 @@ public class ContextCovariateUnitTest {
RAC = new RecalibrationArgumentCollection();
covariate = new ContextCovariate();
covariate.initialize(RAC);
}
@BeforeMethod
public void initCache() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = true)

View File

@ -54,6 +54,7 @@ import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@ -71,6 +72,11 @@ public class CycleCovariateUnitTest {
covariate.initialize(RAC);
}
@BeforeMethod
public void initCache() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = true)
public void testSimpleCycles() {
short readLength = 10;

View File

@ -53,6 +53,7 @@ import org.broadinstitute.sting.utils.sam.GATKSAMReadGroupRecord;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Random;
@ -63,9 +64,14 @@ import java.util.Random;
*/
public class ReadCovariatesUnitTest {
@BeforeMethod
public void init() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = false)
public void testCovariateGeneration() {
final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();
final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();
final String RGID = "id";
ReadGroupCovariate rgCov = new ReadGroupCovariate();

View File

@ -53,6 +53,7 @@ import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@ -70,6 +71,11 @@ public class ReadGroupCovariateUnitTest {
covariate.initialize(RAC);
}
@BeforeMethod
public void initCache() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = true)
public void testSingleRecord() {
final String expected = "SAMPLE.1";

View File

@ -54,6 +54,7 @@ import org.broadinstitute.sting.utils.sam.GATKSAMReadGroupRecord;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broadinstitute.sting.utils.sam.ReadUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.*;
@ -63,6 +64,11 @@ import java.util.*;
* @since 4/21/12
*/
public class RecalibrationReportUnitTest {
@BeforeMethod
public void init() {
ReadCovariates.clearKeysCache();
}
private static RecalDatum createRandomRecalDatum(int maxObservations, int maxErrors) {
final Random random = new Random();
final int nObservations = random.nextInt(maxObservations);
@ -71,7 +77,7 @@ public class RecalibrationReportUnitTest {
return new RecalDatum((long)nObservations, (double)nErrors, (byte)qual);
}
@Test(enabled = false)
@Test
public void testOutput() {
final int length = 100;

View File

@ -56,6 +56,7 @@ import org.broadinstitute.sting.utils.BaseUtils;
import org.broadinstitute.sting.utils.collections.Pair;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
@ -82,8 +83,13 @@ public class RepeatCovariatesUnitTest {
rurlCovariate.initialize(RAC);
}
@BeforeMethod
public void initCache() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = true)
@Test
public void testFindNumberOfRepetitions() {
// First, test logic to compute number of repetitions of a substring on a given string.
int result = GATKVariantContextUtils.findNumberofRepetitions("AC".getBytes(), "ACAC".getBytes(), true);
@ -136,7 +142,7 @@ public class RepeatCovariatesUnitTest {
* Build synthetic reads with random content made up of tandem repeats, record computed Repeat Unit and # repeats and see if
* they match with read context
*/
@Test(enabled = false)
@Test
public void testManyObservations() {
final int NUM_UNITS = 10;
final int MAX_REPEAT_UNIT_LENGTH = RAC.MAX_STR_UNIT_LENGTH;