git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-2069 updated spike to latest
[jalview.git]
/
src
/
jalview
/
datamodel
/
SearchResults.java
diff --git
a/src/jalview/datamodel/SearchResults.java
b/src/jalview/datamodel/SearchResults.java
index
1bf5475
..
cde50e5
100755
(executable)
--- 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
{
public class SearchResults implements SearchResultsI
{
- private List<SearchResultMatchI> matches = new ArrayList<SearchResultMatchI>();
+ private List<SearchResultMatchI> matches = new ArrayList<>();
/**
* One match consists of a sequence reference, start and end positions.
/**
* 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
{
*/
public class Match implements SearchResultMatchI
{
- SequenceI sequence;
+ final SequenceI sequence;
/**
* Start position of match in sequence (base 1)
*/
/**
* Start position of match in sequence (base 1)
*/
- int start;
+ final int start;
/**
* End position (inclusive) (base 1)
*/
/**
* End position (inclusive) (base 1)
*/
- int end;
+ final int end;
/**
* create a Match on a range of sequence. Match always holds region in
/**
* 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();
}
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
/**
* 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
@@
-164,8
+159,8
@@
public class SearchResults implements SearchResultsI
return false;
}
SearchResultMatchI m = (SearchResultMatchI) obj;
return false;
}
SearchResultMatchI m = (SearchResultMatchI) obj;
- return (sequence == m.getSequence() && start == m.getStart() && end == m
- .getEnd());
+ return (sequence == m.getSequence() && start == m.getStart()
+ && end == m.getEnd());
}
}
}
}
@@
-219,20
+214,15
@@
public class SearchResults implements SearchResultsI
m = (Match) _m;
mfound = false;
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;
{
mfound = true;
- // locate region in local context
matchStart = sequence.findIndex(m.start) - 1;
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)
if (mfound)
{
if (matchStart <= end && matchEnd >= start)
@@
-264,7
+254,7
@@
public class SearchResults implements SearchResultsI
else
{
// debug
else
{
// debug
- // System.err.println("Outwith bounds!" + matchStart+">"+end +" or "
+ // System.err.println("Outwith bounds!" + matchStart+">"+end +" or "
// + matchEnd+"<"+start);
}
}
// + matchEnd+"<"+start);
}
}
@@
-363,4
+353,10
@@
public class SearchResults implements SearchResultsI
SearchResultsI sr = (SearchResultsI) obj;
return matches.equals(sr.getResults());
}
SearchResultsI sr = (SearchResultsI) obj;
return matches.equals(sr.getResults());
}
+
+ @Override
+ public void addSearchResults(SearchResultsI toAdd)
+ {
+ matches.addAll(toAdd.getResults());
+ }
}
}