From: gmungoc Date: Mon, 15 Apr 2019 15:48:30 +0000 (+0100) Subject: JAL-3193 removal of rest.ensemblgenomes.org X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=53c54d0ada46fa839095ace36e18e30ddcf63aa0;p=jalview.git JAL-3193 removal of rest.ensemblgenomes.org --- diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index e6bae9b..82c809b 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -99,7 +99,7 @@ public class CrossRef */ public List findXrefSourcesForSequences(boolean dna) { - List sources = new ArrayList(); + List sources = new ArrayList<>(); for (SequenceI seq : fromSeqs) { if (seq != null) @@ -107,16 +107,15 @@ public class CrossRef findXrefSourcesForSequence(seq, dna, sources); } } - sources.remove(DBRefSource.EMBL); // hack to prevent EMBL xrefs resulting in - // redundant datasets + + // hack to prevent EMBL xrefs resulting in redundant datasets + sources.remove(DBRefSource.EMBL); + if (dna) { - sources.remove(DBRefSource.ENSEMBL); // hack to prevent Ensembl and - // EnsemblGenomes xref option shown - // from cdna panel - sources.remove(DBRefSource.ENSEMBLGENOMES); + // hack to prevent Ensembl xref option shown from cdna panel + sources.remove(DBRefSource.ENSEMBL); } - // redundant datasets return sources; } @@ -151,7 +150,7 @@ public class CrossRef * find sequence's direct (dna-to-dna, peptide-to-peptide) xrefs */ DBRefEntry[] lrfs = DBRefUtils.selectDbRefs(fromDna, seq.getDBRefs()); - List foundSeqs = new ArrayList(); + List foundSeqs = new ArrayList<>(); /* * find sequences in the alignment which xref one of these DBRefs @@ -218,7 +217,7 @@ public class CrossRef public Alignment findXrefSequences(String source, boolean fromDna) { - rseqs = new ArrayList(); + rseqs = new ArrayList<>(); AlignedCodonFrame cf = new AlignedCodonFrame(); matcher = new SequenceIdMatcher(dataset.getSequences()); @@ -430,8 +429,8 @@ public class CrossRef if (retrieved != null) { boolean addedXref = false; - List newDsSeqs = new ArrayList(), - doNotAdd = new ArrayList(); + List newDsSeqs = new ArrayList<>(), + doNotAdd = new ArrayList<>(); for (SequenceI retrievedSequence : retrieved) { diff --git a/src/jalview/datamodel/DBRefSource.java b/src/jalview/datamodel/DBRefSource.java index 7a30141..a56e8a0 100755 --- a/src/jalview/datamodel/DBRefSource.java +++ b/src/jalview/datamodel/DBRefSource.java @@ -86,17 +86,15 @@ public class DBRefSource public static final String GENEDB = "GeneDB".toUpperCase(); /** - * Ensembl + * Ensembl (EnsemblGenomes merged to Ensembl rest services 09.04.2019) */ public static final String ENSEMBL = "ENSEMBL"; - public static final String ENSEMBLGENOMES = "ENSEMBLGENOMES"; - /** * List of databases whose sequences might have coding regions annotated */ public static final String[] DNACODINGDBS = { EMBL, EMBLCDS, GENEDB, - ENSEMBL, ENSEMBLGENOMES }; + ENSEMBL }; public static final String[] CODINGDBS = { EMBLCDS, GENEDB, ENSEMBL }; diff --git a/src/jalview/ext/ensembl/EnsemblCdna.java b/src/jalview/ext/ensembl/EnsemblCdna.java index e01ad17..d6d3f3a 100644 --- a/src/jalview/ext/ensembl/EnsemblCdna.java +++ b/src/jalview/ext/ensembl/EnsemblCdna.java @@ -63,16 +63,6 @@ public class EnsemblCdna extends EnsemblSeqProxy super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblCdna(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/src/jalview/ext/ensembl/EnsemblCds.java b/src/jalview/ext/ensembl/EnsemblCds.java index 8f13d99..05963cd 100644 --- a/src/jalview/ext/ensembl/EnsemblCds.java +++ b/src/jalview/ext/ensembl/EnsemblCds.java @@ -56,16 +56,6 @@ public class EnsemblCds extends EnsemblSeqProxy super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblCds(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/src/jalview/ext/ensembl/EnsemblData.java b/src/jalview/ext/ensembl/EnsemblData.java index 47fe0fc..715bcaf 100644 --- a/src/jalview/ext/ensembl/EnsemblData.java +++ b/src/jalview/ext/ensembl/EnsemblData.java @@ -22,7 +22,9 @@ package jalview.ext.ensembl; /** * A data class to model the data and rest version of one Ensembl domain, - * currently for rest.ensembl.org and rest.ensemblgenomes.org + * currently for rest.ensembl.org and rest.ensemblgenomes.org. + *

+ * April 2019 reduced to rest.ensembl.org only * * @author gmcarstairs */ diff --git a/src/jalview/ext/ensembl/EnsemblFeatures.java b/src/jalview/ext/ensembl/EnsemblFeatures.java index 744191d..859251b 100644 --- a/src/jalview/ext/ensembl/EnsemblFeatures.java +++ b/src/jalview/ext/ensembl/EnsemblFeatures.java @@ -65,16 +65,6 @@ class EnsemblFeatures extends EnsemblRestClient super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblFeatures(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/src/jalview/ext/ensembl/EnsemblGene.java b/src/jalview/ext/ensembl/EnsemblGene.java index 7648536..0da3a29 100644 --- a/src/jalview/ext/ensembl/EnsemblGene.java +++ b/src/jalview/ext/ensembl/EnsemblGene.java @@ -70,16 +70,6 @@ public class EnsemblGene extends EnsemblSeqProxy super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblGene(String d) - { - super(d); - } - @Override public String getDbName() { @@ -183,7 +173,7 @@ public class EnsemblGene extends EnsemblSeqProxy */ void findGeneLoci(SequenceI seq, String geneId) { - GeneLociI geneLoci = new EnsemblLookup(getDomain()).getGeneLoci(geneId); + GeneLociI geneLoci = new EnsemblLookup().getGeneLoci(geneId); if (geneLoci != null) { seq.setGeneLoci(geneLoci.getSpeciesId(), geneLoci.getAssemblyId(), @@ -250,7 +240,7 @@ public class EnsemblGene extends EnsemblSeqProxy /* * First try lookup as an Ensembl (gene or transcript) identifier */ - String geneId = new EnsemblLookup(getDomain()).getGeneId(acc); + String geneId = new EnsemblLookup().getGeneId(acc); if (geneId != null) { if (!geneIds.contains(geneId)) @@ -264,8 +254,8 @@ public class EnsemblGene extends EnsemblSeqProxy * if given a gene or other external name, lookup and fetch * the corresponding gene for all model organisms */ - List ids = new EnsemblSymbol(getDomain(), getDbSource(), - getDbVersion()).getGeneIds(acc); + List ids = new EnsemblSymbol(getDbSource(), getDbVersion()) + .getGeneIds(acc); for (String id : ids) { if (!geneIds.contains(id)) @@ -423,7 +413,7 @@ public class EnsemblGene extends EnsemblSeqProxy List mapTo = new ArrayList<>(); mapTo.add(new int[] { 1, transcriptLength }); MapList mapping = new MapList(mappedFrom, mapTo, 1, 1); - EnsemblCdna cdna = new EnsemblCdna(getDomain()); + EnsemblCdna cdna = new EnsemblCdna(); cdna.transferFeatures(gene.getFeatures().getPositionalFeatures(), transcript.getDatasetSequence(), mapping, parentId); diff --git a/src/jalview/ext/ensembl/EnsemblGenome.java b/src/jalview/ext/ensembl/EnsemblGenome.java deleted file mode 100644 index 4f59bc5..0000000 --- a/src/jalview/ext/ensembl/EnsemblGenome.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.SequenceFeature; -import jalview.datamodel.SequenceI; -import jalview.io.gff.SequenceOntologyI; - -import java.util.ArrayList; -import java.util.List; - -/** - * A client to fetch genomic sequence from Ensembl - * - * TODO: not currently used - delete? - * - * @author gmcarstairs - * - */ -public class EnsemblGenome extends EnsemblSeqProxy -{ - /* - * fetch transcript features on genomic sequence (to identify the transcript - * regions) and cds, exon and variation features (to retain) - */ - private static final EnsemblFeatureType[] FEATURES_TO_FETCH = { - EnsemblFeatureType.transcript, EnsemblFeatureType.exon, - EnsemblFeatureType.cds, EnsemblFeatureType.variation }; - - /** - * Default constructor (to use rest.ensembl.org) - */ - public EnsemblGenome() - { - super(); - } - - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblGenome(String d) - { - super(d); - } - - @Override - public String getDbName() - { - return "ENSEMBL (Genomic)"; - } - - @Override - protected EnsemblSeqType getSourceEnsemblType() - { - return EnsemblSeqType.GENOMIC; - } - - @Override - protected EnsemblFeatureType[] getFeaturesToFetch() - { - return FEATURES_TO_FETCH; - } - - /** - * Answers true unless the feature type is 'transcript' (or a sub-type of - * transcript in the Sequence Ontology), or has a parent other than the given - * accession id. Transcript features are only retrieved in order to identify - * the transcript sequence range, and are redundant information on the - * transcript sequence itself. - */ - @Override - protected boolean retainFeature(SequenceFeature sf, String accessionId) - { - if (isTranscript(sf.getType())) - { - return false; - } - return featureMayBelong(sf, accessionId); - } - - /** - * Answers a list of sequence features (if any) whose type is 'transcript' (or - * a subtype of transcript in the Sequence Ontology), and whose ID is the - * accession we are retrieving. - *

- * Note we also include features of type "NMD_transcript_variant", although - * not strictly 'transcript' in the SO, as they used in Ensembl as if they - * were. - */ - @Override - protected List getIdentifyingFeatures(SequenceI seq, - String accId) - { - List result = new ArrayList<>(); - List sfs = seq.getFeatures().getFeaturesByOntology( - SequenceOntologyI.TRANSCRIPT, - SequenceOntologyI.NMD_TRANSCRIPT_VARIANT); - for (SequenceFeature sf : sfs) - { - String id = (String) sf.getValue(JSON_ID); - if (accId.equals(id)) - { - result.add(sf); - } - } - return result; - } - -} diff --git a/src/jalview/ext/ensembl/EnsemblGenomes.java b/src/jalview/ext/ensembl/EnsemblGenomes.java deleted file mode 100644 index 9fc6a53..0000000 --- a/src/jalview/ext/ensembl/EnsemblGenomes.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.bin.Cache; -import jalview.datamodel.DBRefSource; - -/** - * A class to behave much like EnsemblGene but referencing the ensemblgenomes - * domain and data - * - * @author gmcarstairs - * - */ -public class EnsemblGenomes extends EnsemblGene -{ - /** - * Constructor sets domain to rest.ensemblgenomes.org instead of the 'usual' - * rest.ensembl.org - */ - public EnsemblGenomes() - { - super(); - setDomain(Cache.getDefault(ENSEMBL_GENOMES_BASEURL, - DEFAULT_ENSEMBL_GENOMES_BASEURL)); - } - - @Override - public String getDbName() - { - return DBRefSource.ENSEMBLGENOMES; - } - - @Override - public String getTestQuery() - { - /* - * Salmonella gene, Uniprot Q8Z9G6, EMBLCDS CAD01290 - */ - return "CAD01290"; - } - - @Override - public String getDbSource() - { - return DBRefSource.ENSEMBLGENOMES; - } - -} diff --git a/src/jalview/ext/ensembl/EnsemblInfo.java b/src/jalview/ext/ensembl/EnsemblInfo.java index fa24f1e..9b97080 100644 --- a/src/jalview/ext/ensembl/EnsemblInfo.java +++ b/src/jalview/ext/ensembl/EnsemblInfo.java @@ -1,7 +1,6 @@ package jalview.ext.ensembl; import jalview.datamodel.AlignmentI; -import jalview.datamodel.DBRefSource; import java.io.BufferedReader; import java.io.IOException; @@ -21,22 +20,26 @@ public class EnsemblInfo extends EnsemblRestClient { /* - * cached results of REST /info/divisions service, currently - *

-   * { 
-   *  { "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" }
    *  }
-   * 
- * The values for EnsemblGenomes are retrieved by a REST call, that for - * Ensembl is added programmatically for convenience of lookup */ private static Map divisions; + /** + * Constructor + */ + public EnsemblInfo() + { + super(); + } + @Override public String getDbName() { @@ -62,9 +65,8 @@ public class EnsemblInfo extends EnsemblRestClient } /** - * 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 @@ -80,26 +82,21 @@ public class EnsemblInfo extends EnsemblRestClient /** * 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 @@ -122,15 +119,15 @@ public class EnsemblInfo extends EnsemblRestClient * 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()) @@ -145,20 +142,20 @@ public class EnsemblInfo extends EnsemblRestClient } /** - * 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 */ diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index c6b794a..b795d0d 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -56,16 +56,6 @@ public class EnsemblLookup extends EnsemblRestClient super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param - */ - public EnsemblLookup(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/src/jalview/ext/ensembl/EnsemblMap.java b/src/jalview/ext/ensembl/EnsemblMap.java index f01bd4f..deda7d4 100644 --- a/src/jalview/ext/ensembl/EnsemblMap.java +++ b/src/jalview/ext/ensembl/EnsemblMap.java @@ -37,16 +37,6 @@ public class EnsemblMap extends EnsemblRestClient super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param - */ - public EnsemblMap(String domain) - { - super(domain); - } - @Override public String getDbName() { @@ -113,7 +103,7 @@ public class EnsemblMap extends EnsemblRestClient * @param toRef * @param queryRange * @return - * @see http://rest.ensemblgenomes.org/documentation/info/assembly_map + * @see http://rest.ensembl.org/documentation/info/assembly_map */ public int[] getAssemblyMapping(String species, String chromosome, String fromRef, String toRef, int[] queryRange) @@ -247,7 +237,7 @@ public class EnsemblMap extends EnsemblRestClient br = getHttpResponse(url, null); if (br != null) { - return (parseIdMappingResponse(br, accession, domain)); + return (parseIdMappingResponse(br, accession)); } } return null; @@ -271,9 +261,7 @@ public class EnsemblMap extends EnsemblRestClient } /** - * Constructs a URL to the /map/cds/ or /map/cdna/ REST service. The - * REST call is to either ensembl or ensemblgenomes, as determined from the - * division, e.g. Ensembl or EnsemblProtists. + * Constructs a URL to the /map/cds/ or /map/cdna/ REST service * * @param domain * @param accession @@ -309,11 +297,9 @@ public class EnsemblMap extends EnsemblRestClient * * @param br * @param accession - * @param domain * @return */ - GeneLociI parseIdMappingResponse(BufferedReader br, String accession, - String domain) + GeneLociI parseIdMappingResponse(BufferedReader br, String accession) { JSONParser jp = new JSONParser(); @@ -368,8 +354,7 @@ public class EnsemblMap extends EnsemblRestClient * processed all mapped regions on chromosome, assemble the result, * having first fetched the species id for the accession */ - final String species = new EnsemblLookup(domain) - .getSpecies(accession); + final String species = new EnsemblLookup().getSpecies(accession); final String as = assembly; final String chr = chromosome; List fromRange = Collections.singletonList(new int[] { 1, diff --git a/src/jalview/ext/ensembl/EnsemblProtein.java b/src/jalview/ext/ensembl/EnsemblProtein.java index 0280f16..1b9de92 100644 --- a/src/jalview/ext/ensembl/EnsemblProtein.java +++ b/src/jalview/ext/ensembl/EnsemblProtein.java @@ -53,16 +53,6 @@ public class EnsemblProtein extends EnsemblSeqProxy super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblProtein(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index 617ab21..8cfc343 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -64,8 +64,6 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher * @see https://github.com/Ensembl/ensembl-rest/wiki/Change-log * @see http://rest.ensembl.org/info/rest?content-type=application/json */ - private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "10.0"; - private static final String LATEST_ENSEMBL_REST_VERSION = "10.0"; private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log"; @@ -83,8 +81,6 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher domainData = new HashMap<>(); domainData.put(DEFAULT_ENSEMBL_BASEURL, new EnsemblData(DEFAULT_ENSEMBL_BASEURL, LATEST_ENSEMBL_REST_VERSION)); - domainData.put(DEFAULT_ENSEMBL_GENOMES_BASEURL, new EnsemblData( - DEFAULT_ENSEMBL_GENOMES_BASEURL, LATEST_ENSEMBLGENOMES_REST_VERSION)); } protected volatile boolean inProgress = false; @@ -99,28 +95,14 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher /* * initialise domain info lazily */ - if (!domainData.containsKey(ensemblDomain)) - { - domainData.put(ensemblDomain, - new EnsemblData(ensemblDomain, LATEST_ENSEMBL_REST_VERSION)); - } - if (!domainData.containsKey(ensemblGenomesDomain)) + String domain = getDomain(); + if (!domainData.containsKey(domain)) { - domainData.put(ensemblGenomesDomain, new EnsemblData( - ensemblGenomesDomain, LATEST_ENSEMBLGENOMES_REST_VERSION)); + domainData.put(domain, + new EnsemblData(domain, LATEST_ENSEMBL_REST_VERSION)); } } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblRestClient(String d) - { - setDomain(d); - } - @Override public boolean queryInProgress() { @@ -187,8 +169,6 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher 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(pingUrl); /* diff --git a/src/jalview/ext/ensembl/EnsemblSeqProxy.java b/src/jalview/ext/ensembl/EnsemblSeqProxy.java index 5dc701d..0fabb7e 100644 --- a/src/jalview/ext/ensembl/EnsemblSeqProxy.java +++ b/src/jalview/ext/ensembl/EnsemblSeqProxy.java @@ -116,14 +116,6 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient } /** - * Constructor given the target domain to fetch data from - */ - public EnsemblSeqProxy(String d) - { - super(d); - } - - /** * Makes the sequence queries to Ensembl's REST service and returns an * alignment consisting of the returned sequences. */ @@ -208,7 +200,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient * exon, cds and variation features */ SequenceI genomicSequence = null; - EnsemblFeatures gffFetcher = new EnsemblFeatures(getDomain()); + EnsemblFeatures gffFetcher = new EnsemblFeatures(); EnsemblFeatureType[] features = getFeaturesToFetch(); AlignmentI geneFeatures = gffFetcher.getSequenceRecords(accId, features); @@ -258,7 +250,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient String accId = querySeq.getName(); try { - AlignmentI protein = new EnsemblProtein(getDomain()) + AlignmentI protein = new EnsemblProtein() .getSequenceRecords(accId); if (protein == null || protein.getHeight() == 0) { @@ -353,7 +345,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient seq = seq.getDatasetSequence(); } - EnsemblXref xrefFetcher = new EnsemblXref(getDomain(), getDbSource(), + EnsemblXref xrefFetcher = new EnsemblXref(getDbSource(), getEnsemblDataVersion()); List xrefs = xrefFetcher.getCrossReferences(seq.getName()); for (DBRefEntry xref : xrefs) diff --git a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java index 3b71823..40dfa84 100644 --- a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java +++ b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java @@ -34,17 +34,12 @@ import com.stevesoft.pat.Regex; */ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl { - // domain properties lookup keys: + // domain property lookup key protected static final String ENSEMBL_BASEURL = "ENSEMBL_BASEURL"; - protected static final String ENSEMBL_GENOMES_BASEURL = "ENSEMBL_GENOMES_BASEURL"; - - // domain properties default values: + // domain property default value protected static final String DEFAULT_ENSEMBL_BASEURL = "https://rest.ensembl.org"; - // ensemblgenomes REST service merged to ensembl 9th April 2019 - protected static final String DEFAULT_ENSEMBL_GENOMES_BASEURL = DEFAULT_ENSEMBL_BASEURL; - /* * accepts ENSG/T/E/P with 11 digits * or ENSMUSP or similar for other species @@ -54,10 +49,6 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl "(ENS([A-Z]{3}|)[GTEP]{1}[0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)"); - protected final String ensemblGenomesDomain; - - protected final String ensemblDomain; - protected static final String OBJECT_TYPE_TRANSLATION = "Translation"; protected static final String OBJECT_TYPE_TRANSCRIPT = "Transcript"; @@ -92,21 +83,14 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl * 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_BASEURL, + domain = Cache.getDefault(ENSEMBL_BASEURL, DEFAULT_ENSEMBL_BASEURL).trim(); - ensemblGenomesDomain = Cache.getDefault(ENSEMBL_GENOMES_BASEURL, - DEFAULT_ENSEMBL_GENOMES_BASEURL).trim(); - domain = ensemblDomain; } @Override public String getDbSource() { // NB ensure Uniprot xrefs are canonicalised from "Ensembl" to "ENSEMBL" - if (ensemblGenomesDomain.equals(getDomain())) - { - return DBRefSource.ENSEMBLGENOMES; - } return DBRefSource.ENSEMBL; } @@ -158,8 +142,7 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl } /** - * Returns the domain name to query e.g. http://rest.ensembl.org or - * http://rest.ensemblgenomes.org + * Returns the domain name to query e.g. http://rest.ensembl.org * * @return */ diff --git a/src/jalview/ext/ensembl/EnsemblSymbol.java b/src/jalview/ext/ensembl/EnsemblSymbol.java index 40d6cad..40860d2 100644 --- a/src/jalview/ext/ensembl/EnsemblSymbol.java +++ b/src/jalview/ext/ensembl/EnsemblSymbol.java @@ -44,6 +44,7 @@ public class EnsemblSymbol extends EnsemblXref { private static final String GENE = "gene"; private static final String TYPE = "type"; + /** * Constructor given the target domain to fetch data from * @@ -51,9 +52,9 @@ public class EnsemblSymbol extends EnsemblXref * @param dbName * @param dbVersion */ - public EnsemblSymbol(String domain, String dbName, String dbVersion) + public EnsemblSymbol(String dbName, String dbVersion) { - super(domain, dbName, dbVersion); + super(dbName, dbVersion); } /** @@ -131,8 +132,8 @@ public class EnsemblSymbol extends EnsemblXref */ public List getGeneIds(String identifier) { - List result = new ArrayList(); - List ids = new ArrayList(); + List result = new ArrayList<>(); + List ids = new ArrayList<>(); ids.add(identifier); String[] queries = identifier.split(getAccessionSeparator()); diff --git a/src/jalview/ext/ensembl/EnsemblXref.java b/src/jalview/ext/ensembl/EnsemblXref.java index 77768a6..a0b97fd 100644 --- a/src/jalview/ext/ensembl/EnsemblXref.java +++ b/src/jalview/ext/ensembl/EnsemblXref.java @@ -52,13 +52,14 @@ class EnsemblXref extends EnsemblRestClient private String dbName = "ENSEMBL (xref)"; /** - * Constructor given the target domain to fetch data from + * Constructor * - * @param d + * @param sbSource + * @param version */ - public EnsemblXref(String d, String dbSource, String version) + public EnsemblXref(String dbSource, String version) { - super(d); + super(); dbName = dbSource; xrefVersion = dbSource + ":" + version; diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index 29d4ec7..f84d422 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -21,7 +21,6 @@ package jalview.ws; import jalview.ext.ensembl.EnsemblGene; -import jalview.ext.ensembl.EnsemblGenomes; import jalview.ws.dbsources.EmblCdsSource; import jalview.ws.dbsources.EmblSource; import jalview.ws.dbsources.Pdb; @@ -49,7 +48,6 @@ public class SequenceFetcher extends ASequenceFetcher public SequenceFetcher() { addDBRefSourceImpl(EnsemblGene.class); - addDBRefSourceImpl(EnsemblGenomes.class); addDBRefSourceImpl(EmblSource.class); addDBRefSourceImpl(EmblCdsSource.class); addDBRefSourceImpl(Uniprot.class); diff --git a/test/jalview/analysis/CrossRefTest.java b/test/jalview/analysis/CrossRefTest.java index 81ec443..4d67342 100644 --- a/test/jalview/analysis/CrossRefTest.java +++ b/test/jalview/analysis/CrossRefTest.java @@ -128,12 +128,12 @@ public class CrossRefTest seq.addDBRef(new DBRefEntry("EMBLCDS", "0", "E2347")); seq.addDBRef(new DBRefEntry("GENEDB", "0", "E2348")); seq.addDBRef(new DBRefEntry("ENSEMBL", "0", "E2349")); - seq.addDBRef(new DBRefEntry("ENSEMBLGENOMES", "0", "E2350")); + seq.addDBRef(new DBRefEntry("EnsemblFungi", "0", "E2350")); sources = new CrossRef(new SequenceI[] { seq }, al) .findXrefSourcesForSequences(false); // method is patched to remove EMBL from the sources to match - assertEquals(4, sources.size()); - assertEquals("[EMBLCDS, GENEDB, ENSEMBL, ENSEMBLGENOMES]", + assertEquals(3, sources.size()); + assertEquals("[EMBLCDS, GENEDB, ENSEMBL]", sources.toString()); /* diff --git a/test/jalview/ext/ensembl/EnsemblGenomeTest.java b/test/jalview/ext/ensembl/EnsemblGenomeTest.java deleted file mode 100644 index 11140f9..0000000 --- a/test/jalview/ext/ensembl/EnsemblGenomeTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; - -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceDummy; -import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceI; -import jalview.gui.JvOptionPane; -import jalview.io.gff.SequenceOntologyFactory; -import jalview.io.gff.SequenceOntologyLite; -import jalview.util.MapList; - -import java.util.List; - -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class EnsemblGenomeTest -{ - - @BeforeClass(alwaysRun = true) - public void setUpJvOptionPane() - { - JvOptionPane.setInteractiveMode(false); - JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); - } - - @BeforeClass(alwaysRun = true) - public void setUp() - { - SequenceOntologyFactory.setInstance(new SequenceOntologyLite()); - } - - @AfterClass(alwaysRun = true) - public void tearDown() - { - SequenceOntologyFactory.setInstance(null); - } - - /** - * Test that the genomic sequence part of genomic sequence is correctly - * identified by 'transcript' features (or subtypes) with the correct gene ID - */ - @Test(groups = "Functional") - public void testGetGenomicRangesFromFeatures() - { - EnsemblGenome testee = new EnsemblGenome(); - SequenceI genomic = new SequenceDummy("chr7"); - genomic.setStart(10000); - genomic.setEnd(50000); - String transcriptId = "ABC123"; - - // transcript at (start+10000) length 501 - SequenceFeature sf = new SequenceFeature("transcript", "", 20000, - 20500, 0f, null); - sf.setValue("id", transcriptId); - sf.setStrand("+"); - genomic.addSequenceFeature(sf); - - // transcript (sub-type) at (start + 10500) length 101 - sf = new SequenceFeature("ncRNA", "", 10500, 10600, 0f, null); - sf.setValue("id", transcriptId); - sf.setStrand("+"); - genomic.addSequenceFeature(sf); - - // Ensembl treats NMD_transcript_variant as if transcript - // although strictly it is a sequence_variant in SO - sf = new SequenceFeature("NMD_transcript_variant", "", 11000, 12000, - 0f, null); - sf.setValue("id", transcriptId); - sf.setStrand("+"); - genomic.addSequenceFeature(sf); - - // transcript with a different ID doesn't count - sf = new SequenceFeature("transcript", "", 11500, 12600, 0f, null); - sf.setValue("id", "anotherOne"); - genomic.addSequenceFeature(sf); - - // parent of transcript feature doesn't count - sf = new SequenceFeature("gene_member_region", "", 10000, 50000, 0f, - null); - genomic.addSequenceFeature(sf); - - MapList ranges = testee.getGenomicRangesFromFeatures(genomic, - transcriptId, 23); - List fromRanges = ranges.getFromRanges(); - assertEquals(3, fromRanges.size()); - // from ranges should be sorted by start order - assertEquals(10500, fromRanges.get(0)[0]); - assertEquals(10600, fromRanges.get(0)[1]); - assertEquals(11000, fromRanges.get(1)[0]); - assertEquals(12000, fromRanges.get(1)[1]); - assertEquals(20000, fromRanges.get(2)[0]); - assertEquals(20500, fromRanges.get(2)[1]); - // to range should start from given start numbering - List toRanges = ranges.getToRanges(); - assertEquals(1, toRanges.size()); - assertEquals(23, toRanges.get(0)[0]); - assertEquals(1625, toRanges.get(0)[1]); - } - - /** - * Test the method that retains features except for 'transcript' (or - * sub-type), or those with parent other than the given id - */ - @Test(groups = "Functional") - public void testRetainFeature() - { - String accId = "ABC123"; - EnsemblGenome testee = new EnsemblGenome(); - - SequenceFeature sf = new SequenceFeature("transcript", "", 20000, - 20500, 0f, null); - assertFalse(testee.retainFeature(sf, accId)); - - sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f, - null); - assertFalse(testee.retainFeature(sf, accId)); - - sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, - 0f, null); - assertFalse(testee.retainFeature(sf, accId)); - - // other feature with no parent is kept - sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null); - assertTrue(testee.retainFeature(sf, accId)); - - // other feature with correct parent is kept - sf.setValue("Parent", accId); - assertTrue(testee.retainFeature(sf, accId)); - - // other feature with wrong parent is not kept - sf.setValue("Parent", "XYZ"); - assertFalse(testee.retainFeature(sf, accId)); - } - - /** - * Test the method that picks out 'transcript' (or subtype) features with the - * accession id as ID - */ - @Test(groups = "Functional") - public void testGetIdentifyingFeatures() - { - String accId = "ABC123"; - SequenceI seq = new Sequence(accId, "HEARTS"); - - // transcript with no ID not valid - SequenceFeature sf1 = new SequenceFeature("transcript", "", 1, 2, 0f, - null); - seq.addSequenceFeature(sf1); - - // transcript with wrong ID not valid - // NB change desc to avoid rejection of duplicate feature! - SequenceFeature sf2 = new SequenceFeature("transcript", "a", 1, 2, 0f, - null); - sf2.setValue("id", "transcript"); - seq.addSequenceFeature(sf2); - - // transcript with right ID is valid - SequenceFeature sf3 = new SequenceFeature("transcript", "b", 1, 2, 0f, - null); - sf3.setValue("id", accId); - seq.addSequenceFeature(sf3); - - // transcript sub-type with right ID is valid - SequenceFeature sf4 = new SequenceFeature("ncRNA", "", 1, 2, 0f, null); - sf4.setValue("id", accId); - seq.addSequenceFeature(sf4); - - // Ensembl treats NMD_transcript_variant as if a transcript - SequenceFeature sf5 = new SequenceFeature("NMD_transcript_variant", "", - 1, 2, 0f, null); - sf5.setValue("id", accId); - seq.addSequenceFeature(sf5); - - // gene not valid: - SequenceFeature sf6 = new SequenceFeature("gene", "", 1, 2, 0f, null); - sf6.setValue("id", accId); - seq.addSequenceFeature(sf6); - - // exon not valid: - SequenceFeature sf7 = new SequenceFeature("exon", "", 1, 2, 0f, null); - sf7.setValue("id", accId); - seq.addSequenceFeature(sf7); - - List sfs = new EnsemblGenome() - .getIdentifyingFeatures(seq, accId); - assertFalse(sfs.contains(sf1)); - assertFalse(sfs.contains(sf2)); - assertTrue(sfs.contains(sf3)); - assertTrue(sfs.contains(sf4)); - assertTrue(sfs.contains(sf5)); - assertFalse(sfs.contains(sf6)); - assertFalse(sfs.contains(sf7)); - } - -} diff --git a/test/jalview/ext/ensembl/EnsemblSeqProxyAdapter.java b/test/jalview/ext/ensembl/EnsemblSeqProxyAdapter.java index be7bdf2..d06a9d0 100644 --- a/test/jalview/ext/ensembl/EnsemblSeqProxyAdapter.java +++ b/test/jalview/ext/ensembl/EnsemblSeqProxyAdapter.java @@ -40,16 +40,6 @@ public class EnsemblSeqProxyAdapter extends EnsemblSeqProxy super(); } - /** - * Constructor given the target domain to fetch data from - * - * @param d - */ - public EnsemblSeqProxyAdapter(String d) - { - super(d); - } - @Override public String getDbName() { diff --git a/test/jalview/ext/ensembl/EnsemblXrefTest.java b/test/jalview/ext/ensembl/EnsemblXrefTest.java index 9cc6627..6174ed0 100644 --- a/test/jalview/ext/ensembl/EnsemblXrefTest.java +++ b/test/jalview/ext/ensembl/EnsemblXrefTest.java @@ -58,8 +58,7 @@ public class EnsemblXrefTest String dbName = "ENSEMBL"; String dbVers = "0.6.2b1"; System.out.println(JSON); - EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName, - dbVers) + EnsemblXref testee = new EnsemblXref(dbName, dbVers) { @Override protected BufferedReader getHttpResponse(URL url, List ids) diff --git a/test/jalview/ws/dbsources/RemoteFormatTest.java b/test/jalview/ws/dbsources/RemoteFormatTest.java index e04d195..70d235b 100644 --- a/test/jalview/ws/dbsources/RemoteFormatTest.java +++ b/test/jalview/ws/dbsources/RemoteFormatTest.java @@ -10,7 +10,6 @@ import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; -import jalview.ext.ensembl.EnsemblGenomes; import jalview.fts.api.FTSData; import jalview.fts.api.FTSDataColumnI; import jalview.fts.api.FTSRestClientI; @@ -61,7 +60,7 @@ public class RemoteFormatTest { DBRefSource.PDB, "1QIP" }, { DBRefSource.EMBL, "X53828" }, { DBRefSource.EMBLCDS, "CAA37824" }, { DBRefSource.ENSEMBL, "ENSG00000157764" }, - { new EnsemblGenomes().getDbSource(), "DDB_G0283883" }, + // { new EnsemblGenomes().getDbSource(), "DDB_G0283883" }, { new PfamFull().getDbSource(), "PF03760" }, { new PfamSeed().getDbSource(), "PF03760" }, { new RfamSeed().getDbSource(), "RF00014" } };