List<SequenceI> st = pickbestMatches(candName, matches);
return st == null || st.size() == 0 ? null : st.get(0);
}
+
+ /**
+ * returns the SequenceI's with exact word matches to candName
+ *
+ * @param candName
+ * SeqIdName
+ * @param matches
+ * List of SequenceI objects - some of which may be duplicates
+ * @return { word matches to candName }
+ */
+ private List<SequenceI> pickwordMatches(SeqIdName candName,
+ List<SequenceI> matches)
+ {
+ List<SequenceI> best = new ArrayList<SequenceI>();
+ for (SequenceI match : matches)
+ {
+ if (!best.contains(match))
+ {
+ if (candName.equalsCase(match.getDisplayId(true)))
+ {
+ // put the exact match at the beginning
+ best.add(0, match);
+ }
+ else
+ {
+ best.add(match);
+ }
+ addSeq(match);
+ }
+ }
+ return best;
+ }
/**
* returns the closest SequenceI in matches to SeqIdName and returns all the
*
* @param seqnam
* string to query Matcher with.
- * @return a new array or (possibly) null
+ * @return a new array or null of no match exists
*/
public SequenceI[] findAllIdMatches(String seqnam)
{
SeqIdName nam = new SeqIdName(seqnam);
List<SequenceI> m = findAllIdMatches(nam);
- if (m != null)
+ if (m != null && m.size() > 0)
{
return m.toArray(new SequenceI[m.size()]);
}
{
matches.addAll(names.remove(nam));
}
- List<SequenceI> r = pickbestMatches(nam, matches);
+ List<SequenceI> r = (wordBased) ? pickwordMatches(nam, matches)
+ : pickbestMatches(nam, matches);
return r;
}
}