Clear the ReadCovariates keysCache before runs of individual Unit Tests

- normal runs have a constant covariate count, so this is not necessary
This commit is contained in:
Joel Thibault 2014-02-13 16:23:47 -05:00
parent 07a1d55209
commit ec16439387
8 changed files with 50 additions and 2 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
*/

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);

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,6 +83,11 @@ public class RepeatCovariatesUnitTest {
rurlCovariate.initialize(RAC);
}
@BeforeMethod
public void initCache() {
ReadCovariates.clearKeysCache();
}
@Test(enabled = true)
public void testFindNumberOfRepetitions() {