From: Jim Procter Date: Thu, 25 Aug 2016 19:55:19 +0000 (+0100) Subject: JAL-2106 JAL-2154 cross-refs from Ensembl should verify as cross refs only X-Git-Tag: Release_2_10_0~47^2~4^2~43^2~11 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=76de4fc452184b56e01960d05cb2235b1807e836;p=jalview.git JAL-2106 JAL-2154 cross-refs from Ensembl should verify as cross refs only --- diff --git a/src/jalview/ext/ensembl/EnsemblGene.java b/src/jalview/ext/ensembl/EnsemblGene.java index b4d2783..50e1032 100644 --- a/src/jalview/ext/ensembl/EnsemblGene.java +++ b/src/jalview/ext/ensembl/EnsemblGene.java @@ -174,7 +174,8 @@ public class EnsemblGene extends EnsemblSeqProxy */ else { - List ids = new EnsemblSymbol(getDomain()).getIds(acc); + List ids = new EnsemblSymbol(getDomain(), getDbSource(), + getDbVersion()).getIds(acc); for (String geneId : ids) { if (!geneIds.contains(geneId)) @@ -196,7 +197,8 @@ public class EnsemblGene extends EnsemblSeqProxy */ protected String getGeneIdentifiersForName(String query) { - List ids = new EnsemblSymbol(getDomain()).getIds(query); + List ids = new EnsemblSymbol(getDomain(), getDbSource(), + getDbVersion()).getIds(query); if (ids != null) { for (String id : ids) diff --git a/src/jalview/ext/ensembl/EnsemblSeqProxy.java b/src/jalview/ext/ensembl/EnsemblSeqProxy.java index e44b610..5a32736 100644 --- a/src/jalview/ext/ensembl/EnsemblSeqProxy.java +++ b/src/jalview/ext/ensembl/EnsemblSeqProxy.java @@ -308,7 +308,8 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient seq = seq.getDatasetSequence(); } - EnsemblXref xrefFetcher = new EnsemblXref(getDomain()); + EnsemblXref xrefFetcher = new EnsemblXref(getDomain(), getDbSource(), + getEnsemblDataVersion()); List xrefs = xrefFetcher.getCrossReferences(seq.getName()); for (DBRefEntry xref : xrefs) { diff --git a/src/jalview/ext/ensembl/EnsemblSymbol.java b/src/jalview/ext/ensembl/EnsemblSymbol.java index 1c47f11..b8c8c54 100644 --- a/src/jalview/ext/ensembl/EnsemblSymbol.java +++ b/src/jalview/ext/ensembl/EnsemblSymbol.java @@ -25,11 +25,13 @@ public class EnsemblSymbol extends EnsemblXref /** * Constructor given the target domain to fetch data from * - * @param d + * @param domain + * @param dbName + * @param dbVersion */ - public EnsemblSymbol(String d) + public EnsemblSymbol(String domain, String dbName, String dbVersion) { - super(d); + super(domain, dbName, dbVersion); } /** diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java index fa86865..313572f 100644 --- a/src/jalview/ext/ensembl/EnsemblXref.java +++ b/src/jalview/ext/ensembl/EnsemblXref.java @@ -29,20 +29,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 @@ -152,7 +157,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); } } @@ -163,6 +168,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. diff --git a/test/jalview/ext/ensembl/EnsemblXrefTest.java b/test/jalview/ext/ensembl/EnsemblXrefTest.java index 1dc9b8d..4dc8ab2 100644 --- a/test/jalview/ext/ensembl/EnsemblXrefTest.java +++ b/test/jalview/ext/ensembl/EnsemblXrefTest.java @@ -1,6 +1,7 @@ package jalview.ext.ensembl; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; import jalview.datamodel.DBRefEntry; @@ -24,8 +25,11 @@ public class EnsemblXrefTest @Test(groups = "Functional") public void testGetCrossReferences() { + String dbName = "ENSEMBL"; + String dbVers = "0.6.2b1"; System.out.println(JSON); - EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org") + EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName, + dbVers) { @Override protected BufferedReader getHttpResponse(URL url, List ids) @@ -40,8 +44,12 @@ public class EnsemblXrefTest assertEquals(2, dbrefs.size()); assertEquals("CCDS", dbrefs.get(0).getSource()); assertEquals("CCDS5863", dbrefs.get(0).getAccessionId()); + assertFalse(dbrefs.get(0).isPrimary()); + assertEquals(dbName + ":" + dbVers, dbrefs.get(0).getVersion()); // Uniprot name should get converted to Jalview canonical form assertEquals("UNIPROT", dbrefs.get(1).getSource()); assertEquals("P15056", dbrefs.get(1).getAccessionId()); + assertEquals(dbName + ":" + dbVers, dbrefs.get(1).getVersion()); + assertFalse(dbrefs.get(1).isPrimary()); } }