From f87f3bc59e76f6112821e01ed88cf4c3ed853379 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 16 Jan 2018 12:20:18 +0000 Subject: [PATCH] JAL-2885 uniprot now https, uniprot/ensembl/pfam/xfam configurable --- src/jalview/ext/ensembl/EnsemblGenomes.java | 6 +++- src/jalview/ext/ensembl/EnsemblLookup.java | 9 +++++ src/jalview/ext/ensembl/EnsemblRestClient.java | 35 +++++++++++++------- .../ext/ensembl/EnsemblSequenceFetcher.java | 32 +++++++++++++++--- .../fts/service/uniprot/UniProtFTSRestClient.java | 16 +++++++-- src/jalview/ws/dbsources/Pfam.java | 16 ++++----- src/jalview/ws/dbsources/PfamFull.java | 14 +------- src/jalview/ws/dbsources/PfamSeed.java | 13 +------- src/jalview/ws/dbsources/Rfam.java | 21 ++++++------ src/jalview/ws/dbsources/RfamFull.java | 14 +------- src/jalview/ws/dbsources/RfamSeed.java | 13 +------- src/jalview/ws/dbsources/Uniprot.java | 10 +++++- src/jalview/ws/dbsources/Xfam.java | 13 +++++--- test/jalview/ext/ensembl/EnsemblGeneTest.java | 2 ++ test/jalview/ws/dbsources/PfamFullTest.java | 30 +++++++++++++++++ test/jalview/ws/dbsources/PfamSeedTest.java | 30 +++++++++++++++++ test/jalview/ws/dbsources/RfamFullTest.java | 30 +++++++++++++++++ test/jalview/ws/dbsources/RfamSeedTest.java | 32 ++++++++++++++++++ test/jalview/ws/dbsources/XfamFetcherTest.java | 2 +- 19 files changed, 242 insertions(+), 96 deletions(-) create mode 100644 test/jalview/ws/dbsources/PfamFullTest.java create mode 100644 test/jalview/ws/dbsources/PfamSeedTest.java create mode 100644 test/jalview/ws/dbsources/RfamFullTest.java create mode 100644 test/jalview/ws/dbsources/RfamSeedTest.java diff --git a/src/jalview/ext/ensembl/EnsemblGenomes.java b/src/jalview/ext/ensembl/EnsemblGenomes.java index bbd1f26..6af6d44 100644 --- a/src/jalview/ext/ensembl/EnsemblGenomes.java +++ b/src/jalview/ext/ensembl/EnsemblGenomes.java @@ -20,6 +20,8 @@ */ package jalview.ext.ensembl; +import jalview.bin.Cache; + /** * A class to behave much like EnsemblGene but referencing the ensemblgenomes * domain and data @@ -35,7 +37,9 @@ public class EnsemblGenomes extends EnsemblGene */ public EnsemblGenomes() { - super(ENSEMBL_GENOMES_REST); + super(); + setDomain(Cache.getDefault(ENSEMBL_GENOMES_DOMAIN, + DEFAULT_ENSEMBL_GENOMES_DOMAIN)); } @Override diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index 31da9c0..f31a3f0 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -50,6 +50,8 @@ public class EnsemblLookup extends EnsemblRestClient private static final String OBJECT_TYPE_GENE = "Gene"; private static final String OBJECT_TYPE = "object_type"; + private String lastId; + /** * Default constructor (to use rest.ensembl.org) */ @@ -137,6 +139,13 @@ public class EnsemblLookup extends EnsemblRestClient try { URL url = getUrl(identifier); + if (identifier.equals(lastId)) + { + System.err.println("** Ensembl lookup " + url.toString() + + " looping on Parent!"); + return null; + } + lastId = identifier; if (url != null) { br = getHttpResponse(url, ids); diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index b1bc8e5..d457668 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -72,10 +72,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log"; - private static Map domainData; - - // @see https://github.com/Ensembl/ensembl-rest/wiki/Output-formats - private static final String PING_URL = "http://rest.ensembl.org/info/ping.json"; + private static Map domainData = new HashMap<>(); private final static long AVAILABILITY_RETEST_INTERVAL = 10000L; // 10 seconds @@ -85,11 +82,10 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher static { - domainData = new HashMap<>(); - domainData.put(ENSEMBL_REST, - new EnsemblInfo(ENSEMBL_REST, LATEST_ENSEMBL_REST_VERSION)); - domainData.put(ENSEMBL_GENOMES_REST, new EnsemblInfo( - ENSEMBL_GENOMES_REST, LATEST_ENSEMBLGENOMES_REST_VERSION)); + domainData.put(DEFAULT_ENSEMBL_DOMAIN, + new EnsemblInfo(DEFAULT_ENSEMBL_DOMAIN, LATEST_ENSEMBL_REST_VERSION)); + domainData.put(DEFAULT_ENSEMBL_GENOMES_DOMAIN, new EnsemblInfo( + DEFAULT_ENSEMBL_GENOMES_DOMAIN, LATEST_ENSEMBLGENOMES_REST_VERSION)); } protected volatile boolean inProgress = false; @@ -99,7 +95,21 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher */ public EnsemblRestClient() { - this(ENSEMBL_REST); + super(); + + /* + * initialise domain info lazily + */ + if (!domainData.containsKey(ensemblDomain)) + { + domainData.put(ensemblDomain, + new EnsemblInfo(ensemblDomain, LATEST_ENSEMBL_REST_VERSION)); + } + if (!domainData.containsKey(ensemblGenomesDomain)) + { + domainData.put(ensemblGenomesDomain, new EnsemblInfo( + ensemblGenomesDomain, LATEST_ENSEMBLGENOMES_REST_VERSION)); + } } /** @@ -169,11 +179,12 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher boolean checkEnsembl() { BufferedReader br = null; + String pingUrl = getDomain() + "/info/ping" + CONTENT_TYPE_JSON; try { // note this format works for both ensembl and ensemblgenomes // info/ping.json works for ensembl only (March 2016) - URL ping = new URL(getDomain() + "/info/ping" + CONTENT_TYPE_JSON); + URL ping = new URL(pingUrl); /* * expect {"ping":1} if ok @@ -192,7 +203,7 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher } catch (Throwable t) { System.err.println( - "Error connecting to " + PING_URL + ": " + t.getMessage()); + "Error connecting to " + pingUrl + ": " + t.getMessage()); } finally { if (br != null) diff --git a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java index 598dba1..2f642b5 100644 --- a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java +++ b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java @@ -20,6 +20,7 @@ */ package jalview.ext.ensembl; +import jalview.bin.Cache; import jalview.datamodel.DBRefSource; import jalview.ws.seqfetcher.DbSourceProxyImpl; @@ -32,6 +33,14 @@ import com.stevesoft.pat.Regex; */ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl { + // domain properties lookup keys: + protected static final String ENSEMBL_DOMAIN = "ENSEMBL_DOMAIN"; + protected static final String ENSEMBL_GENOMES_DOMAIN = "ENSEMBL_GENOMES_DOMAIN"; + + // domain properties default values: + protected static final String DEFAULT_ENSEMBL_DOMAIN = "http://rest.ensembl.org"; + protected static final String DEFAULT_ENSEMBL_GENOMES_DOMAIN = "http://rest.ensemblgenomes.org"; + /* * accepts ENSG/T/E/P with 11 digits * or ENSMUSP or similar for other species @@ -41,9 +50,9 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl "(ENS([A-Z]{3}|)[GTEP]{1}[0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)"); - protected static final String ENSEMBL_GENOMES_REST = "http://rest.ensemblgenomes.org"; + protected final String ensemblGenomesDomain; - protected static final String ENSEMBL_REST = "http://rest.ensembl.org"; + protected final String ensemblDomain; /* * possible values for the 'feature' parameter of the /overlap REST service @@ -56,13 +65,28 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl constrained, regulatory } - private String domain = ENSEMBL_REST; + private String domain; + + /** + * Constructor + */ + public EnsemblSequenceFetcher() + { + /* + * the default domain names may be overridden in .jalview_properties; + * this allows an easy change from http to https in future if needed + */ + ensemblDomain = Cache.getDefault(ENSEMBL_DOMAIN, DEFAULT_ENSEMBL_DOMAIN); + ensemblGenomesDomain = Cache.getDefault(ENSEMBL_GENOMES_DOMAIN, + DEFAULT_ENSEMBL_GENOMES_DOMAIN); + domain = ensemblDomain; + } @Override public String getDbSource() { // NB ensure Uniprot xrefs are canonicalised from "Ensembl" to "ENSEMBL" - if (ENSEMBL_GENOMES_REST.equals(getDomain())) + if (ensemblGenomesDomain.equals(getDomain())) { return DBRefSource.ENSEMBLGENOMES; } diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index 250fba0..262ed86 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -21,6 +21,7 @@ package jalview.fts.service.uniprot; +import jalview.bin.Cache; import jalview.fts.api.FTSData; import jalview.fts.api.FTSDataColumnI; import jalview.fts.api.FTSRestClientI; @@ -44,9 +45,18 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; public class UniProtFTSRestClient extends FTSRestClient { + private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org"; + private static FTSRestClientI instance = null; - public static final String UNIPROT_SEARCH_ENDPOINT = "http://www.uniprot.org/uniprot/?"; + public final String uniprotSearchEndpoint; + + public UniProtFTSRestClient() + { + super(); + uniprotSearchEndpoint = Cache.getDefault("UNIPROT_DOMAIN", + DEFAULT_UNIPROT_DOMAIN) + "/uniprot/?"; + } @Override public FTSRestResponse executeRequest(FTSRestRequest uniportRestRequest) @@ -81,7 +91,7 @@ public class UniProtFTSRestClient extends FTSRestClient } WebResource webResource = null; - webResource = client.resource(UNIPROT_SEARCH_ENDPOINT) + webResource = client.resource(uniprotSearchEndpoint) .queryParam("format", "tab") .queryParam("columns", wantedFields) .queryParam("limit", String.valueOf(responseSize)) @@ -158,7 +168,7 @@ public class UniProtFTSRestClient extends FTSRestClient String[] foundDataRow = uniProtTabDelimittedResponseString.split("\n"); if (foundDataRow != null && foundDataRow.length > 0) { - result = new ArrayList(); + result = new ArrayList<>(); boolean firstRow = true; for (String dataRow : foundDataRow) { diff --git a/src/jalview/ws/dbsources/Pfam.java b/src/jalview/ws/dbsources/Pfam.java index 0227e35..6cec4ef 100644 --- a/src/jalview/ws/dbsources/Pfam.java +++ b/src/jalview/ws/dbsources/Pfam.java @@ -20,6 +20,7 @@ */ package jalview.ws.dbsources; +import jalview.bin.Cache; import jalview.datamodel.DBRefSource; import com.stevesoft.pat.Regex; @@ -34,6 +35,8 @@ import com.stevesoft.pat.Regex; */ abstract public class Pfam extends Xfam { + private static final String PFAM_DOMAIN_KEY = "PFAM_DOMAIN"; + private static final String DEFAULT_PFAM_DOMAIN = "http://pfam.xfam.org"; public Pfam() { @@ -48,7 +51,6 @@ abstract public class Pfam extends Xfam @Override public String getAccessionSeparator() { - // TODO Auto-generated method stub return null; } @@ -60,7 +62,6 @@ abstract public class Pfam extends Xfam @Override public Regex getAccessionValidator() { - // TODO Auto-generated method stub return null; } @@ -91,17 +92,14 @@ abstract public class Pfam extends Xfam @Override public String getDbVersion() { - // TODO Auto-generated method stub return null; } - /** - * Returns base URL for selected Pfam alignment type - * - * @return PFAM URL stub for this DbSource - */ @Override - protected abstract String getXFAMURL(); + protected String getDomain() + { + return Cache.getDefault(PFAM_DOMAIN_KEY, DEFAULT_PFAM_DOMAIN); + } /* * (non-Javadoc) diff --git a/src/jalview/ws/dbsources/PfamFull.java b/src/jalview/ws/dbsources/PfamFull.java index ec9fcbb..0600427 100644 --- a/src/jalview/ws/dbsources/PfamFull.java +++ b/src/jalview/ws/dbsources/PfamFull.java @@ -31,20 +31,8 @@ public class PfamFull extends Pfam super(); } - /* - * (non-Javadoc) - * - * @see jalview.ws.dbsources.Pfam#getPFAMURL() - */ - @Override - protected String getXFAMURL() - { - return "http://pfam.xfam.org/family/"; - - } - @Override - public String getXFAMURLSUFFIX() + public String getURLSuffix() { return "/alignment/full"; } diff --git a/src/jalview/ws/dbsources/PfamSeed.java b/src/jalview/ws/dbsources/PfamSeed.java index 33c39b1..dff8a17 100644 --- a/src/jalview/ws/dbsources/PfamSeed.java +++ b/src/jalview/ws/dbsources/PfamSeed.java @@ -33,19 +33,8 @@ public class PfamSeed extends Pfam super(); } - /* - * (non-Javadoc) - * - * @see jalview.ws.dbsources.Pfam#getPFAMURL() - */ - @Override - protected String getXFAMURL() - { - return "http://pfam.xfam.org/family/"; - } - @Override - public String getXFAMURLSUFFIX() + public String getURLSuffix() { return "/alignment/seed"; } diff --git a/src/jalview/ws/dbsources/Rfam.java b/src/jalview/ws/dbsources/Rfam.java index 97f73d0..bed1b48 100644 --- a/src/jalview/ws/dbsources/Rfam.java +++ b/src/jalview/ws/dbsources/Rfam.java @@ -20,6 +20,7 @@ */ package jalview.ws.dbsources; +import jalview.bin.Cache; import jalview.datamodel.DBRefSource; import com.stevesoft.pat.Regex; @@ -31,6 +32,15 @@ import com.stevesoft.pat.Regex; */ abstract public class Rfam extends Xfam { + private static final String RFAM_DOMAIN_KEY = "RFAM_DOMAIN"; + + private static final String DEFAULT_RFAM_DOMAIN = "http://rfam.xfam.org"; + + @Override + protected String getDomain() + { + return Cache.getDefault(RFAM_DOMAIN_KEY, DEFAULT_RFAM_DOMAIN); + } public Rfam() { @@ -46,7 +56,6 @@ abstract public class Rfam extends Xfam @Override public String getAccessionSeparator() { - // TODO Auto-generated method stub return null; } @@ -58,7 +67,6 @@ abstract public class Rfam extends Xfam @Override public Regex getAccessionValidator() { - // TODO Auto-generated method stub return null; } @@ -82,18 +90,9 @@ abstract public class Rfam extends Xfam @Override public String getDbVersion() { - // TODO Auto-generated method stub return null; } - /** - * Returns base URL for selected Rfam alignment type - * - * @return RFAM URL stub for this DbSource - */ - @Override - protected abstract String getXFAMURL(); - /* * (non-Javadoc) * diff --git a/src/jalview/ws/dbsources/RfamFull.java b/src/jalview/ws/dbsources/RfamFull.java index b2ca31a..d815336 100644 --- a/src/jalview/ws/dbsources/RfamFull.java +++ b/src/jalview/ws/dbsources/RfamFull.java @@ -33,20 +33,8 @@ public class RfamFull extends Rfam super(); } - /* - * (non-Javadoc) - * - * @see jalview.ws.dbsources.Rfam#getXFAMURL() - */ - @Override - protected String getXFAMURL() - { - return "http://rfam.xfam.org/family/"; - - } - @Override - public String getXFAMURLSUFFIX() + public String getURLSuffix() { return "/alignment/full"; } diff --git a/src/jalview/ws/dbsources/RfamSeed.java b/src/jalview/ws/dbsources/RfamSeed.java index f714547..a74e829 100644 --- a/src/jalview/ws/dbsources/RfamSeed.java +++ b/src/jalview/ws/dbsources/RfamSeed.java @@ -33,19 +33,8 @@ public class RfamSeed extends Rfam super(); } - /* - * (non-Javadoc) - * - * @see jalview.ws.dbsources.Rfam#getRFAMURL() - */ - @Override - protected String getXFAMURL() - { - return "http://rfam.xfam.org/family/"; - } - @Override - public String getXFAMURLSUFFIX() + public String getURLSuffix() { // to download gzipped file add '?gzip=1' return "/alignment/stockholm"; diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 73775cf..6b09eb6 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -20,6 +20,7 @@ */ package jalview.ws.dbsources; +import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; @@ -52,6 +53,8 @@ import com.stevesoft.pat.Regex; */ public class Uniprot extends DbSourceProxyImpl { + private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org"; + private static final String BAR_DELIMITER = "|"; /* @@ -67,6 +70,11 @@ public class Uniprot extends DbSourceProxyImpl super(); } + private String getDomain() + { + return Cache.getDefault("UNIPROT_DOMAIN", DEFAULT_UNIPROT_DOMAIN); + } + /* * (non-Javadoc) * @@ -163,7 +171,7 @@ public class Uniprot extends DbSourceProxyImpl "(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", ""); AlignmentI al = null; - String downloadstring = "http://www.uniprot.org/uniprot/" + queries + String downloadstring = getDomain() + "/uniprot/" + queries + ".xml"; URL url = null; URLConnection urlconn = null; diff --git a/src/jalview/ws/dbsources/Xfam.java b/src/jalview/ws/dbsources/Xfam.java index 26291eb..e336c7d 100644 --- a/src/jalview/ws/dbsources/Xfam.java +++ b/src/jalview/ws/dbsources/Xfam.java @@ -42,7 +42,7 @@ public abstract class Xfam extends DbSourceProxyImpl super(); } - protected abstract String getXFAMURL(); + protected abstract String getDomain(); @Override public abstract String getDbVersion(); @@ -57,8 +57,7 @@ public abstract class Xfam extends DbSourceProxyImpl // retrieved. startQuery(); // TODO: trap HTTP 404 exceptions and return null - String xfamUrl = getXFAMURL() + queries.trim().toUpperCase() - + getXFAMURLSUFFIX(); + String xfamUrl = getURL(queries); if (Cache.log != null) { @@ -83,6 +82,12 @@ public abstract class Xfam extends DbSourceProxyImpl return rcds; } + String getURL(String queries) + { + return getDomain() + "/family/" + queries.trim().toUpperCase() + + getURLSuffix(); + } + /** * Pfam and Rfam provide alignments */ @@ -97,7 +102,7 @@ public abstract class Xfam extends DbSourceProxyImpl * * @return "" for most Xfam sources */ - public String getXFAMURLSUFFIX() + public String getURLSuffix() { return ""; } diff --git a/test/jalview/ext/ensembl/EnsemblGeneTest.java b/test/jalview/ext/ensembl/EnsemblGeneTest.java index 5920b89..b7ea0cb 100644 --- a/test/jalview/ext/ensembl/EnsemblGeneTest.java +++ b/test/jalview/ext/ensembl/EnsemblGeneTest.java @@ -25,6 +25,7 @@ import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertTrue; import jalview.api.FeatureSettingsModelI; +import jalview.bin.Cache; import jalview.datamodel.SequenceDummy; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; @@ -53,6 +54,7 @@ public class EnsemblGeneTest @BeforeClass(alwaysRun = true) public void setUp() { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); } diff --git a/test/jalview/ws/dbsources/PfamFullTest.java b/test/jalview/ws/dbsources/PfamFullTest.java new file mode 100644 index 0000000..d675fbe --- /dev/null +++ b/test/jalview/ws/dbsources/PfamFullTest.java @@ -0,0 +1,30 @@ +package jalview.ws.dbsources; + +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class PfamFullTest +{ + @BeforeClass(alwaysRun = true) + public void setUp() + { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + } + + @Test(groups = "Functional") + public void testGetURL() + { + // with default value for domain + String url = new PfamFull().getURL(" abc "); + assertEquals(url, "http://pfam.xfam.org/family/ABC/alignment/full"); + + // with override in properties + Cache.setProperty("PFAM_DOMAIN", "https://pfam.xfam.org"); + url = new PfamFull().getURL(" abc "); + assertEquals(url, "https://pfam.xfam.org/family/ABC/alignment/full"); + } +} diff --git a/test/jalview/ws/dbsources/PfamSeedTest.java b/test/jalview/ws/dbsources/PfamSeedTest.java new file mode 100644 index 0000000..537c97e --- /dev/null +++ b/test/jalview/ws/dbsources/PfamSeedTest.java @@ -0,0 +1,30 @@ +package jalview.ws.dbsources; + +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class PfamSeedTest +{ + @BeforeClass(alwaysRun = true) + public void setUp() + { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + } + + @Test(groups = "Functional") + public void testGetURL() + { + // with default value for domain + String url = new PfamSeed().getURL(" abc "); + assertEquals(url, "http://pfam.xfam.org/family/ABC/alignment/seed"); + + // with override in properties + Cache.setProperty("PFAM_DOMAIN", "https://pfam.xfam.org"); + url = new PfamSeed().getURL(" abc "); + assertEquals(url, "https://pfam.xfam.org/family/ABC/alignment/seed"); + } +} diff --git a/test/jalview/ws/dbsources/RfamFullTest.java b/test/jalview/ws/dbsources/RfamFullTest.java new file mode 100644 index 0000000..344aee6 --- /dev/null +++ b/test/jalview/ws/dbsources/RfamFullTest.java @@ -0,0 +1,30 @@ +package jalview.ws.dbsources; + +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RfamFullTest +{ + @BeforeClass(alwaysRun = true) + public void setUp() + { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + } + + @Test(groups = "Functional") + public void testGetURL() + { + // with default value for domain + String url = new RfamFull().getURL(" abc "); + assertEquals(url, "http://rfam.xfam.org/family/ABC/alignment/full"); + + // with override in properties + Cache.setProperty("RFAM_DOMAIN", "https://rfam.xfam.org"); + url = new RfamFull().getURL(" abc "); + assertEquals(url, "https://rfam.xfam.org/family/ABC/alignment/full"); + } +} diff --git a/test/jalview/ws/dbsources/RfamSeedTest.java b/test/jalview/ws/dbsources/RfamSeedTest.java new file mode 100644 index 0000000..e45fff1 --- /dev/null +++ b/test/jalview/ws/dbsources/RfamSeedTest.java @@ -0,0 +1,32 @@ +package jalview.ws.dbsources; + +import static org.testng.Assert.assertEquals; + +import jalview.bin.Cache; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RfamSeedTest +{ + @BeforeClass(alwaysRun = true) + public void setUp() + { + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + } + + @Test(groups = "Functional") + public void testGetURL() + { + // with default value for domain + String url = new RfamSeed().getURL(" abc "); + assertEquals(url, + "http://rfam.xfam.org/family/ABC/alignment/stockholm"); + + // with override in properties + Cache.setProperty("RFAM_DOMAIN", "https://rfam.xfam.org"); + url = new RfamSeed().getURL(" abc "); + assertEquals(url, + "https://rfam.xfam.org/family/ABC/alignment/stockholm"); + } +} diff --git a/test/jalview/ws/dbsources/XfamFetcherTest.java b/test/jalview/ws/dbsources/XfamFetcherTest.java index 573022d..51cff6e 100644 --- a/test/jalview/ws/dbsources/XfamFetcherTest.java +++ b/test/jalview/ws/dbsources/XfamFetcherTest.java @@ -58,7 +58,7 @@ public class XfamFetcherTest @Test(groups = { "External" }) public void testPfamFullAndSeed() throws Exception { - PfamFull pff = new PfamFull(); + Pfam pff = new PfamFull(); PfamSeed pfseed = new PfamSeed(); AlignmentI fullpf = pff.getSequenceRecords(pff.getTestQuery()); -- 1.7.10.2