JAL-1705 fetch Uniprot and PDB xrefs for Ensembl protein products
[jalview.git] / src / jalview / ext / ensembl / EnsemblSeqProxy.java
index cbeaae9..8698b78 100644 (file)
@@ -265,6 +265,8 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
       proteinSeq.createDatasetSequence();
       querySeq.createDatasetSequence();
 
+      getProteinCrossReferences(proteinSeq);
+
       MapList mapList = mapCdsToProtein(querySeq, proteinSeq);
       if (mapList != null)
       {
@@ -288,6 +290,29 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
   }
 
   /**
+   * Get Uniprot and PDB xrefs from Ensembl, and attach them to the protein
+   * sequence
+   * 
+   * @param proteinSeq
+   */
+  protected void getProteinCrossReferences(SequenceI proteinSeq)
+  {
+    while (proteinSeq.getDatasetSequence() != null)
+    {
+      proteinSeq = proteinSeq.getDatasetSequence();
+    }
+
+    EnsemblXref xrefFetcher = new EnsemblXref();
+    List<DBRefEntry> xrefs = xrefFetcher.getCrossReferences(
+            proteinSeq.getName(), "PDB", "Uniprot/SPTREMBL",
+            "Uniprot/SWISSPROT");
+    for (DBRefEntry xref : xrefs)
+    {
+      proteinSeq.addDBRef(xref);
+    }
+  }
+
+  /**
    * Returns a mapping from dna to protein by inspecting sequence features of
    * type "CDS" on the dna.
    *