X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSearchResults.java;h=d1e3fcc9698ac00016a30a09358507e1289e199d;hb=09d3b755d9b00f5c3acb44049aedd49361dc0690;hp=a270e3730794fb86701eed87f153ac4a4758e65c;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index a270e37..d1e3fcc 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -34,7 +34,7 @@ import java.util.List; public class SearchResults implements SearchResultsI { - private List matches = new ArrayList(); + private List matches = new ArrayList<>(); /** * One match consists of a sequence reference, start and end positions. @@ -42,17 +42,17 @@ public class SearchResults implements SearchResultsI */ public class Match implements SearchResultMatchI { - SequenceI sequence; + final SequenceI sequence; /** * Start position of match in sequence (base 1) */ - int start; + final int start; /** * End position (inclusive) (base 1) */ - int end; + final int end; /** * create a Match on a range of sequence. Match always holds region in @@ -133,11 +133,6 @@ public class SearchResults implements SearchResultsI return sb.toString(); } - public void setSequence(SequenceI seq) - { - this.sequence = seq; - } - /** * Hashcode is the hashcode of the matched sequence plus a hash of start and * end positions. Match objects that pass the test for equals are guaranteed @@ -219,20 +214,15 @@ public class SearchResults implements SearchResultsI m = (Match) _m; mfound = false; - if (m.sequence == sequence) - { - mfound = true; - // locate aligned position - matchStart = sequence.findIndex(m.start) - 1; - matchEnd = sequence.findIndex(m.end) - 1; - } - else if (m.sequence == sequence.getDatasetSequence()) + if (m.sequence == sequence + || m.sequence == sequence.getDatasetSequence()) { mfound = true; - // locate region in local context matchStart = sequence.findIndex(m.start) - 1; - matchEnd = sequence.findIndex(m.end) - 1; + matchEnd = m.start == m.end ? matchStart : sequence + .findIndex(m.end) - 1; } + if (mfound) { if (matchStart <= end && matchEnd >= start) @@ -277,9 +267,12 @@ public class SearchResults implements SearchResultsI { int count = 0; BitSet mask = new BitSet(); + int startRes = sqcol.getStartRes(); + int endRes = sqcol.getEndRes(); + for (SequenceI s : sqcol.getSequences()) { - int[] cols = getResults(s, sqcol.getStartRes(), sqcol.getEndRes()); + int[] cols = getResults(s, startRes, endRes); if (cols != null) { for (int pair = 0; pair < cols.length; pair += 2) @@ -363,4 +356,10 @@ public class SearchResults implements SearchResultsI SearchResultsI sr = (SearchResultsI) obj; return matches.equals(sr.getResults()); } + + @Override + public void addSearchResults(SearchResultsI toAdd) + { + matches.addAll(toAdd.getResults()); + } }