Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ext.ensembl

File EnsemblCdna.java

 

Coverage histogram

../../../img/srcFileCovDistChart7.png
28% of files have more coverage

Code metrics

6
15
9
1
141
69
12
0.8
1.67
9
1.33

Classes

Class Line # Actions
EnsemblCdna 37 15 12 10
0.666666766.7%
 

Contributing tests

This file is covered by 6 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ext.ensembl;
22   
23    import jalview.datamodel.SequenceFeature;
24    import jalview.io.gff.SequenceOntologyFactory;
25    import jalview.io.gff.SequenceOntologyI;
26   
27    import com.stevesoft.pat.Regex;
28   
29    /**
30    * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
31    * sequence that is transcribed to RNA, but not necessarily translated to
32    * protein)
33    *
34    * @author gmcarstairs
35    *
36    */
 
37    public class EnsemblCdna extends EnsemblSeqProxy
38    {
39    /*
40    * accepts ENST or ENSTG with 11 digits
41    * or ENSMUST or similar for other species
42    * or CCDSnnnnn.nn with at least 3 digits
43    */
44    private static final Regex ACCESSION_REGEX = new Regex(
45    "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
46   
47    /*
48    * fetch exon features on genomic sequence (to identify the cdna regions)
49    * and cds and variation features (to retain)
50    */
51    private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
52    EnsemblFeatureType.exon, EnsemblFeatureType.cds,
53    EnsemblFeatureType.variation };
54   
55    /**
56    * Default constructor (to use rest.ensembl.org)
57    */
 
58  7 toggle public EnsemblCdna()
59    {
60  7 super();
61    }
62   
63    /**
64    * Constructor given the target domain to fetch data from
65    *
66    * @param d
67    */
 
68  0 toggle public EnsemblCdna(String d)
69    {
70  0 super(d);
71    }
72   
 
73  0 toggle @Override
74    public String getDbName()
75    {
76  0 return "ENSEMBL (CDNA)";
77    }
78   
 
79  0 toggle @Override
80    protected EnsemblSeqType getSourceEnsemblType()
81    {
82  0 return EnsemblSeqType.CDNA;
83    }
84   
 
85  6 toggle @Override
86    public Regex getAccessionValidator()
87    {
88  6 return ACCESSION_REGEX;
89    }
90   
 
91  0 toggle @Override
92    protected EnsemblFeatureType[] getFeaturesToFetch()
93    {
94  0 return FEATURES_TO_FETCH;
95    }
96   
97    /**
98    * Answers true unless the feature type is 'transcript' (or a sub-type in the
99    * Sequence Ontology).
100    */
 
101  7 toggle @Override
102    protected boolean retainFeature(SequenceFeature sf, String accessionId)
103    {
104  7 if (isTranscript(sf.getType()))
105    {
106  3 return false;
107    }
108  4 return featureMayBelong(sf, accessionId);
109    }
110   
111    /**
112    * Answers true if the sequence feature type is 'exon' (or a subtype of exon
113    * in the Sequence Ontology), and the Parent of the feature is the transcript
114    * we are retrieving
115    */
 
116  16 toggle @Override
117    protected boolean identifiesSequence(SequenceFeature sf, String accId)
118    {
119  16 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
120    SequenceOntologyI.EXON))
121    {
122  12 String parentFeature = (String) sf.getValue(PARENT);
123  12 if (("transcript:" + accId).equals(parentFeature))
124    {
125  8 return true;
126    }
127    }
128  8 return false;
129    }
130   
131    /**
132    * Parameter object_type=Transcaript added to ensure cdna and not peptide is
133    * returned (JAL-2529)
134    */
 
135  0 toggle @Override
136    protected String getObjectType()
137    {
138  0 return OBJECT_TYPE_TRANSCRIPT;
139    }
140   
141    }