Fixing the 'header is negative' problem in Reduce Reads... again.

Previous fixes and tests only covered trailing soft-clips.  Now that up front
hard-clipping is working properly though, we were failing on those in the tool.

Added a patch for this as well as a separate test independent of the soft-clips
to make sure that it's working properly.
This commit is contained in:
Eric Banks 2013-06-24 14:06:21 -04:00
parent d8ca4d3e6d
commit 165b936fcd
2 changed files with 18 additions and 5 deletions

View File

@ -94,7 +94,7 @@ public class SlidingWindowUnitTest extends BaseTest {
//////////////////////////////////////////////////////////////////////////////////////
@Test(enabled = true)
public void testLeadingClipThenInsertion() {
public void testLeadingSoftClipThenInsertion() {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 10);
read.setReadBases(Utils.dupBytes((byte) 'A', 10));
@ -104,8 +104,21 @@ public class SlidingWindowUnitTest extends BaseTest {
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 1);
slidingWindow.addRead(read);
Pair<ObjectSet<GATKSAMRecord>, CompressionStash> result = slidingWindow.close(null);
slidingWindow.close(null);
}
@Test(enabled = true)
public void testLeadingHardClipThenInsertion() {
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 8);
read.setReadBases(Utils.dupBytes((byte) 'A', 8));
read.setBaseQualities(Utils.dupBytes((byte)30, 8));
read.setMappingQuality(30);
read.setCigarString("2H2I6M");
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, 10, header, new GATKSAMReadGroupRecord("test"), 0, 0.05, 0.05, 0.05, 20, 20, 100, ReduceReads.DownsampleStrategy.Normal, false);
slidingWindow.addRead(read);
slidingWindow.close(null);
}
//////////////////////////////////////////////////////////////////////////////////////

View File

@ -613,15 +613,15 @@ public class ReadUtils {
* Checks if a read starts with an insertion.
*
* @param cigarForRead the CIGAR to evaluate
* @param ignoreClipOps should we ignore S and H operators when evaluating whether an I operator is at the beginning?
* @param ignoreSoftClipOps should we ignore S operators when evaluating whether an I operator is at the beginning? Note that H operators are always ignored.
* @return the element if it's a leading insertion or null otherwise
*/
public static CigarElement readStartsWithInsertion(final Cigar cigarForRead, final boolean ignoreClipOps) {
public static CigarElement readStartsWithInsertion(final Cigar cigarForRead, final boolean ignoreSoftClipOps) {
for ( final CigarElement cigarElement : cigarForRead.getCigarElements() ) {
if ( cigarElement.getOperator() == CigarOperator.INSERTION )
return cigarElement;
else if ( !ignoreClipOps || (cigarElement.getOperator() != CigarOperator.HARD_CLIP && cigarElement.getOperator() != CigarOperator.SOFT_CLIP) )
else if ( cigarElement.getOperator() != CigarOperator.HARD_CLIP && ( !ignoreSoftClipOps || cigarElement.getOperator() != CigarOperator.SOFT_CLIP) )
break;
}
return null;