JAL-3193 removal of rest.ensemblgenomes.org
[jalview.git] / src / jalview / ext / ensembl / EnsemblFeatures.java
index a133381..859251b 100644 (file)
@@ -26,6 +26,7 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.io.gff.SequenceOntologyI;
+import jalview.util.JSONUtils;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -64,16 +65,6 @@ class EnsemblFeatures extends EnsemblRestClient
     super();
   }
 
-  /**
-   * Constructor given the target domain to fetch data from
-   * 
-   * @param d
-   */
-  public EnsemblFeatures(String d)
-  {
-    super(d);
-  }
-
   @Override
   public String getDbName()
   {
@@ -129,15 +120,11 @@ 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 value = obj.get("consequence_type");
-          value = obj.get("alleles");
-          JSONArray allelesArray = (JSONArray) value;
-          String alleles = allelesArray == null ? null
-                  : allelesArray.toString(); // todo need as a List?
-          value = obj.get("clinical_significance");
-          JSONArray clinSigArray = (JSONArray) value;
-          String clinSig = clinSigArray == null ? null
-                  : clinSigArray.toString();
+          String alleles = JSONUtils
+                  .arrayToList((JSONArray) obj.get("alleles"));
+          String clinSig = JSONUtils
+                  .arrayToList(
+                          (JSONArray) obj.get("clinical_significance"));
 
           /*
            * convert 'variation' to 'sequence_variant', and 'cds' to 'CDS'
@@ -179,7 +166,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
@@ -194,7 +183,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;