X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblSequenceFetcher.java;h=21f9f7e01b87b878f805f38e6f3f93015986877e;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=bd6335a9f93a042e9308b1e0efe5877ef76ef5ea;hpb=604cbee405a837565ba1a74aa9bddd62aed685ab;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java index bd6335a..21f9f7e 100644 --- a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java +++ b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java @@ -20,7 +20,10 @@ */ package jalview.ext.ensembl; +import jalview.analysis.AlignmentUtils; +import jalview.bin.Cache; import jalview.datamodel.DBRefSource; +import jalview.util.Platform; import jalview.ws.seqfetcher.DbSourceProxyImpl; import com.stevesoft.pat.Regex; @@ -32,17 +35,34 @@ import com.stevesoft.pat.Regex; */ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl { - /* - * accepts ENSG/T/E/P with 11 digits - * or ENSMUSP or similar for other species - * or CCDSnnnnn.nn with at least 3 digits - */ - private static final Regex ACCESSION_REGEX = new Regex( - "(ENS([A-Z]{3}|)[GTEP]{1}[0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)"); + // domain properties lookup keys: + protected static final String ENSEMBL_BASEURL = "ENSEMBL_BASEURL"; + + protected static final String ENSEMBL_GENOMES_BASEURL = "ENSEMBL_GENOMES_BASEURL"; + + // domain properties default values: + 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; + + private static Regex ACCESSION_REGEX; + + protected final String ensemblGenomesDomain; + + protected final String ensemblDomain; + + protected static final String OBJECT_TYPE_TRANSLATION = "Translation"; + + protected static final String OBJECT_TYPE_TRANSCRIPT = "Transcript"; + + protected static final String OBJECT_TYPE_GENE = "Gene"; - protected static final String ENSEMBL_GENOMES_REST = "http://rest.ensemblgenomes.org"; + protected static final String PARENT = "Parent"; - protected static final String ENSEMBL_REST = "http://rest.ensembl.org"; + protected static final String JSON_ID = AlignmentUtils.VARIANT_ID; // "id"; + + protected static final String OBJECT_TYPE = "object_type"; /* * possible values for the 'feature' parameter of the /overlap REST service @@ -55,16 +75,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_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 (ENSEMBL_GENOMES_REST.equals(getDomain())) - { - return DBRefSource.ENSEMBLGENOMES; - } return DBRefSource.ENSEMBL; } @@ -83,6 +115,17 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl @Override public Regex getAccessionValidator() { + if (ACCESSION_REGEX == null) + { + /* + * accepts ENSG/T/E/P with 11 digits + * or ENSMUSP or similar for other species + * or CCDSnnnnn.nn with at least 3 digits + */ + ACCESSION_REGEX = Platform + .newRegex("(ENS([A-Z]{3}|)[GTEP]{1}[0-9]{11}$)" + "|" + + "(CCDS[0-9.]{3,}$)", null); + } return ACCESSION_REGEX; } @@ -128,6 +171,6 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl protected void setDomain(String d) { - domain = d; + domain = d == null ? null : d.trim(); } }