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:
parent
f12d40dde8
commit
3f75fc4e83
|
|
@ -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...
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue