1 package jalview.ext.ensembl;
3 import jalview.datamodel.SequenceFeature;
4 import jalview.io.gff.SequenceOntologyFactory;
5 import jalview.io.gff.SequenceOntologyI;
7 import java.util.Arrays;
10 import com.stevesoft.pat.Regex;
13 * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
14 * sequence that is transcribed to RNA, but not necessarily translated to
20 public class EnsemblCdna extends EnsemblSeqProxy
22 private static final List<String> CROSS_REFERENCES = Arrays
23 .asList(new String[] { "Uniprot/SWISSPROT", "Uniprot/SPTREMBL" });
26 * accepts ENST or ENSTG with 11 digits
27 * or ENSMUST or similar for other species
28 * or CCDSnnnnn.nn with at least 3 digits
30 private static final Regex ACCESSION_REGEX = new Regex(
31 "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
34 * fetch exon features on genomic sequence (to identify the cdna regions)
35 * and cds and variation features (to retain)
37 private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
38 EnsemblFeatureType.exon, EnsemblFeatureType.cds,
39 EnsemblFeatureType.variation };
42 * Default constructor (to use rest.ensembl.org)
50 * Constructor given the target domain to fetch data from
54 public EnsemblCdna(String d)
60 public String getDbName()
62 return "ENSEMBL (CDNA)";
66 protected EnsemblSeqType getSourceEnsemblType()
68 return EnsemblSeqType.CDNA;
72 public Regex getAccessionValidator()
74 return ACCESSION_REGEX;
78 protected EnsemblFeatureType[] getFeaturesToFetch()
80 return FEATURES_TO_FETCH;
84 * Answers true unless the feature type is 'transcript' (or a sub-type in the
88 protected boolean retainFeature(SequenceFeature sf, String accessionId)
90 if (isTranscript(sf.getType()))
94 return featureMayBelong(sf, accessionId);
98 * Answers true if the sequence feature type is 'exon' (or a subtype of exon
99 * in the Sequence Ontology), and the Parent of the feature is the transcript
103 protected boolean identifiesSequence(SequenceFeature sf, String accId)
105 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
106 SequenceOntologyI.EXON))
108 String parentFeature = (String) sf.getValue(PARENT);
109 if (("transcript:" + accId).equals(parentFeature))
118 protected List<String> getCrossReferenceDatabases()
120 return CROSS_REFERENCES;
121 // 30/01/16 also found Vega_transcript, OTTT, ENS_LRG_transcript, UCSC,
122 // HGNC_trans_name, RefSeq_mRNA, RefSeq_mRNA_predicted