20987e188ab2ffbe47bc9abb9ab466cf37de8791
[jalview.git] / src / jalview / ext / ensembl / EnsemblGenome.java
1 package jalview.ext.ensembl;
2
3 import jalview.datamodel.SequenceFeature;
4
5 /**
6  * A client to fetch genomic sequence from Ensembl
7  * 
8  * TODO: not currently used - delete?
9  * 
10  * @author gmcarstairs
11  *
12  */
13 public class EnsemblGenome extends EnsemblSeqProxy
14 {
15   /*
16    * fetch transcript features on genomic sequence (to identify the transcript 
17    * regions) and cds, exon and variation features (to retain)
18    */
19   private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
20       EnsemblFeatureType.transcript, EnsemblFeatureType.exon,
21       EnsemblFeatureType.cds, EnsemblFeatureType.variation };
22
23   /**
24    * Default constructor (to use rest.ensembl.org)
25    */
26   public EnsemblGenome()
27   {
28     super();
29   }
30
31   /**
32    * Constructor given the target domain to fetch data from
33    * 
34    * @param d
35    */
36   public EnsemblGenome(String d)
37   {
38     super(d);
39   }
40
41   @Override
42   public String getDbName()
43   {
44     return "ENSEMBL (Genomic)";
45   }
46
47   @Override
48   protected EnsemblSeqType getSourceEnsemblType()
49   {
50     return EnsemblSeqType.GENOMIC;
51   }
52
53   @Override
54   protected EnsemblFeatureType[] getFeaturesToFetch()
55   {
56     return FEATURES_TO_FETCH;
57   }
58
59   /**
60    * Answers true unless the feature type is 'transcript' (or a sub-type of
61    * transcript in the Sequence Ontology), or has a parent other than the given
62    * accession id. Transcript features are only retrieved in order to identify
63    * the transcript sequence range, and are redundant information on the
64    * transcript sequence itself.
65    */
66   @Override
67   protected boolean retainFeature(SequenceFeature sf, String accessionId)
68   {
69     if (isTranscript(sf.getType()))
70     {
71       return false;
72     }
73     return featureMayBelong(sf, accessionId);
74   }
75
76   /**
77    * Answers true if the sequence feature type is 'transcript' (or a subtype of
78    * transcript in the Sequence Ontology), and the ID of the feature is the
79    * transcript we are retrieving
80    */
81   @Override
82   protected boolean identifiesSequence(SequenceFeature sf, String accId)
83   {
84     if (isTranscript(sf.getType()))
85     {
86       String id = (String) sf.getValue(ID);
87       if (("transcript:" + accId).equals(id))
88       {
89         return true;
90       }
91     }
92     return false;
93   }
94
95 }