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