From: kiramt Date: Thu, 1 Mar 2018 11:50:26 +0000 (+0000) Subject: JAL-2909 fixed another insertions bug X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c0d7fb852ebfdb0b4322c636dd379a031de665c8;p=jalview.git JAL-2909 fixed another insertions bug --- diff --git a/src/jalview/datamodel/CigarParser.java b/src/jalview/datamodel/CigarParser.java index fd5694c..d82bdec 100644 --- a/src/jalview/datamodel/CigarParser.java +++ b/src/jalview/datamodel/CigarParser.java @@ -270,7 +270,7 @@ public class CigarParser SAMRecord rec = it.next(); Iterator cit = rec.getCigar().getCigarElements() .iterator(); - int next = 0; + int next = 1; while (cit.hasNext()) { CigarElement el = cit.next(); @@ -278,12 +278,11 @@ public class CigarParser { case I: // add to insertions list, and move along the read - // location is 1 past the current position of next - // (note if we try to retrieve +1 position from reference by calling - // getReferencePositionAtReadPosition(next+1) we get 0 because it's an - // insertion!) - int refLocation = rec.getReferencePositionAtReadPosition(next) - + 1; + // location is the start of next CIGAR segment + // because getReferencePositionAtReadPosition returns 0 for read + // positions which are not in the reference (like insertions) + int refLocation = rec.getReferencePositionAtReadPosition( + next + el.getLength()); // if there's already an insertion at this location, keep the longest // insertion; if there's no insertion keep this one