JAL-2232 extract EMBLCDS refs from EMBL refs on Uniprot XML.
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index 81b4caf..de70aab 100644 (file)
@@ -30,6 +30,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.UniprotEntry;
 import jalview.datamodel.UniprotFile;
+import jalview.util.DBRefUtils;
 import jalview.ws.ebi.EBIFetchClient;
 import jalview.ws.seqfetcher.DbSourceProxyImpl;
 
@@ -222,6 +223,19 @@ public class Uniprot extends DbSourceProxyImpl
       {
         onlyPdbEntries.addElement(pdb);
       }
+      if ("EMBL".equals(pdb.getType()))
+      {
+        // look for a CDS reference and add it, too.
+        String cdsId = (String) pdb.getProperty()
+                .get("protein sequence ID");
+        if (cdsId != null && cdsId.trim().length() > 0)
+        {
+          dbr = new DBRefEntry(DBRefSource.EMBLCDS, DBRefSource.UNIPROT
+                  + ":"
+                  + dbVersion, cdsId.trim());
+          dbRefs.add(dbr);
+        }
+      }
     }
 
     sequence.setPDBId(onlyPdbEntries);
@@ -233,7 +247,12 @@ public class Uniprot extends DbSourceProxyImpl
         sequence.addSequenceFeature(sf);
       }
     }
+    // we use setDBRefs to assign refs quickly.
     sequence.setDBRefs(dbRefs.toArray(new DBRefEntry[0]));
+    // need to use ensurePrimaries to reify any refs that should become primary
+    // refs
+    DBRefUtils.ensurePrimaries(sequence); // promote any direct refs to primary
+                                          // source dbs
     return sequence;
   }