X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Ffeatures%2FFeatureStoreJS.java;h=4f4936072946d157a4ff2390631e0da607548b92;hb=80634498762666e6acc92368716bf1a4d4f42f7b;hp=dbf14132b500e229e61d172d754686f66b8d8411;hpb=6671b10825bea29ed703911822c18e25ce44f776;p=jalview.git diff --git a/src/jalview/datamodel/features/FeatureStoreJS.java b/src/jalview/datamodel/features/FeatureStoreJS.java index dbf1413..4f49360 100644 --- a/src/jalview/datamodel/features/FeatureStoreJS.java +++ b/src/jalview/datamodel/features/FeatureStoreJS.java @@ -244,8 +244,8 @@ public class FeatureStoreJS extends FeatureStore { if (start == end) { - getContactPoints(contactFeatureStarts, start, result, true); - getContactPoints(contactFeatureEnds, start, result, false); + getContactPointStarts(contactFeatureStarts, start, result); + getContactPointEnds(contactFeatureEnds, end, result); } else { @@ -309,8 +309,8 @@ public class FeatureStoreJS extends FeatureStore * * @author Bob Hanson 2019.07.30 */ - private void getContactPoints(List l, long pos, - List result, boolean isStart) + private void getContactPointStarts(List l, long pos, + List result) { int low = 0; int high = l.size() - 1; @@ -318,7 +318,7 @@ public class FeatureStoreJS extends FeatureStore { int mid = (low + high) >>> 1; SequenceFeature f = l.get(mid); - switch (Long.signum((isStart ? f.begin : f.end) - pos)) + switch (Long.signum(f.begin - pos)) { case -1: low = mid + 1; @@ -330,13 +330,11 @@ public class FeatureStoreJS extends FeatureStore int m = mid; result.add(f); // could be "5" in 12345556788 ? - while (++mid <= high && (f = l.get(mid)) != null - && (isStart ? f.begin : f.end) == pos) + while (++mid <= high && (f = l.get(mid)) != null && f.begin == pos) { result.add(f); } - while (--m >= low && (f = l.get(m)) != null - && (isStart ? f.begin : f.end) == pos) + while (--m >= low && (f = l.get(m)) != null && f.begin == pos) { result.add(f); } @@ -345,6 +343,51 @@ public class FeatureStoreJS extends FeatureStore } } + private void getContactPointEnds(List l, long pos, + List result) + { + int low = 0; + int high = l.size() - 1; + while (low <= high) + { + int mid = (low + high) >>> 1; + SequenceFeature f = l.get(mid); + switch (Long.signum(f.end - pos)) + { + case -1: + low = mid + 1; + continue; + case 1: + high = mid - 1; + continue; + case 0: + int m = mid; + if (f.begin != f.end) + { + result.add(f); + } + // could be "5" in 12345556788 ? + while (++mid <= high && (f = l.get(mid)) != null + && f.end == pos) + { + if (f.begin != f.end) + { + result.add(f); + } + } + while (--m >= low && (f = l.get(m)) != null + && f.end == pos) + { + if (f.begin != f.end) + { + result.add(f); + } + } + return; + } + } + } + /** * Adds contact features whose start position lies in the from-to range to the * result list