JAL-3397 impl.IntervalStore and nonc.IntervalStore unified api
[jalview.git] / src / jalview / ext / ensembl / EnsemblFeatures.java
index 2772498..e4c4365 100644 (file)
@@ -27,9 +27,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.io.gff.SequenceOntologyI;
 import jalview.util.JSONUtils;
-import jalview.util.Platform;
 
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -95,10 +93,7 @@ class EnsemblFeatures extends EnsemblRestClient
     List<String> queries = new ArrayList<>();
     queries.add(query);
     SequenceI seq = parseFeaturesJson(queries);
-    if (seq == null)
-       return null;
     return new Alignment(new SequenceI[] { seq });
-
   }
 
   /**
@@ -109,18 +104,16 @@ class EnsemblFeatures extends EnsemblRestClient
    * @return
    */
   @SuppressWarnings("unchecked")
-private SequenceI parseFeaturesJson(List<String> queries)
+  private SequenceI parseFeaturesJson(List<String> queries)
   {
-         
-         
     SequenceI seq = new Sequence("Dummy", "");
-
     try
     {
-       
       Iterator<Object> rvals = (Iterator<Object>) getJSON(null, queries, -1, MODE_ITERATOR, null);
       if (rvals == null)
+      {
          return null;
+      }
       while (rvals.hasNext())
       {          
         try
@@ -178,31 +171,33 @@ private SequenceI parseFeaturesJson(List<String> queries)
     return seq;
   }
 
-  
-/**
-   * 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
    * @return
    */
+  @SuppressWarnings("unchecked")
   protected String getFirstNotNull(Map<String, Object> obj, String... keys)
   {
-    String desc = null;
-
     for (String key : keys)
     {
       Object val = obj.get(key);
       if (val != null)
       {
-        String s = val.toString();
+        String s = val instanceof List<?>
+                ? JSONUtils.arrayToStringList((List<Object>) val)
+                : val.toString();
         if (!s.isEmpty())
         {
           return s;
         }
       }
     }
-    return desc;
+    return null;
   }
 
   /**