From: Jim Procter Date: Mon, 3 Oct 2016 08:16:14 +0000 (+0100) Subject: JAL-2210 explicit ‘doNotAdd’ list to prevent sequences retrieved from being added... X-Git-Tag: Release_2_10_0~20^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9fe5c5081bf6b6d731c13213b9fec98969999723;p=jalview.git JAL-2210 explicit ‘doNotAdd’ list to prevent sequences retrieved from being added whose references have already been remapped to local dataset sequences --- diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 71b0aa0..59ba8a3 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -422,13 +422,16 @@ public class CrossRef if (retrieved != null) { boolean addedXref = false; + List newDsSeqs = new ArrayList(), doNotAdd = new ArrayList(); + 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) { @@ -441,7 +444,17 @@ public class CrossRef // 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); } } } @@ -494,6 +507,7 @@ public class CrossRef * @return true if retrieveSequence was imported */ private boolean importCrossRefSeq(AlignedCodonFrame cf, + List newDsSeqs, List doNotAdd, SequenceI sourceSequence, SequenceI retrievedSequence) { /** @@ -502,7 +516,6 @@ public class CrossRef */ boolean imported = false; DBRefEntry[] dbr = retrievedSequence.getDBRefs(); - List newDsSeqs = new ArrayList(); if (dbr != null) { for (DBRefEntry dbref : dbr) @@ -574,9 +587,15 @@ public class CrossRef */ 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); /* @@ -634,15 +653,6 @@ public class CrossRef dataset.addSequence(retrievedSequence); matcher.add(retrievedSequence); } - for (SequenceI newToSeq : newDsSeqs) - { - - if (dataset.findIndex(newToSeq) == -1) - { - dataset.addSequence(newToSeq); - matcher.add(newToSeq); - } - } } return imported; }