JAL-3066 Automatically discoverable Protein sequence analysis services
[jalview.git] / src / jalview / ext / ensembl / EnsemblFeatures.java
index 9a45dda..99ebc69 100644 (file)
@@ -130,6 +130,7 @@ class EnsemblFeatures extends EnsemblRestClient
           int end = Integer.parseInt(obj.get("end").toString());
           String source = obj.get("source").toString();
           String strand = obj.get("strand").toString();
+          Object phase = obj.get("phase");
           String alleles = JSONUtils
                   .arrayToList((JSONArray) obj.get("alleles"));
           String clinSig = JSONUtils
@@ -155,6 +156,10 @@ class EnsemblFeatures extends EnsemblRestClient
           SequenceFeature sf = new SequenceFeature(type, desc, start, end,
                   source);
           sf.setStrand("1".equals(strand) ? "+" : "-");
+          if (phase != null)
+          {
+            sf.setPhase(phase.toString());
+          }
           setFeatureAttribute(sf, obj, "id");
           setFeatureAttribute(sf, obj, "Parent");
           setFeatureAttribute(sf, obj, "consequence_type");
@@ -176,7 +181,9 @@ class EnsemblFeatures extends EnsemblRestClient
   }
 
   /**
-   * Returns the first non-null attribute found (if any) as a string
+   * Returns the first non-null attribute found (if any) as a string, formatted
+   * suitably for display as feature description or tooltip. Answers null if
+   * none of the attribute keys is present.
    * 
    * @param obj
    * @param keys
@@ -191,7 +198,9 @@ class EnsemblFeatures extends EnsemblRestClient
       Object val = obj.get(key);
       if (val != null)
       {
-        String s = val.toString();
+        String s = val instanceof JSONArray
+                ? JSONUtils.arrayToList((JSONArray) val)
+                : val.toString();
         if (!s.isEmpty())
         {
           return s;