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