X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblSequenceFetcher.java;h=2008fb6aeebf58e5956623d0e0e60cc848f71da8;hb=7d602d0e4b439e56af3e4551ed71f181a8025534;hp=9a4952e9082d87642432f920f6c208752fd1bea9;hpb=e24933a537e0f640c75d4685c468615872bc77fc;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java index 9a4952e..2008fb6 100644 --- a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java +++ b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java @@ -1,6 +1,29 @@ +/* + * 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.analysis.AlignmentUtils; +import jalview.bin.Cache; import jalview.datamodel.DBRefSource; +import jalview.util.Platform; import jalview.ws.seqfetcher.DbSourceProxyImpl; import com.stevesoft.pat.Regex; @@ -12,13 +35,41 @@ import com.stevesoft.pat.Regex; */ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl { + // 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; + /* * 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,}$)"); + private static final Regex ACCESSION_REGEX = Platform.newRegex( + "(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"; + + protected static final String OBJECT_TYPE_GENE = "Gene"; + + protected static final String PARENT = "Parent"; + + 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 @@ -31,17 +82,29 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl constrained, regulatory } - @Override - public String getDbSource() + private String domain; + + /** + * Constructor + */ + public EnsemblSequenceFetcher() { - // NB ensure Uniprot xrefs are canonicalised from "Ensembl" to "ENSEMBL" - return DBRefSource.ENSEMBL; // "ENSEMBL" + /* + * 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 getDbVersion() + public String getDbSource() { - return "0"; + // NB ensure Uniprot xrefs are canonicalised from "Ensembl" to "ENSEMBL" + return DBRefSource.ENSEMBL; } @Override @@ -90,4 +153,20 @@ abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl { return true; } + + /** + * Returns the domain name to query e.g. http://rest.ensembl.org or + * http://rest.ensemblgenomes.org + * + * @return + */ + protected String getDomain() + { + return domain; + } + + protected void setDomain(String d) + { + domain = d == null ? null : d.trim(); + } }