X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblXref.java;h=714a5c011120801f85cd571dab9af79be73fff13;hb=c0501eaa85c0594f9275766f64de8ea44a59c368;hp=fa868659366e42e9ee8b41bfdcafe92c085025c8;hpb=a61896507a80dd6dcafaee02a872678022afe943;p=jalview.git
diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java
index fa86865..714a5c0 100644
--- a/src/jalview/ext/ensembl/EnsemblXref.java
+++ b/src/jalview/ext/ensembl/EnsemblXref.java
@@ -1,22 +1,39 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.ensembl;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefEntry;
-import jalview.util.DBRefUtils;
-
-import java.io.BufferedReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
+import jalview.util.DBRefUtils;
+
/**
* A class to fetch cross-references from Ensembl by calling the /xrefs REST
* service
@@ -29,20 +46,25 @@ class EnsemblXref extends EnsemblRestClient
private static final String GO_GENE_ONTOLOGY = "GO";
+ private String dbName = "ENSEMBL (xref)";
+
/**
* Constructor given the target domain to fetch data from
*
* @param d
*/
- public EnsemblXref(String d)
+ public EnsemblXref(String d, String dbSource, String version)
{
super(d);
+ dbName = dbSource;
+ xrefVersion = dbSource + ":" + version;
+
}
@Override
public String getDbName()
{
- return "ENSEMBL (xref)";
+ return dbName;
}
@Override
@@ -63,18 +85,6 @@ class EnsemblXref extends EnsemblRestClient
return true;
}
- @Override
- protected String getRequestMimeType(boolean multipleIds)
- {
- return "application/json";
- }
-
- @Override
- protected String getResponseMimeType()
- {
- return "application/json";
- }
-
/**
* Calls the Ensembl xrefs REST endpoint and retrieves any cross-references
* ("primary_id") for the given identifier (Ensembl accession id) and database
@@ -86,81 +96,64 @@ class EnsemblXref extends EnsemblRestClient
* an Ensembl stable identifier
* @return
*/
+ @SuppressWarnings("unchecked")
public List getCrossReferences(String identifier)
{
- List result = new ArrayList();
- List ids = new ArrayList();
+ List result = new ArrayList<>();
+ List ids = new ArrayList<>();
ids.add(identifier);
- BufferedReader br = null;
try
{
- URL url = getUrl(identifier);
- if (url != null)
- {
- br = getHttpResponse(url, ids);
- }
- return (parseResponse(br));
- } catch (IOException e)
- {
- // ignore
- } finally
- {
- if (br != null)
+ Iterator