diff --git a/uk/ac/sanger/artemis/components/alignment/BamUtils.java b/uk/ac/sanger/artemis/components/alignment/BamUtils.java index 8ad6da6ce670d76fdf208fb781b63205133b2fff..84e90f524e522eca357265d2827f19bf0896c655 100644 --- a/uk/ac/sanger/artemis/components/alignment/BamUtils.java +++ b/uk/ac/sanger/artemis/components/alignment/BamUtils.java @@ -166,6 +166,7 @@ class BamUtils final String refName, final int start, final int end, + final int concatShift, final int cnt[][], final SAMRecordPredicate samRecordFlagPredicate, final SAMRecordPredicate samRecordMapQPredicate) @@ -194,7 +195,7 @@ class BamUtils int refStart = block.getReferenceStart(); for(int i=0; i<block.getLength(); i++) { - int pos = refStart + i; + int pos = refStart + i + concatShift; int bin = pos - start; if(bin < 0 || bin > cnt.length-1) continue; diff --git a/uk/ac/sanger/artemis/components/alignment/MappedReads.java b/uk/ac/sanger/artemis/components/alignment/MappedReads.java index f065b85bbfa9369949e1fc0cd99fd1be44ebd164..230f26e0be5e367ec49281c2236b042209e6a9eb 100644 --- a/uk/ac/sanger/artemis/components/alignment/MappedReads.java +++ b/uk/ac/sanger/artemis/components/alignment/MappedReads.java @@ -487,9 +487,20 @@ public class MappedReads if( (start >= offset && start <= offset+len) || (stop >= offset && start <= offset+len) ) { + int thisStart = start-offset; + if(thisStart < 1) + thisStart = 1; + int thisEnd = stop-offset; + if(thisEnd > len) + thisEnd = len; + + int concatShift = 0; + if(offset > start) + concatShift = offset-start; + cnt = BamUtils.countOverRange(bamList.get(i), samFileReaderHash, - name, start-offset, stop-offset, cnt, + name, thisStart, thisEnd, concatShift, cnt, samRecordFlagPredicate, samRecordMapQPredicate); } } @@ -498,7 +509,7 @@ public class MappedReads { cnt = BamUtils.countOverRange(bamList.get(i), samFileReaderHash, - refSeq, start, stop, cnt, + refSeq, start, stop, 0, cnt, samRecordFlagPredicate, samRecordMapQPredicate); }