*/
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;
}
/**
- * 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
* @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;
}
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;