1 package jalview.ext.ensembl;
3 import jalview.datamodel.SequenceFeature;
4 import jalview.io.gff.SequenceOntologyFactory;
5 import jalview.io.gff.SequenceOntologyI;
7 import com.stevesoft.pat.Regex;
10 * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
11 * sequence that is transcribed to RNA, but not necessarily translated to
17 public class EnsemblCdna extends EnsemblSeqProxy
20 * accepts ENST or ENSTG with 11 digits
21 * or ENSMUST or similar for other species
22 * or CCDSnnnnn.nn with at least 3 digits
24 private static final Regex ACCESSION_REGEX = new Regex(
25 "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
28 * fetch exon features on genomic sequence (to identify the cdna regions)
29 * and cds and variation features (to retain)
31 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
32 EnsemblFeatureType.exon, EnsemblFeatureType.cds,
33 EnsemblFeatureType.variation };
36 * Default constructor (to use rest.ensembl.org)
44 * Constructor given the target domain to fetch data from
48 public EnsemblCdna(String d)
54 public String getDbName()
56 return "ENSEMBL (CDNA)";
60 protected EnsemblSeqType getSourceEnsemblType()
62 return EnsemblSeqType.CDNA;
66 public Regex getAccessionValidator()
68 return ACCESSION_REGEX;
72 protected EnsemblFeatureType[] getFeaturesToFetch()
74 return FEATURES_TO_FETCH;
78 * Answers true unless the feature type is 'transcript' (or a sub-type in the
82 protected boolean retainFeature(SequenceFeature sf, String accessionId)
84 if (isTranscript(sf.getType()))
88 return featureMayBelong(sf, accessionId);
92 * Answers true if the sequence feature type is 'exon' (or a subtype of exon
93 * in the Sequence Ontology), and the Parent of the feature is the transcript
97 protected boolean identifiesSequence(SequenceFeature sf, String accId)
99 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
100 SequenceOntologyI.EXON))
102 String parentFeature = (String) sf.getValue(PARENT);
103 if (("transcript:" + accId).equals(parentFeature))