JAL-2446 merged to spike branch
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index e26ccda..7261cba 100644 (file)
@@ -28,8 +28,9 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
-import jalview.datamodel.UniprotEntry;
-import jalview.datamodel.UniprotFile;
+import jalview.datamodel.xdb.uniprot.UniprotEntry;
+import jalview.datamodel.xdb.uniprot.UniprotFeature;
+import jalview.datamodel.xdb.uniprot.UniprotFile;
 import jalview.ws.ebi.EBIFetchClient;
 import jalview.ws.seqfetcher.DbSourceProxyImpl;
 
@@ -165,7 +166,7 @@ public class Uniprot extends DbSourceProxyImpl
       // uniprotxml parameter required since december 2007
       // uniprotkb dbname changed introduced december 2008
       File file = ebi.fetchDataAsFile("uniprotkb:" + queries, "uniprotxml",
-              ".xml");
+              "xml");
       Vector<UniprotEntry> entries = getUniprotEntries(new FileReader(file));
 
       if (entries != null)
@@ -193,7 +194,8 @@ public class Uniprot extends DbSourceProxyImpl
    *          UniprotEntry
    * @return SequenceI instance created from the UniprotEntry instance
    */
-  public SequenceI uniprotEntryToSequenceI(UniprotEntry entry){
+  public SequenceI uniprotEntryToSequenceI(UniprotEntry entry)
+  {
     String id = getUniprotEntryId(entry);
     SequenceI sequence = new Sequence(id, entry.getUniprotSequence()
             .getContent());
@@ -225,8 +227,7 @@ 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)
         {
           // remove version
@@ -236,7 +237,7 @@ public class Uniprot extends DbSourceProxyImpl
           dbRefs.add(dbr);
         }
       }
-      if (false) // "Ensembl".equals(pdb.getType()))
+      if ("Ensembl".equals(pdb.getType()))
       {
         /*UniprotXML
          * <dbReference type="Ensembl" id="ENST00000321556">
@@ -245,36 +246,32 @@ public class Uniprot extends DbSourceProxyImpl
         * <property type="gene ID" value="ENSG00000158828"/>
         * </dbReference> 
          */
-        String cdsId = (String) pdb.getProperty()
-                .get("protein sequence ID");
+        String cdsId = (String) pdb.getProperty("protein sequence ID");
         if (cdsId != null && cdsId.trim().length() > 0)
         {
-          // Only add the product ID
-          dbRefs.remove(dbr);
           dbr = new DBRefEntry(DBRefSource.ENSEMBL, DBRefSource.UNIPROT
                   + ":" + dbVersion, cdsId.trim());
           dbRefs.add(dbr);
 
         }
       }
-
     }
 
     sequence.setPDBId(onlyPdbEntries);
     if (entry.getFeature() != null)
     {
-      for (SequenceFeature sf : entry.getFeature())
+      for (UniprotFeature uf : entry.getFeature())
       {
-        sf.setFeatureGroup("Uniprot");
-        sequence.addSequenceFeature(sf);
+        SequenceFeature copy = new SequenceFeature(uf.getType(),
+                uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot");
+        copy.setStatus(uf.getStatus());
+        sequence.addSequenceFeature(copy);
       }
     }
-    // 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;
   }