Merge pull request #342 from broadinstitute/eb_fix_mq_in_rbp
Fixing ReadBackedPileup to represent mapping qualities as ints, not (signed) bytes.
This commit is contained in:
commit
e5aab22680
|
|
@ -156,7 +156,7 @@ public final class QualifyMissingIntervals extends LocusWalker<Metrics, Metrics>
|
||||||
baseQual += qual;
|
baseQual += qual;
|
||||||
}
|
}
|
||||||
double mapQual = 0.0;
|
double mapQual = 0.0;
|
||||||
for (byte qual : pileup.getMappingQuals()) {
|
for (int qual : pileup.getMappingQuals()) {
|
||||||
mapQual += qual;
|
mapQual += qual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ public interface ReadBackedPileup extends Iterable<PileupElement>, HasGenomeLoca
|
||||||
* Get an array of the mapping qualities
|
* Get an array of the mapping qualities
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public byte[] getMappingQuals();
|
public int[] getMappingQuals();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new ReadBackedPileup that is sorted by start coordinate of the reads.
|
* Returns a new ReadBackedPileup that is sorted by start coordinate of the reads.
|
||||||
|
|
|
||||||
|
|
@ -969,11 +969,11 @@ public class ReadBackedPileupImpl implements ReadBackedPileup {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] getMappingQuals() {
|
public int[] getMappingQuals() {
|
||||||
byte[] v = new byte[getNumberOfElements()];
|
final int[] v = new int[getNumberOfElements()];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (PileupElement pile : pileupElementTracker) {
|
for ( final PileupElement pile : pileupElementTracker ) {
|
||||||
v[pos++] = (byte) pile.getRead().getMappingQuality();
|
v[pos++] = pile.getRead().getMappingQuality();
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,6 @@ public class ReadBackedPileupUnitTest {
|
||||||
testRBPCounts(pileup, new RBPCountTest(params.nReads + 2, params.nMapq0 + 1, params.nDeletions + 1));
|
testRBPCounts(pileup, new RBPCountTest(params.nReads + 2, params.nMapq0 + 1, params.nDeletions + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void testRBPCounts(final ReadBackedPileup rbp, RBPCountTest expected) {
|
private void testRBPCounts(final ReadBackedPileup rbp, RBPCountTest expected) {
|
||||||
for ( int cycles = 0; cycles < 3; cycles++ ) {
|
for ( int cycles = 0; cycles < 3; cycles++ ) {
|
||||||
// multiple cycles to make sure caching is working
|
// multiple cycles to make sure caching is working
|
||||||
|
|
@ -306,4 +305,24 @@ public class ReadBackedPileupUnitTest {
|
||||||
Assert.assertEquals(rbp.getNumberOfMappingQualityZeroReads(), expected.nMapq0);
|
Assert.assertEquals(rbp.getNumberOfMappingQualityZeroReads(), expected.nMapq0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRBPMappingQuals() {
|
||||||
|
|
||||||
|
// create a read with high MQ
|
||||||
|
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read", 0, 1, 10);
|
||||||
|
read.setReadBases(Utils.dupBytes((byte) 'A', 10));
|
||||||
|
read.setBaseQualities(Utils.dupBytes((byte) 30, 10));
|
||||||
|
read.setCigarString("10M");
|
||||||
|
read.setMappingQuality(200); // set a MQ higher than max signed byte
|
||||||
|
|
||||||
|
// now create the RBP
|
||||||
|
final List<PileupElement> elts = new LinkedList<>();
|
||||||
|
elts.add(new PileupElement(read, 0, read.getCigar().getCigarElement(0), 0, 0));
|
||||||
|
final Map<String, ReadBackedPileupImpl> pileupsBySample = new HashMap<>();
|
||||||
|
pileupsBySample.put("foo", new ReadBackedPileupImpl(loc, elts));
|
||||||
|
final ReadBackedPileup pileup = new ReadBackedPileupImpl(loc, pileupsBySample);
|
||||||
|
|
||||||
|
Assert.assertEquals(pileup.getMappingQuals()[0], 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue