- * Adds one feature to the NCList that can manage nested features (creating
- * the NCList if necessary), and returns true. If the feature is already
- * stored in the NCList (by equality test), then it is not added, and this
- * method returns false.
- */
- protected synchronized boolean addNestedFeature(SequenceFeature feature)
- {
- if (nestedFeatures == null)
- {
- nestedFeatures = new NCList<>(feature);
- return true;
- }
- return nestedFeatures.add(feature, false);
- }
-
- /**
- * Add a feature to the list of non-nested features, maintaining the ordering
- * of the list. A check is made for whether the feature is nested in (properly
- * contained by) an existing feature. If there is no nesting, the feature is
- * added to the list and the method returns true. If nesting is found, the
- * feature is not added and the method returns false.
- *
- * @param feature
- * @return
- */
- protected boolean addNonNestedFeature(SequenceFeature feature)
- {
- synchronized (nonNestedFeatures)
- {
- /*
- * find the first stored feature which doesn't precede the new one
- */
- int insertPosition = binarySearch(nonNestedFeatures,
- SearchCriterion.byFeature(feature, RangeComparator.BY_START_POSITION));
-
- /*
- * fail if we detect feature enclosure - of the new feature by
- * the one preceding it, or of the next feature by the new one
- */
- if (insertPosition > 0)
- {
- if (encloses(nonNestedFeatures.get(insertPosition - 1), feature))
- {
- return false;
- }
- }
- if (insertPosition < nonNestedFeatures.size())
- {
- if (encloses(feature, nonNestedFeatures.get(insertPosition)))
- {
- return false;
- }
- }
-
- /*
- * checks passed - add the feature
- */
- nonNestedFeatures.add(insertPosition, feature);
-
- return true;
- }
- }
-
- /**
- * Answers true if range1 properly encloses range2, else false
- *
- * @param range1
- * @param range2
- * @return