if (retrieved != null)
{
boolean addedXref = false;
+ List<SequenceI> newDsSeqs = new ArrayList<SequenceI>(), doNotAdd = new ArrayList<SequenceI>();
+
for (SequenceI retrievedSequence : retrieved)
{
// dataset gets contaminated ccwith non-ds sequences. why ??!
// try: Ensembl -> Nuc->Ensembl, Nuc->Uniprot-->Protein->EMBL->
SequenceI retrievedDss = retrievedSequence.getDatasetSequence() == null ? retrievedSequence
: retrievedSequence.getDatasetSequence();
- addedXref |= importCrossRefSeq(cf, dss, retrievedDss);
+ addedXref |= importCrossRefSeq(cf, newDsSeqs, doNotAdd, dss,
+ retrievedDss);
}
if (!addedXref)
{
// try: Ensembl -> Nuc->Ensembl, Nuc->Uniprot-->Protein->EMBL->
SequenceI retrievedDss = retrievedSequence.getDatasetSequence() == null ? retrievedSequence
: retrievedSequence.getDatasetSequence();
- addedXref |= importCrossRefSeq(cf, dss, retrievedDss);
+ addedXref |= importCrossRefSeq(cf, newDsSeqs, doNotAdd, dss,
+ retrievedDss);
+ }
+ }
+ for (SequenceI newToSeq : newDsSeqs)
+ {
+ if (!doNotAdd.contains(newToSeq)
+ && dataset.findIndex(newToSeq) == -1)
+ {
+ dataset.addSequence(newToSeq);
+ matcher.add(newToSeq);
}
}
}
* @return true if retrieveSequence was imported
*/
private boolean importCrossRefSeq(AlignedCodonFrame cf,
+ List<SequenceI> newDsSeqs, List<SequenceI> doNotAdd,
SequenceI sourceSequence, SequenceI retrievedSequence)
{
/**
*/
boolean imported = false;
DBRefEntry[] dbr = retrievedSequence.getDBRefs();
- List<SequenceI> newDsSeqs = new ArrayList<SequenceI>();
if (dbr != null)
{
for (DBRefEntry dbref : dbr)
*/
for (DBRefEntry ref : toRefs)
{
+ if (dbref.getSrcAccString().equals(
+ ref.getSrcAccString()))
+ {
+ continue; // avoid overwriting the ref on source sequence
+ }
matched.addDBRef(ref); // add or update mapping
}
}
+ doNotAdd.add(map.getTo());
map.setTo(matched);
/*
dataset.addSequence(retrievedSequence);
matcher.add(retrievedSequence);
}
- for (SequenceI newToSeq : newDsSeqs)
- {
-
- if (dataset.findIndex(newToSeq) == -1)
- {
- dataset.addSequence(newToSeq);
- matcher.add(newToSeq);
- }
- }
}
return imported;
}