* - when true, "myseq" matches "X|myseq" and "myseq"
* @param seqs
*/
- public SequenceIdMatcher(boolean wordBasedMatch,
- List<SequenceI> seqs)
+ public SequenceIdMatcher(boolean wordBasedMatch, List<SequenceI> seqs)
{
wordBased = wordBasedMatch;
names = new HashMap<SeqIdName, Set<SequenceI>>();
public void addSeq(SequenceI seq)
{
- // TODO: deal with ID collisions - SequenceI should be appended to list
- // associated with this key.
+ // TODO: deal with ID collisions - SequenceI should be appended to list
+ // associated with this key.
addSeqIdName(new SeqIdName(seq.getDisplayId(true)), seq);
- if (wordBased)
+ if (wordBased)
+ {
+ for (SeqIdName key : getWordsFor(seq))
{
- for (SeqIdName key : getWordsFor(seq))
- {
addSeqIdName(key, seq);
- }
}
- SequenceI dbseq = seq;
+ }
+ SequenceI dbseq = seq;
// TODO add test for database xref resolution
- while (dbseq.getDatasetSequence() != null)
- {
- dbseq = dbseq.getDatasetSequence();
- }
- // add in any interesting identifiers
- if (dbseq.getDBRefs() != null)
+ while (dbseq.getDatasetSequence() != null)
+ {
+ dbseq = dbseq.getDatasetSequence();
+ }
+ // add in any interesting identifiers
+ if (dbseq.getDBRefs() != null)
+ {
+ DBRefEntry dbr[] = dbseq.getDBRefs();
+ SeqIdName sid = null;
+ for (int r = 0; r < dbr.length; r++)
{
- DBRefEntry dbr[] = dbseq.getDBRefs();
- SeqIdName sid = null;
- for (int r = 0; r < dbr.length; r++)
+ sid = new SeqIdName(dbr[r].getAccessionId());
+ if (!names.containsKey(sid))
{
- sid = new SeqIdName(dbr[r].getAccessionId());
- if (!names.containsKey(sid))
- {
addSeqIdName(sid, seq);
- }
}
+ }
}
}
-
/**
* generate word based keys for the given sequence
*