From 81acbfca392c2868b5f41fc40906dba33891a15d Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 21 Mar 2016 16:46:10 +0000 Subject: [PATCH] JAL-2029 further fixes to get correct xrefs and xrefs on xrefs... --- src/jalview/analysis/CrossRef.java | 9 ++++ src/jalview/datamodel/xdb/embl/EmblEntry.java | 59 +++++++++++++------------ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index d48c14a..0f7a754 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -385,6 +385,15 @@ public class CrossRef .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); + } map.setTo(matched); } else diff --git a/src/jalview/datamodel/xdb/embl/EmblEntry.java b/src/jalview/datamodel/xdb/embl/EmblEntry.java index 7da6d6c..d830130 100644 --- a/src/jalview/datamodel/xdb/embl/EmblEntry.java +++ b/src/jalview/datamodel/xdb/embl/EmblEntry.java @@ -502,47 +502,50 @@ public class EmblEntry dna.addSequenceFeature(sf); } } - // add dbRefs to sequence + + /* + * add dbRefs to sequence, and mappings for Uniprot xrefs + */ if (feature.dbRefs != null) { - boolean productMapped = false; + boolean mappingUsed = false; for (DBRefEntry ref : feature.dbRefs) { ref.setSource(DBRefUtils.getCanonicalName(ref.getSource())); - // Hard code the kind of protein product accessions that EMBL cite if (ref.getSource().equals(DBRefSource.UNIPROT)) { - String refSeqName = DBRefSource.UNIPROT + "|" + String proteinSeqName = DBRefSource.UNIPROT + "|" + ref.getAccessionId(); - ref.setMap(map); if (map != null && map.getTo() != null) { - // if (!productMapped) - // { - // map.getTo().setName(refSeqName); - // map.getTo().addDBRef( - // new DBRefEntry(ref.getSource(), ref.getVersion(), ref - // .getAccessionId())); // don't copy map over. - // // if (map.getTo().getName().startsWith(prid)) - // productMapped = true; - // } - // else - // { + if (mappingUsed) + { /* - * an alternate UNIPROT product for CDS - same mapping - * but to a sequence with a different name + * two or more Uniprot xrefs for the same CDS - + * each needs a distinct Mapping (as to a different sequence) */ - SequenceI newSeq = matcher.findIdMatch(refSeqName); - if (newSeq == null) - { - newSeq = new Sequence(refSeqName, map.getTo() + map = new Mapping(map); + } + mappingUsed = true; + + /* + * try to locate the protein mapped to (possibly by a + * previous CDS feature) + */ + SequenceI proteinSeq = matcher.findIdMatch(proteinSeqName); + if (proteinSeq == null) + { + proteinSeq = new Sequence(proteinSeqName, + product .getSequenceAsString()); - matcher.add(newSeq); - peptides.add(newSeq); - } - Mapping newMap = new Mapping(newSeq, map.getMap()); - ref.setMap(newMap); - // } + matcher.add(proteinSeq); + peptides.add(proteinSeq); + } + map.setTo(proteinSeq); + map.getTo().addDBRef( + new DBRefEntry(ref.getSource(), ref.getVersion(), ref + .getAccessionId())); + ref.setMap(map); } noProteinDbref = false; } -- 1.7.10.2