*/
public List<String> findXrefSourcesForSequences(boolean dna)
{
- List<String> sources = new ArrayList<String>();
+ List<String> sources = new ArrayList<>();
for (SequenceI seq : fromSeqs)
{
if (seq != null)
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;
}
* find sequence's direct (dna-to-dna, peptide-to-peptide) xrefs
*/
DBRefEntry[] lrfs = DBRefUtils.selectDbRefs(fromDna, seq.getDBRefs());
- List<SequenceI> foundSeqs = new ArrayList<SequenceI>();
+ List<SequenceI> foundSeqs = new ArrayList<>();
/*
* find sequences in the alignment which xref one of these DBRefs
public Alignment findXrefSequences(String source, boolean fromDna)
{
- rseqs = new ArrayList<SequenceI>();
+ rseqs = new ArrayList<>();
AlignedCodonFrame cf = new AlignedCodonFrame();
matcher = new SequenceIdMatcher(dataset.getSequences());
if (retrieved != null)
{
boolean addedXref = false;
- List<SequenceI> newDsSeqs = new ArrayList<SequenceI>(),
- doNotAdd = new ArrayList<SequenceI>();
+ List<SequenceI> newDsSeqs = new ArrayList<>(),
+ doNotAdd = new ArrayList<>();
for (SequenceI retrievedSequence : retrieved)
{
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 };
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblCdna(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblCds(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
/**
* 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.
+ * <p>
+ * April 2019 reduced to rest.ensembl.org only
*
* @author gmcarstairs
*/
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblFeatures(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblGene(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
*/
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(),
/*
* 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))
* if given a gene or other external name, lookup and fetch
* the corresponding gene for all model organisms
*/
- List<String> ids = new EnsemblSymbol(getDomain(), getDbSource(),
- getDbVersion()).getGeneIds(acc);
+ List<String> ids = new EnsemblSymbol(getDbSource(), getDbVersion())
+ .getGeneIds(acc);
for (String id : ids)
{
if (!geneIds.contains(id))
List<int[]> 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);
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- * 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.
- * <p>
- * 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<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
- String accId)
- {
- List<SequenceFeature> result = new ArrayList<>();
- List<SequenceFeature> 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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- * 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;
- }
-
-}
package jalview.ext.ensembl;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefSource;
import java.io.BufferedReader;
import java.io.IOException;
{
/*
- * cached results of REST /info/divisions service, currently
- * <pre>
- * {
- * { "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" }
* }
- * </pre>
- * The values for EnsemblGenomes are retrieved by a REST call, that for
- * Ensembl is added programmatically for convenience of lookup
*/
private static Map<String, String> divisions;
+ /**
+ * Constructor
+ */
+ public EnsemblInfo()
+ {
+ super();
+ }
+
@Override
public String getDbName()
{
}
/**
- * 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
/**
* 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
* 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())
}
/**
- * 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
*/
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param
- */
- public EnsemblLookup(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param
- */
- public EnsemblMap(String domain)
- {
- super(domain);
- }
-
@Override
public String getDbName()
{
* @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)
br = getHttpResponse(url, null);
if (br != null)
{
- return (parseIdMappingResponse(br, accession, domain));
+ return (parseIdMappingResponse(br, accession));
}
}
return null;
}
/**
- * Constructs a URL to the /map/cds/<id> or /map/cdna/<id> 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/<id> or /map/cdna/<id> REST service
*
* @param domain
* @param accession
*
* @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();
* 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<int[]> fromRange = Collections.singletonList(new int[] { 1,
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblProtein(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
* @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";
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;
/*
* 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()
{
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);
/*
}
/**
- * 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.
*/
* 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);
String accId = querySeq.getName();
try
{
- AlignmentI protein = new EnsemblProtein(getDomain())
+ AlignmentI protein = new EnsemblProtein()
.getSequenceRecords(accId);
if (protein == null || protein.getHeight() == 0)
{
seq = seq.getDatasetSequence();
}
- EnsemblXref xrefFetcher = new EnsemblXref(getDomain(), getDbSource(),
+ EnsemblXref xrefFetcher = new EnsemblXref(getDbSource(),
getEnsemblDataVersion());
List<DBRefEntry> xrefs = xrefFetcher.getCrossReferences(seq.getName());
for (DBRefEntry xref : xrefs)
*/
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
"(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";
* 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;
}
}
/**
- * 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
*/
{
private static final String GENE = "gene";
private static final String TYPE = "type";
+
/**
* Constructor given the target domain to fetch data from
*
* @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);
}
/**
*/
public List<String> getGeneIds(String identifier)
{
- List<String> result = new ArrayList<String>();
- List<String> ids = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
+ List<String> ids = new ArrayList<>();
ids.add(identifier);
String[] queries = identifier.split(getAccessionSeparator());
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;
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;
public SequenceFetcher()
{
addDBRefSourceImpl(EnsemblGene.class);
- addDBRefSourceImpl(EnsemblGenomes.class);
addDBRefSourceImpl(EmblSource.class);
addDBRefSourceImpl(EmblCdsSource.class);
addDBRefSourceImpl(Uniprot.class);
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());
/*
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- * 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<int[]> 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<int[]> 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<SequenceFeature> 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));
- }
-
-}
super();
}
- /**
- * Constructor given the target domain to fetch data from
- *
- * @param d
- */
- public EnsemblSeqProxyAdapter(String d)
- {
- super(d);
- }
-
@Override
public String getDbName()
{
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<String> ids)
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;
{ 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" } };