addSeq(cand);
int q, w, candlen = cand.getName().length();
// keep the one with an id 'closer' to the given seqnam string
- if ((q = Math.abs(matchlen - namlen)) > (w = Math.abs(candlen
- - namlen))
- && candlen > matchlen)
+ boolean is_closer = ((q = Math.abs(matchlen - namlen)) > (w = Math
+ .abs(candlen - namlen)) && candlen > matchlen);
+ // if not closer, then check if current best is actually identical in case
+ // as
+ // well
+ if (is_closer || (!candName.equalsCase(best.get(0).getName())))
{
best.clear();
match = cand;
}
if (q == w && candlen == matchlen)
{
+ // equivalently good, and matches with case as well. so
// record any ties
best.add(cand);
}
private class SeqIdName
{
- String id;
+ String id, origid;
SeqIdName(String s)
{
if (s != null)
{
id = new String(s).toLowerCase();
+ origid = new String(s);
}
else
{
{
return id;
}
+
+ public boolean equalsCase(String s)
+ {
+ if (origid.length() > s.length())
+ {
+ return check_wordmatch(origid, s);
+ }
+ else
+ {
+ return check_wordmatch(s, origid);
+ }
+ }
+
+ public boolean equalsCase(SeqIdName sid)
+ {
+ return equalsCase(sid.origid);
+ }
}
}