}
/**
+ * Run through the sorted sequence array once, building the containedBy linked
+ * list references. Does a check first to make sure there is actually
+ * something out there that is overlapping. A null for sf.containedBy means
+ * there are no overlaps for this feature.
*
* @param intervals
*/
int maxEnd = intervals[0].end;
for (int i = 1, n = intervals.length; i < n; i++)
{
- SequenceFeature ithis = intervals[i];
- if (ithis.begin <= maxEnd)
+ SequenceFeature sf = intervals[i];
+ if (sf.begin <= maxEnd)
{
- ithis.containedBy = getContainedBy(intervals[i - 1], ithis);
+ sf.containedBy = getContainedBy(intervals[i - 1], sf);
}
- if (ithis.end > maxEnd)
+ if (sf.end > maxEnd)
{
- maxEnd = ithis.end;
+ maxEnd = sf.end;
}
}
}
/**
- * Since we are traversing the sorted feature array, all elements prior to the
- * one we are working on have been fully linked. All we are doing is following
- * those links until we find the first array feature with a containedBy
- * element that has an end >= our begin point. It is generally a very short
- * list -- maybe one or two depths. But it might be more than that.
+ * Since we are traversing the sorted feature array in a forward direction,
+ * all elements prior to the one we are working on have been fully linked. All
+ * we are doing is following those links until we find the first array feature
+ * with a containedBy element that has an end >= our begin point. It is
+ * generally a very short list -- maybe one or two depths. But it might be
+ * more than that.
*
* @param sf
* @param sf0
return null;
}
- // Searching for overlapping features at a given position:
+ // search-stage methods
/**
* Binary search for contact start or end at a given (Overview) position.
/**
* A binary search identical to the one used for contact start/end, but here
- * we return the feature itself.
+ * we return the feature itself. Unlike Collection.BinarySearch, all we have
+ * to be is close, not exact, and we make sure if there is a string of
+ * identical starts, then we slide to the end so that we can check all of
+ * them.
*
* @param l
* @param pos
{
;
}
- mid--;
- return l[mid];
+ return l[--mid];
}
}
// -1 here?