X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblLookup.java;h=3dca1b72267af2a857a67cf928d723c40205cc10;hb=cb8e52fbbc5f725e3f7f48c672cdddb0690bd978;hp=0d1b5540c9728a4fbb47f71ff5aa3c5f2307344f;hpb=14193747f3831242bc7dfac12394eb20eb0ba480;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index 0d1b554..3dca1b7 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -20,26 +20,27 @@ */ 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.BufferedReader; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.function.Function; +import java.util.Map; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; /** - * A client for the Ensembl lookup REST endpoint + * A client for the Ensembl /lookup REST endpoint, used to find the gene + * identifier given a gene, transcript or protein identifier, or to extract the + * species or chromosomal coordinates from the same service response * * @author gmcarstairs */ @@ -47,14 +48,6 @@ public class EnsemblLookup extends EnsemblRestClient { private static final String SPECIES = "species"; - private static final String PARENT = "Parent"; - - private static final String OBJECT_TYPE_TRANSLATION = "Translation"; - private static final String OBJECT_TYPE_TRANSCRIPT = "Transcript"; - private static final String ID = "id"; - private static final String OBJECT_TYPE_GENE = "Gene"; - private static final String OBJECT_TYPE = "object_type"; - /** * Default constructor (to use rest.ensembl.org) */ @@ -89,17 +82,26 @@ public class EnsemblLookup extends EnsemblRestClient protected URL getUrl(List ids) throws MalformedURLException { String identifier = ids.get(0); - return getUrl(identifier); + return getUrl(identifier, null); } /** + * Gets the url for lookup of the given identifier, optionally with objectType + * also specified in the request + * * @param identifier + * @param objectType * @return */ - protected URL getUrl(String identifier) + protected URL getUrl(String identifier, String objectType) { String url = getDomain() + "/lookup/id/" + identifier + CONTENT_TYPE_JSON; + if (objectType != null) + { + url += "&" + OBJECT_TYPE + "=" + objectType; + } + try { return new URL(url); @@ -115,158 +117,114 @@ public class EnsemblLookup extends EnsemblRestClient return true; } - @Override - protected String getRequestMimeType(boolean multipleIds) - { - return "application/json"; - } - - @Override - protected String getResponseMimeType() - { - return "application/json"; - } - /** - * Calls the Ensembl lookup REST endpoint and returns - *