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.SequenceOntologyI;
26 import jalview.util.Platform;
28 import java.util.ArrayList;
29 import java.util.List;
31 import com.stevesoft.pat.Regex;
34 * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
35 * sequence that is transcribed to RNA, but not necessarily translated to
41 public class EnsemblCdna extends EnsemblSeqProxy
44 * accepts ENST or ENSTG with 11 digits
45 * or ENSMUST or similar for other species
46 * or CCDSnnnnn.nn with at least 3 digits
48 private static Regex ACCESSION_REGEX;
50 * fetch exon features on genomic sequence (to identify the cdna regions)
51 * and cds and variation features (to retain)
53 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
54 EnsemblFeatureType.exon, EnsemblFeatureType.cds,
55 EnsemblFeatureType.variation };
58 * Default constructor (to use rest.ensembl.org)
66 * Constructor given the target domain to fetch data from
70 public EnsemblCdna(String d)
76 public String getDbName()
78 return "ENSEMBL (CDNA)";
82 protected EnsemblSeqType getSourceEnsemblType()
84 return EnsemblSeqType.CDNA;
88 public Regex getAccessionValidator()
90 if (ACCESSION_REGEX == null)
93 * accepts ENSG/T/E/P with 11 digits
94 * or ENSMUSP or similar for other species
95 * or CCDSnnnnn.nn with at least 3 digits
97 ACCESSION_REGEX = Platform.newRegex(
98 "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)", null);
100 return ACCESSION_REGEX;
104 protected EnsemblFeatureType[] getFeaturesToFetch()
106 return FEATURES_TO_FETCH;
110 * Answers true unless the feature type is 'transcript' (or a sub-type in the
111 * Sequence Ontology).
114 protected boolean retainFeature(SequenceFeature sf, String accessionId)
116 if (isTranscript(sf.getType()))
120 return featureMayBelong(sf, accessionId);
124 * Answers a list of sequence features (if any) whose type is 'exon' (or a
125 * subtype of exon in the Sequence Ontology), and whose Parent is the
126 * transcript we are retrieving
129 protected List<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
132 List<SequenceFeature> result = new ArrayList<>();
133 List<SequenceFeature> sfs = seq.getFeatures()
134 .getFeaturesByOntology(SequenceOntologyI.EXON);
135 for (SequenceFeature sf : sfs)
137 String parentFeature = (String) sf.getValue(PARENT);
138 if (accId.equals(parentFeature))
148 * Parameter object_type=Transcaript added to ensure cdna and not peptide is
149 * returned (JAL-2529)
152 protected String getObjectType()
154 return OBJECT_TYPE_TRANSCRIPT;