2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ext.ensembl;
23 import jalview.datamodel.SequenceFeature;
24 import jalview.datamodel.SequenceI;
25 import jalview.io.gff.SequenceOntologyFactory;
26 import jalview.io.gff.SequenceOntologyI;
28 import java.util.ArrayList;
29 import java.util.List;
32 * A client for direct fetching of CDS sequences from Ensembl (i.e. that part of
33 * the genomic sequence that is translated to protein)
35 * TODO: not currently used as CDS sequences are computed from CDS features on
36 * transcripts - delete this class?
41 public class EnsemblCds extends EnsemblSeqProxy
44 * fetch cds features on genomic sequence (to identify the CDS regions)
45 * and exon and variation features (to retain for display)
47 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
48 EnsemblFeatureType.cds, EnsemblFeatureType.exon,
49 EnsemblFeatureType.variation };
52 * Default constructor (to use rest.ensembl.org)
60 * Constructor given the target domain to fetch data from
64 public EnsemblCds(String d)
70 public String getDbName()
72 return "ENSEMBL (CDS)";
76 protected EnsemblSeqType getSourceEnsemblType()
78 return EnsemblSeqType.CDS;
82 protected EnsemblFeatureType[] getFeaturesToFetch()
84 return FEATURES_TO_FETCH;
88 * Answers true unless the feature type is 'CDS' (or a sub-type of CDS in the
89 * Sequence Ontology). CDS features are only retrieved in order to identify
90 * the cds sequence range, and are redundant information on the cds sequence
94 protected boolean retainFeature(SequenceFeature sf, String accessionId)
96 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
97 SequenceOntologyI.CDS))
101 return featureMayBelong(sf, accessionId);
105 * Answers true if the sequence feature type is 'CDS' (or a subtype of CDS in
106 * the Sequence Ontology), and the Parent of the feature is the transcript we
110 protected boolean identifiesSequence(SequenceFeature sf, String accId)
112 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
113 SequenceOntologyI.CDS))
115 String parentFeature = (String) sf.getValue(PARENT);
116 if (("transcript:" + accId).equals(parentFeature))
125 * Overrides this method to trivially return a range which is the whole of the
126 * nucleotide sequence. This is both faster than scanning for CDS features,
127 * and also means we don't need to keep CDS features on CDS sequence (where
128 * they are redundant information).
130 protected List<int[]> getCdsRanges(SequenceI dnaSeq)
132 int len = dnaSeq.getLength();
133 List<int[]> ranges = new ArrayList<int[]>();
134 ranges.add(new int[] { 1, len });