Oops, forgot to push the unit tests
This commit is contained in:
parent
a057cf31b3
commit
a96c5da884
|
|
@ -47,9 +47,9 @@ public class ReadGroupCovariateUnitTest {
|
|||
|
||||
}
|
||||
|
||||
private void verifyCovariateArray(BitSet[] values, String expected) {
|
||||
for (BitSet value : values) {
|
||||
String actual = covariate.keyFromBitSet(value);
|
||||
private void verifyCovariateArray(Long[] values, String expected) {
|
||||
for (Long value : values) {
|
||||
String actual = covariate.formatKey(value);
|
||||
Assert.assertEquals(actual, expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class RecalibrationReportUnitTest {
|
|||
|
||||
final QuantizationInfo quantizationInfo = new QuantizationInfo(quals, counts);
|
||||
final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();
|
||||
final LinkedHashMap<BQSRKeyManager, Map<BitSet, RecalDatum>> keysAndTablesMap = new LinkedHashMap<BQSRKeyManager, Map<BitSet, RecalDatum>>();
|
||||
final LinkedHashMap<BQSRKeyManager, Map<Long, RecalDatum>> keysAndTablesMap = new LinkedHashMap<BQSRKeyManager, Map<Long, RecalDatum>>();
|
||||
|
||||
quantizationInfo.noQuantization();
|
||||
final List<Covariate> requiredCovariates = new LinkedList<Covariate>();
|
||||
|
|
@ -43,13 +43,13 @@ public class RecalibrationReportUnitTest {
|
|||
rgCovariate.initialize(RAC);
|
||||
requiredCovariates.add(rgCovariate);
|
||||
final BQSRKeyManager rgKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(rgKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(rgKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
final QualityScoreCovariate qsCovariate = new QualityScoreCovariate();
|
||||
qsCovariate.initialize(RAC);
|
||||
requiredCovariates.add(qsCovariate);
|
||||
final BQSRKeyManager qsKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(qsKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(qsKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
final ContextCovariate cxCovariate = new ContextCovariate();
|
||||
cxCovariate.initialize(RAC);
|
||||
|
|
@ -58,7 +58,7 @@ public class RecalibrationReportUnitTest {
|
|||
cyCovariate.initialize(RAC);
|
||||
optionalCovariates.add(cyCovariate);
|
||||
BQSRKeyManager cvKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(cvKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(cvKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
for (Covariate cov : requiredCovariates)
|
||||
requestedCovariates.add(cov);
|
||||
|
|
@ -79,22 +79,22 @@ public class RecalibrationReportUnitTest {
|
|||
int nKeys = 0; // keep track of how many keys were produced
|
||||
final ReadCovariates rc = RecalDataManager.computeCovariates(read, requestedCovariates);
|
||||
for (int offset = 0; offset < length; offset++) {
|
||||
for (Map.Entry<BQSRKeyManager, Map<BitSet, RecalDatum>> entry : keysAndTablesMap.entrySet()) {
|
||||
for (Map.Entry<BQSRKeyManager, Map<Long, RecalDatum>> entry : keysAndTablesMap.entrySet()) {
|
||||
BQSRKeyManager keyManager = entry.getKey();
|
||||
Map<BitSet, RecalDatum> table = entry.getValue();
|
||||
Map<Long, RecalDatum> table = entry.getValue();
|
||||
|
||||
for (BitSet key : keyManager.bitSetsFromAllKeys(rc.getMismatchesKeySet(offset), EventType.BASE_SUBSTITUTION)) {
|
||||
for (Long key : keyManager.longsFromAllKeys(rc.getMismatchesKeySet(offset), EventType.BASE_SUBSTITUTION)) {
|
||||
table.put(key, RecalDatum.createRandomRecalDatum(10000, 10));
|
||||
nKeys++;
|
||||
}
|
||||
|
||||
for (BitSet key : keyManager.bitSetsFromAllKeys(rc.getInsertionsKeySet(offset), EventType.BASE_INSERTION)) {
|
||||
for (Long key : keyManager.longsFromAllKeys(rc.getInsertionsKeySet(offset), EventType.BASE_INSERTION)) {
|
||||
table.put(key, RecalDatum.createRandomRecalDatum(100000, 10));
|
||||
nKeys++;
|
||||
}
|
||||
|
||||
|
||||
for (BitSet key : keyManager.bitSetsFromAllKeys(rc.getDeletionsKeySet(offset), EventType.BASE_DELETION)) {
|
||||
for (Long key : keyManager.longsFromAllKeys(rc.getDeletionsKeySet(offset), EventType.BASE_DELETION)) {
|
||||
table.put(key, RecalDatum.createRandomRecalDatum(100000, 10));
|
||||
nKeys++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.broadinstitute.sting.utils;
|
||||
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.BQSRKeyManager;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.ContextCovariate;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
@ -45,31 +47,31 @@ public class BitSetUtilsUnitTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
@Test(enabled = false)
|
||||
public void testDNAAndBitSetConversion() {
|
||||
String[] dna = {"AGGTGTTGT", "CCCCCCCCCCCCCC", "GGGGGGGGGGGGGG", "TTTTTTTTTTTTTT", "GTAGACCGATCTCAGCTAGT", "AACGTCAATGCAGTCAAGTCAGACGTGGGTT", "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"};
|
||||
|
||||
// Test all contexts of size 1-8.
|
||||
for (long n = 0; n < RANDOM_NUMBERS_TO_TRY; n++)
|
||||
Assert.assertEquals(BitSetUtils.longFrom(BitSetUtils.bitSetFrom(BitSetUtils.dnaFrom(BitSetUtils.bitSetFrom(n)))), n);
|
||||
//for (long n = 0; n < RANDOM_NUMBERS_TO_TRY; n++)
|
||||
// Assert.assertEquals(BitSetUtils.longFrom(BitSetUtils.bitSetFrom(ContextCovariate.contextFromKey(BitSetUtils.bitSetFrom(n)))), n);
|
||||
|
||||
// Test the special cases listed in the dna array
|
||||
for (String d : dna)
|
||||
Assert.assertEquals(BitSetUtils.dnaFrom(BitSetUtils.bitSetFrom(d)), d);
|
||||
//for (String d : dna)
|
||||
// Assert.assertEquals(BitSetUtils.dnaFrom(BitSetUtils.bitSetFrom(d)), d);
|
||||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testNumberOfBitsToRepresent() {
|
||||
Assert.assertEquals(BitSetUtils.numberOfBitsToRepresent(0), 0); // Make sure 0 elements need 0 bits to be represented
|
||||
Assert.assertEquals(BitSetUtils.numberOfBitsToRepresent(1), 1); // Make sure 1 element needs 1 bit to be represented
|
||||
Assert.assertEquals(BitSetUtils.numberOfBitsToRepresent(3), 2); // Make sure 3 elements need 2 bit to be represented
|
||||
Assert.assertEquals(BQSRKeyManager.numberOfBitsToRepresent(0), 0); // Make sure 0 elements need 0 bits to be represented
|
||||
Assert.assertEquals(BQSRKeyManager.numberOfBitsToRepresent(1), 1); // Make sure 1 element needs 1 bit to be represented
|
||||
Assert.assertEquals(BQSRKeyManager.numberOfBitsToRepresent(3), 2); // Make sure 3 elements need 2 bit to be represented
|
||||
|
||||
for (int i = 1; i < 63; i++) { // Can't test i == 63 because n1 is a negative number
|
||||
long n1 = 1L << i;
|
||||
long n2 = Math.abs(random.nextLong()) % n1;
|
||||
long n3 = n1 | n2;
|
||||
Assert.assertEquals(BitSetUtils.numberOfBitsToRepresent(n3), (n3 == n1) ? i : i + 1);
|
||||
Assert.assertEquals(BitSetUtils.numberOfBitsToRepresent(n1), i);
|
||||
Assert.assertEquals(BQSRKeyManager.numberOfBitsToRepresent(n3), (n3 == n1) ? i : i + 1);
|
||||
Assert.assertEquals(BQSRKeyManager.numberOfBitsToRepresent(n1), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.*;
|
|||
public class BaseRecalibrationUnitTest {
|
||||
|
||||
private org.broadinstitute.sting.gatk.walkers.recalibration.RecalDataManager dataManager;
|
||||
private LinkedHashMap<BQSRKeyManager, Map<BitSet, RecalDatum>> keysAndTablesMap;
|
||||
private LinkedHashMap<BQSRKeyManager, Map<Long, RecalDatum>> keysAndTablesMap;
|
||||
|
||||
private ReadGroupCovariate rgCovariate;
|
||||
private QualityScoreCovariate qsCovariate;
|
||||
|
|
@ -51,19 +51,19 @@ public class BaseRecalibrationUnitTest {
|
|||
ArrayList<Covariate> requestedCovariates = new ArrayList<Covariate>();
|
||||
|
||||
dataManager = new org.broadinstitute.sting.gatk.walkers.recalibration.RecalDataManager(true, 4);
|
||||
keysAndTablesMap = new LinkedHashMap<BQSRKeyManager, Map<BitSet, RecalDatum>>();
|
||||
keysAndTablesMap = new LinkedHashMap<BQSRKeyManager, Map<Long, RecalDatum>>();
|
||||
|
||||
rgCovariate = new ReadGroupCovariate();
|
||||
rgCovariate.initialize(RAC);
|
||||
requiredCovariates.add(rgCovariate);
|
||||
BQSRKeyManager rgKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(rgKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(rgKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
qsCovariate = new QualityScoreCovariate();
|
||||
qsCovariate.initialize(RAC);
|
||||
requiredCovariates.add(qsCovariate);
|
||||
BQSRKeyManager qsKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(qsKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(qsKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
cxCovariate = new ContextCovariate();
|
||||
cxCovariate.initialize(RAC);
|
||||
|
|
@ -72,7 +72,7 @@ public class BaseRecalibrationUnitTest {
|
|||
cyCovariate.initialize(RAC);
|
||||
optionalCovariates.add(cyCovariate);
|
||||
BQSRKeyManager cvKeyManager = new BQSRKeyManager(requiredCovariates, optionalCovariates);
|
||||
keysAndTablesMap.put(cvKeyManager, new HashMap<BitSet, RecalDatum>());
|
||||
keysAndTablesMap.put(cvKeyManager, new HashMap<Long, RecalDatum>());
|
||||
|
||||
|
||||
for (Covariate cov : requiredCovariates)
|
||||
|
|
@ -83,7 +83,7 @@ public class BaseRecalibrationUnitTest {
|
|||
readCovariates = RecalDataManager.computeCovariates(read, requestedCovariates);
|
||||
|
||||
for (int i=0; i<read.getReadLength(); i++) {
|
||||
BitSet[] bitKeys = readCovariates.getMismatchesKeySet(i);
|
||||
Long[] bitKeys = readCovariates.getMismatchesKeySet(i);
|
||||
|
||||
|
||||
Object[] objKey = buildObjectKey(bitKeys);
|
||||
|
|
@ -98,9 +98,9 @@ public class BaseRecalibrationUnitTest {
|
|||
dataManager.addToAllTables(objKey, oldDatum, QualityUtils.MIN_USABLE_Q_SCORE);
|
||||
|
||||
RecalDatum newDatum = new RecalDatum(nObservations, nErrors, estimatedQReported, empiricalQuality);
|
||||
for (Map.Entry<BQSRKeyManager, Map<BitSet, RecalDatum>> mapEntry : keysAndTablesMap.entrySet()) {
|
||||
List<BitSet> keys = mapEntry.getKey().bitSetsFromAllKeys(bitKeys, EventType.BASE_SUBSTITUTION);
|
||||
for (BitSet key : keys)
|
||||
for (Map.Entry<BQSRKeyManager, Map<Long, RecalDatum>> mapEntry : keysAndTablesMap.entrySet()) {
|
||||
List<Long> keys = mapEntry.getKey().longsFromAllKeys(bitKeys, EventType.BASE_SUBSTITUTION);
|
||||
for (Long key : keys)
|
||||
updateCovariateWithKeySet(mapEntry.getValue(), key, newDatum);
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ public class BaseRecalibrationUnitTest {
|
|||
public void testGoldStandardComparison() {
|
||||
debugTables();
|
||||
for (int i = 0; i < read.getReadLength(); i++) {
|
||||
BitSet [] bitKey = readCovariates.getKeySet(i, EventType.BASE_SUBSTITUTION);
|
||||
Long [] bitKey = readCovariates.getKeySet(i, EventType.BASE_SUBSTITUTION);
|
||||
Object [] objKey = buildObjectKey(bitKey);
|
||||
byte v2 = baseRecalibration.performSequentialQualityCalculation(bitKey, EventType.BASE_SUBSTITUTION);
|
||||
byte v1 = goldStandardSequentialCalculation(objKey);
|
||||
|
|
@ -131,12 +131,12 @@ public class BaseRecalibrationUnitTest {
|
|||
}
|
||||
}
|
||||
|
||||
private Object[] buildObjectKey(BitSet[] bitKey) {
|
||||
private Object[] buildObjectKey(Long[] bitKey) {
|
||||
Object[] key = new Object[bitKey.length];
|
||||
key[0] = rgCovariate.keyFromBitSet(bitKey[0]);
|
||||
key[1] = qsCovariate.keyFromBitSet(bitKey[1]);
|
||||
key[2] = cxCovariate.keyFromBitSet(bitKey[2]);
|
||||
key[3] = cyCovariate.keyFromBitSet(bitKey[3]);
|
||||
key[0] = rgCovariate.formatKey(bitKey[0]);
|
||||
key[1] = qsCovariate.formatKey(bitKey[1]);
|
||||
key[2] = cxCovariate.formatKey(bitKey[2]);
|
||||
key[3] = cyCovariate.formatKey(bitKey[3]);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
@ -157,9 +157,9 @@ public class BaseRecalibrationUnitTest {
|
|||
|
||||
int i = 0;
|
||||
System.out.println("\nV2 Table\n");
|
||||
for (Map.Entry<BQSRKeyManager, Map<BitSet, RecalDatum>> mapEntry : keysAndTablesMap.entrySet()) {
|
||||
for (Map.Entry<BQSRKeyManager, Map<Long, RecalDatum>> mapEntry : keysAndTablesMap.entrySet()) {
|
||||
BQSRKeyManager keyManager = mapEntry.getKey();
|
||||
Map<BitSet, RecalDatum> table = mapEntry.getValue();
|
||||
Map<Long, RecalDatum> table = mapEntry.getValue();
|
||||
switch(i++) {
|
||||
case 0 :
|
||||
System.out.println("ReadGroup Table:");
|
||||
|
|
@ -171,8 +171,8 @@ public class BaseRecalibrationUnitTest {
|
|||
System.out.println("Covariates Table:");
|
||||
break;
|
||||
}
|
||||
for (Map.Entry<BitSet, RecalDatum> entry : table.entrySet()) {
|
||||
BitSet key = entry.getKey();
|
||||
for (Map.Entry<Long, RecalDatum> entry : table.entrySet()) {
|
||||
Long key = entry.getKey();
|
||||
RecalDatum datum = entry.getValue();
|
||||
List<Object> keySet = keyManager.keySetFrom(key);
|
||||
System.out.println(String.format("%s => %s", Utils.join(",", keySet), datum) + "," + datum.getEstimatedQReported());
|
||||
|
|
@ -199,7 +199,7 @@ public class BaseRecalibrationUnitTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateCovariateWithKeySet(final Map<BitSet, RecalDatum> recalTable, final BitSet hashKey, final RecalDatum datum) {
|
||||
private void updateCovariateWithKeySet(final Map<Long, RecalDatum> recalTable, final Long hashKey, final RecalDatum datum) {
|
||||
RecalDatum previousDatum = recalTable.get(hashKey); // using the list of covariate values as a key, pick out the RecalDatum from the data HashMap
|
||||
if (previousDatum == null) // key doesn't exist yet in the map so make a new bucket and add it
|
||||
recalTable.put(hashKey, datum.copy());
|
||||
|
|
|
|||
Loading…
Reference in New Issue