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