- /**
- * Quickly check if the given sequence is referred to in the search results
- *
- * @param sequence
- * (specific alignment sequence or a dataset sequence)
- * @return true if the results involve sequence
- */
+ @Override
+ public boolean appendResult(SequenceI sequence, int start, int end)
+ {
+
+ Match m = new Match(sequence, start, end);
+
+ boolean appending=false;
+
+ // we dynamically maintain an interval to add as we test each range in the list
+
+ int cstart=start,cend=end;
+ List<SearchResultMatchI> toRemove=new ArrayList<>();
+ for (SearchResultMatchI thatm:matches)
+ {
+ if (thatm.getSequence()==sequence)
+ {
+ if (thatm.contains(sequence,cstart,cend))
+ {
+ // found a match containing the current range. nothing else to do except report if we operated on the list
+ return appending;
+ }
+ if (thatm.adjacent(sequence, cstart, cend))
+ {
+ // update the match to add with the adjacent start/end
+ start = Math.min(m.start, thatm.getStart());
+ end = Math.max(m.end, thatm.getEnd());
+ // and check if we keep or remove the old one
+ if (thatm.getStart()!=start || thatm.getEnd()!=end)
+ {
+ toRemove.add(thatm);
+ count--;
+ cstart = start;
+ cend = end;
+ appending=true;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ matches.removeAll(toRemove);
+ {
+ matches.add(new Match(sequence,cstart,cend));
+ count++;
+ }
+ return appending;
+ }
+ @Override