From 9fe5c5081bf6b6d731c13213b9fec98969999723 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 3 Oct 2016 09:16:14 +0100 Subject: [PATCH] =?utf8?q?JAL-2210=20explicit=20=E2=80=98doNotAdd=E2=80=99=20?= =?utf8?q?list=20to=20prevent=20sequences=20retrieved=20from=20being=20added?= =?utf8?q?=20whose=20references=20have=20already=20been=20remapped=20to=20lo?= =?utf8?q?cal=20dataset=20sequences?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/analysis/CrossRef.java | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) 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; } -- 1.7.10.2