Merge branch 'develop' into spike/JAL-4047/JAL-4048_columns_in_sequenceID
[jalview.git] / src / jalview / ext / ensembl / EnsemblLookup.java
index fc37b8a..e188986 100644 (file)
  */
 package jalview.ext.ensembl;
 
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.GeneLociI;
+import jalview.datamodel.GeneLocus;
+import jalview.datamodel.Mapping;
 import jalview.util.MapList;
 
 import java.io.IOException;
@@ -200,8 +202,8 @@ public class EnsemblLookup extends EnsemblRestClient
   }
 
   /**
-   * Calls the /lookup/id rest service and returns the response as a Map<String, Object>,
-   * or null if any error
+   * Calls the /lookup/id rest service and returns the response as a Map<String,
+   * Object>, or null if any error
    * 
    * @param identifier
    * @param objectType
@@ -209,17 +211,18 @@ public class EnsemblLookup extends EnsemblRestClient
    * @return
    */
   @SuppressWarnings("unchecked")
-  protected Map<String, Object> getResult(String identifier, String objectType)
+  protected Map<String, Object> getResult(String identifier,
+          String objectType)
   {
     List<String> ids = Arrays.asList(new String[] { identifier });
 
     try
     {
-      return (Map<String, Object>) getJSON(getUrl(identifier, objectType), ids, -1, MODE_MAP, null);
-    } 
-    catch (IOException | ParseException e)
+      return (Map<String, Object>) getJSON(getUrl(identifier, objectType),
+              ids, -1, MODE_MAP, null);
+    } catch (IOException | ParseException e)
     {
-      System.err.println("Error parsing " + identifier + " lookup response "
+      jalview.bin.Console.errPrintln("Error parsing " + identifier + " lookup response "
               + e.getMessage());
       return null;
     }
@@ -264,41 +267,19 @@ public class EnsemblLookup extends EnsemblRestClient
       boolean reverseStrand = "-1".equals(strand);
       int toStart = reverseStrand ? end : start;
       int toEnd = reverseStrand ? start : end;
-      List<int[]> fromRange = Collections.singletonList(new int[] { 1,
-          fromEnd });
-      List<int[]> toRange = Collections.singletonList(new int[] { toStart,
-          toEnd });
-      final MapList map = new MapList(fromRange, toRange, 1, 1);
-      return new GeneLociI()
-      {
-
-        @Override
-        public String getSpeciesId()
-        {
-          return species == null ? "" : species;
-        }
-
-        @Override
-        public String getAssemblyId()
-        {
-          return assembly;
-        }
-
-        @Override
-        public String getChromosomeId()
-        {
-          return chromosome;
-        }
-
-        @Override
-        public MapList getMap()
-        {
-          return map;
-        }
-      };
+      List<int[]> fromRange = Collections
+              .singletonList(new int[]
+              { 1, fromEnd });
+      List<int[]> toRange = Collections
+              .singletonList(new int[]
+              { toStart, toEnd });
+      final Mapping map = new Mapping(
+              new MapList(fromRange, toRange, 1, 1));
+      return new GeneLocus(species == null ? "" : species, assembly,
+              chromosome, map);
     } catch (NullPointerException | NumberFormatException e)
     {
-      Cache.log.error("Error looking up gene loci: " + e.getMessage());
+      Console.error("Error looking up gene loci: " + e.getMessage());
       e.printStackTrace();
     }
     return null;