X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblXref.java;h=c0b00b182f8fc528974dff004831e33607c82f4d;hb=defcce0ef74ffc0923b4387bcb5f0d867bf64831;hp=7b5f9da09ff9d4b3ddc783d7b1c04bd732587dfc;hpb=b40bbf24867e2f44c40e9af6cf43bdfee29c337c;p=jalview.git
diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java
index 7b5f9da..c0b00b1 100644
--- a/src/jalview/ext/ensembl/EnsemblXref.java
+++ b/src/jalview/ext/ensembl/EnsemblXref.java
@@ -1,3 +1,23 @@
+/*
+ * 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;
@@ -27,20 +47,27 @@ import org.json.simple.parser.ParseException;
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
@@ -77,17 +104,14 @@ class EnsemblXref extends EnsemblRestClient
* Calls the Ensembl xrefs REST endpoint and retrieves any cross-references
* ("primary_id") for the given identifier (Ensembl accession id) and database
* names. The "dbname" returned by Ensembl is canonicalised to Jalview's
- * standard version, and a DBRefEntry constructed. If no databases are
- * specified, all available cross-references are retrieved.
+ * standard version, and a DBRefEntry constructed. Currently takes all
+ * identifiers apart from GO terms and synonyms.
*
* @param identifier
* an Ensembl stable identifier
- * @param databases
- * optional list of Ensembl cross-referenced databases of interest
* @return
*/
- public List getCrossReferences(String identifier,
- List databases)
+ public List getCrossReferences(String identifier)
{
List result = new ArrayList();
List ids = new ArrayList();
@@ -101,7 +125,7 @@ class EnsemblXref extends EnsemblRestClient
{
br = getHttpResponse(url, ids);
}
- return (parseResponse(br, databases));
+ return (parseResponse(br));
} catch (IOException e)
{
// ignore
@@ -124,17 +148,15 @@ class EnsemblXref extends EnsemblRestClient
/**
* Parses "primary_id" and "dbname" values from the JSON response and
- * constructs a DBRefEntry if the dbname is in the list supplied. Returns a
- * list of the DBRefEntry created. Note we don't parse "synonyms" as they
- * appear to be either redirected or obsolete in Uniprot.
+ * constructs a DBRefEntry. Returns a list of the DBRefEntry created. Note we
+ * don't parse "synonyms" as they appear to be either redirected or obsolete
+ * in Uniprot.
*
* @param br
- * @param databases
* @return
* @throws IOException
*/
- protected List parseResponse(BufferedReader br,
- List databases)
+ protected List parseResponse(BufferedReader br)
throws IOException
{
JSONParser jp = new JSONParser();
@@ -147,8 +169,7 @@ class EnsemblXref extends EnsemblRestClient
{
JSONObject val = (JSONObject) rvals.next();
String dbName = val.get("dbname").toString();
- if (databases != null && !databases.isEmpty()
- && !databases.contains(dbName))
+ if (dbName.equals(GO_GENE_ONTOLOGY))
{
continue;
}
@@ -156,7 +177,7 @@ class EnsemblXref extends EnsemblRestClient
if (dbName != null && id != null)
{
dbName = DBRefUtils.getCanonicalName(dbName);
- DBRefEntry dbref = new DBRefEntry(dbName, "0", id);
+ DBRefEntry dbref = new DBRefEntry(dbName, getXRefVersion(), id);
result.add(dbref);
}
}
@@ -167,6 +188,18 @@ class EnsemblXref extends EnsemblRestClient
return result;
}
+ private String xrefVersion = "ENSEMBL:0";
+
+ /**
+ * version string for Xrefs - for 2.10, hardwired for ENSEMBL:0
+ *
+ * @return
+ */
+ public String getXRefVersion()
+ {
+ return xrefVersion;
+ }
+
/**
* Returns the URL for the REST endpoint to fetch all cross-references for an
* identifier. Note this may return protein cross-references for nucleotide.