{
if (start == end)
{
- getContactPoints(contactFeatureStarts, start, result, true);
- getContactPoints(contactFeatureEnds, start, result, false);
+ getContactPointStarts(contactFeatureStarts, start, result);
+ getContactPointEnds(contactFeatureEnds, end, result);
}
else
{
*
* @author Bob Hanson 2019.07.30
*/
- private void getContactPoints(List<SequenceFeature> l, long pos,
- List<SequenceFeature> result, boolean isStart)
+ private void getContactPointStarts(List<SequenceFeature> l, long pos,
+ List<SequenceFeature> result)
{
int low = 0;
int high = l.size() - 1;
{
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;
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);
}
}
}
+ private void getContactPointEnds(List<SequenceFeature> l, long pos,
+ List<SequenceFeature> 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