JAL-1705 parse 'description' from GFF as sequence description
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 4 Mar 2016 09:58:42 +0000 (09:58 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 4 Mar 2016 09:58:42 +0000 (09:58 +0000)
src/jalview/ext/ensembl/EnsemblGene.java
src/jalview/ext/ensembl/EnsemblSeqProxy.java

index cec7a8d..aa5e0ab 100644 (file)
@@ -14,6 +14,8 @@ import jalview.util.MapList;
 import jalview.util.StringUtils;
 
 import java.awt.Color;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -292,10 +294,25 @@ public class EnsemblGene extends EnsemblSeqProxy
     }
 
     Sequence transcript = new Sequence(accId, seqChars, 1, transcriptLength);
-    String geneName = (String) transcriptFeature.getValue(NAME);
-    if (geneName != null)
+
+    /*
+     * Ensembl has gene name as transcript Name
+     * EnsemblGenomes doesn't, but has a url-encoded description field
+     */
+    String description = (String) transcriptFeature.getValue(NAME);
+    if (description == null)
+    {
+      description = (String) transcriptFeature.getValue(DESCRIPTION);
+    }
+    if (description != null)
     {
-      transcript.setDescription(geneName);
+      try
+      {
+        transcript.setDescription(URLDecoder.decode(description, "UTF-8"));
+      } catch (UnsupportedEncodingException e)
+      {
+        e.printStackTrace(); // as if
+      }
     }
     transcript.createDatasetSequence();
 
index a878784..5e27158 100644 (file)
@@ -49,6 +49,8 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
 
   protected static final String NAME = "Name";
 
+  protected static final String DESCRIPTION = "description";
+
   /*
    * enum for 'type' parameter to the /sequence REST service
    */