Merge branch 'develop' into task/JAL-2196pdbeProperties
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index de70aab..caed598 100644 (file)
@@ -30,7 +30,6 @@ 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;
 
@@ -226,16 +225,35 @@ public class Uniprot extends DbSourceProxyImpl
       if ("EMBL".equals(pdb.getType()))
       {
         // look for a CDS reference and add it, too.
-        String cdsId = (String) pdb.getProperty()
-                .get("protein sequence ID");
+        String cdsId = (String) pdb.getProperty("protein sequence ID");
         if (cdsId != null && cdsId.trim().length() > 0)
         {
-          dbr = new DBRefEntry(DBRefSource.EMBLCDS, DBRefSource.UNIPROT
-                  + ":"
-                  + dbVersion, cdsId.trim());
+          // remove version
+          String[] vrs = cdsId.split("\\.");
+          dbr = new DBRefEntry(DBRefSource.EMBLCDS, vrs.length > 1 ? vrs[1]
+                  : DBRefSource.UNIPROT + ":" + dbVersion, vrs[0]);
           dbRefs.add(dbr);
         }
       }
+      if ("Ensembl".equals(pdb.getType()))
+      {
+        /*UniprotXML
+         * <dbReference type="Ensembl" id="ENST00000321556">
+        * <molecule id="Q9BXM7-1"/>
+        * <property type="protein sequence ID" value="ENSP00000364204"/>
+        * <property type="gene ID" value="ENSG00000158828"/>
+        * </dbReference> 
+         */
+        String cdsId = (String) pdb.getProperty("protein sequence ID");
+        if (cdsId != null && cdsId.trim().length() > 0)
+        {
+          dbr = new DBRefEntry(DBRefSource.ENSEMBL, DBRefSource.UNIPROT
+                  + ":" + dbVersion, cdsId.trim());
+          dbRefs.add(dbr);
+
+        }
+      }
+
     }
 
     sequence.setPDBId(onlyPdbEntries);
@@ -247,12 +265,10 @@ 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
+    for (DBRefEntry dbr : dbRefs)
+    {
+      sequence.addDBRef(dbr);
+    }
     return sequence;
   }