X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblLookup.java;h=f6b3a47b6c07e73a55d474db4a9bb22b6b85d1e7;hb=321caefc5a40cd735c93e0bfa450e0e04abc485d;hp=0d1b5540c9728a4fbb47f71ff5aa3c5f2307344f;hpb=14b1b2a878190d5fffda298c4b9a901c72c74ad3;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index 0d1b554..f6b3a47 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -32,14 +32,15 @@ import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.function.Function; 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); @@ -128,20 +130,15 @@ public class EnsemblLookup extends EnsemblRestClient } /** - * Calls the Ensembl lookup REST endpoint and returns - *