package jalview.ext.ensembl;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefSource;
import java.io.BufferedReader;
import java.io.IOException;
{
/*
- * cached results of REST /info/divisions service, currently
- * <pre>
- * {
- * { "ENSEMBLFUNGI", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLBACTERIA", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLPROTISTS", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLMETAZOA", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLPLANTS", "http://rest.ensemblgenomes.org"},
+ * cached upper-cased results of REST /info/divisions service,
+ * currently (from April 2019)
+ * { "ENSEMBLFUNGI", "http://rest.ensembl.org",
+ * "ENSEMBLBACTERIA", "http://rest.ensembl.org",
+ * "ENSEMBLPROTISTS", "http://rest.ensembl.org",
+ * "ENSEMBLMETAZOA", "http://rest.ensembl.org",
+ * "ENSEMBLPLANTS", "http://rest.ensembl.org",
* "ENSEMBL", "http://rest.ensembl.org" }
* }
- * </pre>
- * The values for EnsemblGenomes are retrieved by a REST call, that for
- * Ensembl is added programmatically for convenience of lookup
*/
private static Map<String, String> divisions;
+ /**
+ * Constructor
+ */
+ public EnsemblInfo()
+ {
+ super();
+ }
+
@Override
public String getDbName()
{
return true;
}
- @Override
- protected String getRequestMimeType(boolean multipleIds)
- {
- return "application/json";
- }
-
- @Override
- protected String getResponseMimeType()
- {
- return "application/json";
- }
-
/**
- * Answers the domain (http://rest.ensembl.org or
- * http://rest.ensemblgenomes.org) for the given division, or null if not
- * recognised by Ensembl.
+ * Answers the domain (e.g. http://rest.ensembl.org) for the given division,
+ * or null if not recognised by Ensembl
*
* @param division
* @return
/**
* On first request only, populate the lookup map by fetching the list of
- * divisions known to EnsemblGenomes.
+ * divisions known to Ensembl
*/
void fetchDivisions()
{
divisions = new HashMap<>();
- /*
- * for convenience, pre-fill ensembl.org as the domain for "ENSEMBL"
- */
- divisions.put(DBRefSource.ENSEMBL.toUpperCase(), ensemblDomain);
-
BufferedReader br = null;
try
{
- URL url = getDivisionsUrl(ensemblGenomesDomain);
+ URL url = getDivisionsUrl();
if (url != null)
{
br = getHttpResponse(url, null);
}
- parseResponse(br, ensemblGenomesDomain);
+ parseResponse(br);
} catch (IOException e)
{
// ignore
* Parses the JSON response to /info/divisions, and add each to the lookup map
*
* @param br
- * @param domain
*/
- void parseResponse(BufferedReader br, String domain)
+ void parseResponse(BufferedReader br)
{
JSONParser jp = new JSONParser();
try
{
JSONArray parsed = (JSONArray) jp.parse(br);
+ String domain = getDomain();
Iterator rvals = parsed.iterator();
while (rvals.hasNext())
}
/**
- * Constructs the URL for the EnsemblGenomes /info/divisions REST service
- * @param domain TODO
+ * Constructs the URL for the Ensembl /info/divisions REST service
*
* @return
* @throws MalformedURLException
*/
- URL getDivisionsUrl(String domain) throws MalformedURLException
+ URL getDivisionsUrl() throws MalformedURLException
{
- return new URL(domain
+ return new URL(
+ getDomain()
+ "/info/divisions?content-type=application/json");
}
/**
- * Returns the set of 'divisions' recognised by Ensembl or EnsemblGenomes
+ * Returns the set of 'divisions' recognised by Ensembl
*
* @return
*/