JAL-1705 derive transcript sequences from gene sequence/GFF; handle CDS
[jalview.git] / src / jalview / ext / ensembl / EnsemblGenome.java
1 package jalview.ext.ensembl;
2
3 import jalview.datamodel.SequenceFeature;
4
5 public class EnsemblGenome extends EnsemblSeqProxy
6 {
7   /*
8    * fetch transcript features on genomic sequence (to identify the transcript 
9    * regions) and cds, exon and variation features (to retain)
10    */
11   private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
12       EnsemblFeatureType.transcript, EnsemblFeatureType.exon,
13       EnsemblFeatureType.cds /*, EnsemblFeatureType.variation */};
14
15   public EnsemblGenome()
16   {
17     super();
18   }
19
20   @Override
21   public String getDbName()
22   {
23     return "ENSEMBL (Genome)";
24   }
25
26   @Override
27   protected EnsemblSeqType getSourceEnsemblType()
28   {
29     return EnsemblSeqType.GENOMIC;
30   }
31
32   @Override
33   protected EnsemblFeatureType[] getFeaturesToFetch()
34   {
35     return FEATURES_TO_FETCH;
36   }
37
38   /**
39    * Answers true unless the feature type is 'transcript' (or a sub-type of
40    * transcript in the Sequence Ontology). Transcript features are only
41    * retrieved in order to identify the transcript sequence range, and are
42    * redundant information on the transcript sequence itself.
43    */
44   @Override
45   protected boolean retainFeature(SequenceFeature sf, String accessionId)
46   {
47     if (isTranscript(sf.getType()))
48     {
49       return false;
50     }
51     return featureMayBelong(sf, accessionId);
52   }
53
54   /**
55    * Answers true if the sequence feature type is 'transcript' (or a subtype of
56    * transcript in the Sequence Ontology), and the ID of the feature is the
57    * transcript we are retrieving
58    */
59   @Override
60   protected boolean identifiesSequence(SequenceFeature sf, String accId)
61   {
62     if (isTranscript(sf.getType()))
63     {
64       String id = (String) sf.getValue(ID);
65       if (("transcript:" + accId).equals(id))
66       {
67         return true;
68       }
69     }
70     return false;
71   }
72
73 }