JAL-1705 additional tests, validation regexp tweaks, javadoc
[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 (Genomic)";
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), or has a parent other than the given
41    * accession id. Transcript features are only retrieved in order to identify
42    * the transcript sequence range, and are redundant information on the
43    * transcript sequence itself.
44    */
45   @Override
46   protected boolean retainFeature(SequenceFeature sf, String accessionId)
47   {
48     if (isTranscript(sf.getType()))
49     {
50       return false;
51     }
52     return featureMayBelong(sf, accessionId);
53   }
54
55   /**
56    * Answers true if the sequence feature type is 'transcript' (or a subtype of
57    * transcript in the Sequence Ontology), and the ID of the feature is the
58    * transcript we are retrieving
59    */
60   @Override
61   protected boolean identifiesSequence(SequenceFeature sf, String accId)
62   {
63     if (isTranscript(sf.getType()))
64     {
65       String id = (String) sf.getValue(ID);
66       if (("transcript:" + accId).equals(id))
67       {
68         return true;
69       }
70     }
71     return false;
72   }
73
74 }