IndelRealigner throws a user error when it encounters reads with I operators greater than the number of read bases.
Added test to ensure it works.
This commit is contained in:
parent
890f4e8873
commit
7174f8cfeb
|
|
@ -1462,6 +1462,8 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
||||||
case EQ:
|
case EQ:
|
||||||
case X:
|
case X:
|
||||||
case I:
|
case I:
|
||||||
|
if ( fromIndex + elementLength > actualReadBases.length )
|
||||||
|
throw new UserException.MalformedBAM(read, "the CIGAR string is inconsistent with the number of bases in the read");
|
||||||
System.arraycopy(actualReadBases, fromIndex, readBases, toIndex, elementLength);
|
System.arraycopy(actualReadBases, fromIndex, readBases, toIndex, elementLength);
|
||||||
System.arraycopy(actualBaseQuals, fromIndex, baseQuals, toIndex, elementLength);
|
System.arraycopy(actualBaseQuals, fromIndex, baseQuals, toIndex, elementLength);
|
||||||
fromIndex += elementLength;
|
fromIndex += elementLength;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
package org.broadinstitute.sting.gatk.walkers.indels;
|
package org.broadinstitute.sting.gatk.walkers.indels;
|
||||||
|
|
||||||
import org.broadinstitute.sting.WalkerTest;
|
import org.broadinstitute.sting.WalkerTest;
|
||||||
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -169,4 +170,12 @@ public class IndelRealignerIntegrationTest extends WalkerTest {
|
||||||
executeTest("test realigner nWayOut", spec1);
|
executeTest("test realigner nWayOut", spec1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = RuntimeException.class) // because TESTNG wraps UserExceptions in RuntimeExceptions
|
||||||
|
public void testBadCigarString() {
|
||||||
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
|
"-T IndelRealigner -R " + b37KGReference + " -I " + privateTestDir + "Realigner.error.bam -L 19:5787200-5787300 -targetIntervals 19:5787205-5787300 -o %s",
|
||||||
|
1,
|
||||||
|
Arrays.asList("FAILFAILFAILFAILFAILFAILFAILFAIL"));
|
||||||
|
executeTest("test bad cigar", spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue