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:
commit
6d43952ccc
|
|
@ -1033,7 +1033,7 @@ public class SlidingWindow {
|
||||||
protected void actuallyUpdateHeaderForRead(final LinkedList<HeaderElement> header, final GATKSAMRecord read, final boolean removeRead, final int startIndex) {
|
protected void actuallyUpdateHeaderForRead(final LinkedList<HeaderElement> header, final GATKSAMRecord read, final boolean removeRead, final int startIndex) {
|
||||||
|
|
||||||
final Iterator<HeaderElement> headerElementIterator = header.listIterator(startIndex);
|
final Iterator<HeaderElement> headerElementIterator = header.listIterator(startIndex);
|
||||||
final byte mappingQuality = (byte) read.getMappingQuality();
|
final int mappingQuality = read.getMappingQuality();
|
||||||
final boolean isNegativeStrand = read.getReadNegativeStrandFlag();
|
final boolean isNegativeStrand = read.getReadNegativeStrandFlag();
|
||||||
|
|
||||||
// iterator variables
|
// iterator variables
|
||||||
|
|
@ -1062,14 +1062,15 @@ public class SlidingWindow {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case D:
|
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 int nDeletionBases = cigarElement.getLength();
|
||||||
|
final byte MQbyte = mappingQuality > Byte.MAX_VALUE ? Byte.MAX_VALUE : (byte)mappingQuality;
|
||||||
for ( int i = 0; i < nDeletionBases; i++ ) {
|
for ( int i = 0; i < nDeletionBases; i++ ) {
|
||||||
headerElement = headerElementIterator.next();
|
headerElement = headerElementIterator.next();
|
||||||
if (removeRead)
|
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
|
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;
|
locationIndex += nDeletionBases;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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 ////
|
//// This section tests functionality related to polyploid consensus creation ////
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue