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.io.gff.SequenceOntologyFactory;
25 import jalview.io.gff.SequenceOntologyI;
27 import com.stevesoft.pat.Regex;
30 * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
31 * sequence that is transcribed to RNA, but not necessarily translated to
37 public class EnsemblCdna extends EnsemblSeqProxy
40 * accepts ENST or ENSTG with 11 digits
41 * or ENSMUST or similar for other species
42 * or CCDSnnnnn.nn with at least 3 digits
44 private static final Regex ACCESSION_REGEX = new Regex(
45 "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
48 * fetch exon features on genomic sequence (to identify the cdna regions)
49 * and cds and variation features (to retain)
51 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
52 EnsemblFeatureType.exon, EnsemblFeatureType.cds,
53 EnsemblFeatureType.variation };
56 * Default constructor (to use rest.ensembl.org)
64 * Constructor given the target domain to fetch data from
68 public EnsemblCdna(String d)
74 public String getDbName()
76 return "ENSEMBL (CDNA)";
80 protected EnsemblSeqType getSourceEnsemblType()
82 return EnsemblSeqType.CDNA;
86 public Regex getAccessionValidator()
88 return ACCESSION_REGEX;
92 protected EnsemblFeatureType[] getFeaturesToFetch()
94 return FEATURES_TO_FETCH;
98 * Answers true unless the feature type is 'transcript' (or a sub-type in the
102 protected boolean retainFeature(SequenceFeature sf, String accessionId)
104 if (isTranscript(sf.getType()))
108 return featureMayBelong(sf, accessionId);
112 * Answers true if the sequence feature type is 'exon' (or a subtype of exon
113 * in the Sequence Ontology), and the Parent of the feature is the transcript
117 protected boolean identifiesSequence(SequenceFeature sf, String accId)
119 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
120 SequenceOntologyI.EXON))
122 String parentFeature = (String) sf.getValue(PARENT);
123 if (("transcript:" + accId).equals(parentFeature))
132 * Parameter object_type=Transcaript added to ensure cdna and not peptide is
133 * returned (JAL-2529)
136 protected String getObjectType()
138 return OBJECT_TYPE_TRANSCRIPT;