Unfortunately, because BWA occasionally outputs crazy reads, we need

to make sure not to have an ArrayIndexOutOfBoundsException thrown.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@297 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-04-06 03:51:35 +00:00
parent f12d40dde8
commit 3f75fc4e83
2 changed files with 4 additions and 1 deletions

View File

@ -37,10 +37,12 @@ public class MismatchHistoWalker extends ReadWalker<Integer, Integer> {
int start = read.getAlignmentStart()-1;
int stop = read.getAlignmentEnd();
// sometimes BWA outputs screwy reads
if ( stop >= context.getReferenceContig().getBases().length )
return 0;
List<Byte> refSeq = Utils.subseq(context.getReferenceContig().getBases(), start, stop);
List<Byte> readBases = Utils.subseq(read.getReadBases());
assert(refSeq.size() == readBases.size());
// it's actually faster to reallocate a resized array than to use ArrayLists...

View File

@ -163,6 +163,7 @@ public class Utils {
}
public static ArrayList<Byte> subseq(byte[] fullArray, int start, int end) {
assert end < fullArray.length;
ArrayList<Byte> dest = new ArrayList<Byte>(end - start + 1);
for (int i = start; i < end; i++) {
dest.add(fullArray[i]);