1 package jalview.ext.ensembl;
3 import jalview.datamodel.SequenceFeature;
4 import jalview.datamodel.SequenceI;
5 import jalview.io.gff.SequenceOntologyFactory;
6 import jalview.io.gff.SequenceOntologyI;
8 import java.util.ArrayList;
12 * A client for direct fetching of CDS sequences from Ensembl (i.e. that part of
13 * the genomic sequence that is translated to protein)
15 * TODO: not currently used as CDS sequences are computed from CDS features on
16 * transcripts - delete this class?
21 public class EnsemblCds extends EnsemblSeqProxy
24 * fetch cds features on genomic sequence (to identify the CDS regions)
25 * and exon and variation features (to retain for display)
27 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
28 EnsemblFeatureType.cds, EnsemblFeatureType.exon,
29 EnsemblFeatureType.variation };
32 * Default constructor (to use rest.ensembl.org)
40 * Constructor given the target domain to fetch data from
44 public EnsemblCds(String d)
50 public String getDbName()
52 return "ENSEMBL (CDS)";
56 protected EnsemblSeqType getSourceEnsemblType()
58 return EnsemblSeqType.CDS;
62 protected EnsemblFeatureType[] getFeaturesToFetch()
64 return FEATURES_TO_FETCH;
68 * Answers true unless the feature type is 'CDS' (or a sub-type of CDS in the
69 * Sequence Ontology). CDS features are only retrieved in order to identify
70 * the cds sequence range, and are redundant information on the cds sequence
74 protected boolean retainFeature(SequenceFeature sf, String accessionId)
76 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
77 SequenceOntologyI.CDS))
81 return featureMayBelong(sf, accessionId);
85 * Answers true if the sequence feature type is 'CDS' (or a subtype of CDS in
86 * the Sequence Ontology), and the Parent of the feature is the transcript we
90 protected boolean identifiesSequence(SequenceFeature sf, String accId)
92 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
93 SequenceOntologyI.CDS))
95 String parentFeature = (String) sf.getValue(PARENT);
96 if (("transcript:" + accId).equals(parentFeature))
105 * Overrides this method to trivially return a range which is the whole of the
106 * nucleotide sequence. This is both faster than scanning for CDS features,
107 * and also means we don't need to keep CDS features on CDS sequence (where
108 * they are redundant information).
110 protected List<int[]> getCdsRanges(SequenceI dnaSeq)
112 int len = dnaSeq.getLength();
113 List<int[]> ranges = new ArrayList<int[]>();
114 ranges.add(new int[] { 1, len });