373286fb9f323d3ceaf819dbb9fd7df1d466d2f2
[jalview.git] / src / jalview / ext / ensembl / EnsemblCdna.java
1 package jalview.ext.ensembl;
2
3 import jalview.datamodel.SequenceFeature;
4 import jalview.io.gff.SequenceOntologyFactory;
5 import jalview.io.gff.SequenceOntologyI;
6
7 import java.util.List;
8
9 import com.stevesoft.pat.Regex;
10
11 public class EnsemblCdna extends EnsemblSeqProxy
12 {
13   /*
14    * fetch exon features on genomic sequence (to identify the cdnaregions)
15    * and cds and variation features (to retain)
16    */
17   private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
18       EnsemblFeatureType.exon, EnsemblFeatureType.cds,
19       EnsemblFeatureType.variation };
20
21   public EnsemblCdna()
22   {
23     super();
24   }
25
26   @Override
27   public String getDbName()
28   {
29     return "ENSEMBL (CDNA)";
30   }
31
32   @Override
33   protected EnsemblSeqType getSourceEnsemblType()
34   {
35     return EnsemblSeqType.CDNA;
36   }
37
38   @Override
39   public Regex getAccessionValidator()
40   {
41     return new Regex("((ENST|ENSG|CCDS)[0-9.]{3,})");
42   }
43
44   @Override
45   protected EnsemblFeatureType[] getFeaturesToFetch()
46   {
47     return FEATURES_TO_FETCH;
48   }
49
50   /**
51    * Answers true unless the feature type is 'transcript' (or a sub-type in the
52    * Sequence Ontology).
53    */
54   @Override
55   protected boolean retainFeature(SequenceFeature sf, String accessionId)
56   {
57     if (isTranscript(sf.getType()))
58     {
59       return false;
60     }
61     return featureMayBelong(sf, accessionId);
62   }
63
64   /**
65    * Answers true if the sequence feature type is 'exon' (or a subtype of exon
66    * in the Sequence Ontology), and the Parent of the feature is the transcript
67    * we are retrieving
68    */
69   @Override
70   protected boolean identifiesSequence(SequenceFeature sf, String accId)
71   {
72     if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
73             SequenceOntologyI.EXON))
74     {
75       String parentFeature = (String) sf.getValue(PARENT);
76       if (("transcript:" + accId).equals(parentFeature))
77       {
78         return true;
79       }
80     }
81     return false;
82   }
83
84   @Override
85   protected List<String> getCrossReferenceDatabases()
86   {
87     return super.getCrossReferenceDatabases();
88     // 30/01/16 also found Vega_transcript, OTTT, ENS_LRG_transcript, UCSC,
89     // HGNC_trans_name, RefSeq_mRNA, RefSeq_mRNA_predicted
90   }
91
92 }