X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMappingUtils.java;h=ae4e55d3a31eea6ea64d8f4b742457627f03db1f;hb=65d6d09cd08743d481d39521bb0298ea683888f8;hp=c2cad1f8ef3e27d226f83e940c3607ef3f9db23b;hpb=4ad19b786f19aeadaf7a841e43ff8e490a39589d;p=jalview.git diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index c2cad1f..ae4e55d 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -770,7 +770,8 @@ public final class MappingUtils } /** - * Returns the total length of the supplied ranges + * Returns the total length of the supplied ranges, which may be as single + * [start, end] or multiple [start, end, start, end ...] * * @param ranges * @return @@ -784,7 +785,16 @@ public final class MappingUtils int length = 0; for (int[] range : ranges) { - length += Math.abs(range[1] - range[0]) + 1; + if (range.length % 2 != 0) + { + System.err.println("Error unbalance start/end ranges: " + + ranges.toString()); + return 0; + } + for (int i = 0; i < range.length - 1; i += 2) + { + length += Math.abs(range[i + 1] - range[i]) + 1; + } } return length; } @@ -848,7 +858,6 @@ public final class MappingUtils int cdspos = 0; for (int x = 0; x < copy.length && sxpos == -1; x += 2) { - // fixme handle reverse strand cdspos += Math.abs(copy[x + 1] - copy[x]) + 1; if (removeCount < cdspos) {