Merge pull request #436 from broadinstitute/eb_fix_mq_byte_issue_in_RR

Bug fix for RR: stop (incorrectly) pulling the MQ out of the SAMRecord as a byte instead of an int.
This commit is contained in:
Eric Banks 2013-11-27 19:25:36 -08:00
commit 6d43952ccc
2 changed files with 28 additions and 4 deletions

View File

@ -1033,7 +1033,7 @@ public class SlidingWindow {
protected void actuallyUpdateHeaderForRead(final LinkedList<HeaderElement> header, final GATKSAMRecord read, final boolean removeRead, final int startIndex) {
final Iterator<HeaderElement> headerElementIterator = header.listIterator(startIndex);
final byte mappingQuality = (byte) read.getMappingQuality();
final int mappingQuality = read.getMappingQuality();
final boolean isNegativeStrand = read.getReadNegativeStrandFlag();
// iterator variables
@ -1062,14 +1062,15 @@ public class SlidingWindow {
break;
case D:
// deletions are added to the baseCounts with the read mapping quality as it's quality score
// deletions are added to the baseCounts with the read mapping quality as its quality score
final int nDeletionBases = cigarElement.getLength();
final byte MQbyte = mappingQuality > Byte.MAX_VALUE ? Byte.MAX_VALUE : (byte)mappingQuality;
for ( int i = 0; i < nDeletionBases; i++ ) {
headerElement = headerElementIterator.next();
if (removeRead)
headerElement.removeBase(BaseUtils.Base.D.base, mappingQuality, mappingQuality, mappingQuality, mappingQuality, MIN_BASE_QUAL_TO_COUNT, MIN_MAPPING_QUALITY, false, isNegativeStrand);
headerElement.removeBase(BaseUtils.Base.D.base, MQbyte, MQbyte, MQbyte, mappingQuality, MIN_BASE_QUAL_TO_COUNT, MIN_MAPPING_QUALITY, false, isNegativeStrand);
else
headerElement.addBase(BaseUtils.Base.D.base, mappingQuality, mappingQuality, mappingQuality, mappingQuality, MIN_BASE_QUAL_TO_COUNT, MIN_MAPPING_QUALITY, false, isNegativeStrand);
headerElement.addBase(BaseUtils.Base.D.base, MQbyte, MQbyte, MQbyte, mappingQuality, MIN_BASE_QUAL_TO_COUNT, MIN_MAPPING_QUALITY, false, isNegativeStrand);
}
locationIndex += nDeletionBases;
break;

View File

@ -860,6 +860,29 @@ public class SlidingWindowUnitTest extends BaseTest {
Assert.assertEquals(windowHeader.get(i).getBaseCounts(SlidingWindow.ConsensusType.POSITIVE_CONSENSUS).countOfBase(BaseUtils.Base.A.base), 0);
}
@Test
public void testUpdateHeaderForReadWithHighMQ() {
// set up the window header
final int currentHeaderStart = 100;
final LinkedList<HeaderElement> windowHeader = new LinkedList<>();
for ( int i = 0; i < readLength; i++ )
windowHeader.add(new HeaderElement(currentHeaderStart + i));
// set up the read
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "basicRead", 0, currentHeaderStart, readLength);
read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
read.setBaseQualities(Utils.dupBytes((byte)30, readLength));
read.setMappingQuality(180);
read.setReadNegativeStrandFlag(false);
// add the read and make sure it's not filtered because of low MQ (byte vs. int)
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 10, header, new GATKSAMReadGroupRecord("test"), 0, 0.05, 0.05, 0.05, 20, 20, 10, ReduceReads.DownsampleStrategy.Normal, false);
slidingWindow.actuallyUpdateHeaderForRead(windowHeader, read, false, 0);
for ( int i = 0; i < readLength; i++ )
Assert.assertEquals(windowHeader.get(i).getBaseCounts(SlidingWindow.ConsensusType.POSITIVE_CONSENSUS).countOfBase(BaseUtils.Base.A.base), 1);
}
//////////////////////////////////////////////////////////////////////////////////
//// This section tests functionality related to polyploid consensus creation ////
//////////////////////////////////////////////////////////////////////////////////