X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FCrossRef.java;h=7e77fc1e0903799660db67205966ddcf768a1897;hb=0ebcd487f08f9873987d9a32edce7df47aa27927;hp=7d09a3b2f3506074edcabc2b0f41b60c46fb62e7;hpb=6c52cc0b81ae3abdc3c5f6f88a23364a0246351a;p=jalview.git diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 7d09a3b..7e77fc1 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -228,14 +228,10 @@ public class CrossRef * @param al * alignment to search for cross-referenced sequences (and possibly * add to) - * @param addedPeers - * a list of sequences to add to if 'peers' to the original sequences - * are found e.g. alternative protein products for a protein's gene * @return products (as dataset sequences) */ public static Alignment findXrefSequences(SequenceI[] seqs, - final boolean dna, final String source, AlignmentI al, - List addedPeers) + final boolean dna, final String source, AlignmentI al) { AlignmentI dataset = al.getDataset() == null ? al : al.getDataset(); List rseqs = new ArrayList(); @@ -298,7 +294,6 @@ public class CrossRef { found |= searchDataset(dss, xref, dataset, rseqs, cf, false, !dna); - // ,false,!dna); if (found) { xrfs[r] = null; // we've recovered seqs for this one. @@ -332,8 +327,8 @@ public class CrossRef } if (l > 0) { - System.out - .println("Attempting to retrieve cross referenced sequences."); + // System.out + // .println("Attempting to retrieve cross referenced sequences."); DBRefEntry[] t = new DBRefEntry[l]; l = 0; for (int r = 0; r < xrfs.length; r++) @@ -361,6 +356,8 @@ public class CrossRef { updateDbrefMappings(dna, seq, xrfs, retrieved, cf); + SequenceIdMatcher matcher = new SequenceIdMatcher( + dataset.getSequences()); List copiedFeatures = new ArrayList(); CrossRef me = new CrossRef(); for (int rs = 0; rs < retrieved.length; rs++) @@ -378,8 +375,25 @@ public class CrossRef { if (map.getTo() != null && map.getMap() != null) { - // should search the local dataset to find any existing - // candidates for To ! + SequenceI matched = matcher + .findIdMatch(map.getTo()); + if (matched != null) + { + /* + * already got an xref to this sequence; update this + * map to point to the same sequence, and add + * any new dbrefs to it + */ + for (DBRefEntry ref : map.getTo().getDBRefs()) + { + matched.addDBRef(ref); // add or update mapping + } + map.setTo(matched); + } + else + { + matcher.add(map.getTo()); + } try { // compare ms with dss and replace with dss in mapping @@ -406,7 +420,8 @@ public class CrossRef map.setTo(dss); /* * copy sequence features as well, avoiding - * duplication (e.g. from 2 transcripts) + * duplication (e.g. same variation from 2 + * transcripts) */ SequenceFeature[] sfs = ms .getSequenceFeatures(); @@ -433,7 +448,6 @@ public class CrossRef } else { - addedPeers.add(map.getTo()); cf.addMap(retrieved[rs].getDatasetSequence(), map.getTo(), map.getMap()); }