Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:38:20 GMT
  2. Package jalview.ext.ensembl

File EnsemblCds.java

 

Coverage histogram

../../../img/srcFileCovDistChart6.png
27% of files have more coverage

Code metrics

4
19
8
1
141
70
10
0.53
2.38
8
1.25

Classes

Class Line # Actions
EnsemblCds 41 19 10
0.5806451458.1%
 

Contributing tests

This file is covered by 4 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.datamodel.SequenceI;
25    import jalview.io.gff.SequenceOntologyFactory;
26    import jalview.io.gff.SequenceOntologyI;
27   
28    import java.util.ArrayList;
29    import java.util.List;
30   
31    /**
32    * A client for direct fetching of CDS sequences from Ensembl (i.e. that part of
33    * the genomic sequence that is translated to protein)
34    *
35    * TODO: not currently used as CDS sequences are computed from CDS features on
36    * transcripts - delete this class?
37    *
38    * @author gmcarstairs
39    *
40    */
 
41    public class EnsemblCds extends EnsemblSeqProxy
42    {
43    /*
44    * fetch cds features on genomic sequence (to identify the CDS regions)
45    * and exon and variation features (to retain for display)
46    */
47    private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
48    EnsemblFeatureType.cds, EnsemblFeatureType.exon,
49    EnsemblFeatureType.variation };
50   
51    /**
52    * Default constructor (to use rest.ensembl.org)
53    */
 
54  4 toggle public EnsemblCds()
55    {
56  4 super();
57    }
58   
59    /**
60    * Constructor given the target domain to fetch data from
61    *
62    * @param d
63    */
 
64  0 toggle public EnsemblCds(String d)
65    {
66  0 super(d);
67    }
68   
 
69  0 toggle @Override
70    public String getDbName()
71    {
72  0 return "ENSEMBL (CDS)";
73    }
74   
 
75  0 toggle @Override
76    protected EnsemblSeqType getSourceEnsemblType()
77    {
78  0 return EnsemblSeqType.CDS;
79    }
80   
 
81  0 toggle @Override
82    protected EnsemblFeatureType[] getFeaturesToFetch()
83    {
84  0 return FEATURES_TO_FETCH;
85    }
86   
87    /**
88    * Answers true unless the feature type is 'CDS' (or a sub-type of CDS in the
89    * Sequence Ontology). CDS features are only retrieved in order to identify
90    * the cds sequence range, and are redundant information on the cds sequence
91    * itself.
92    */
 
93  5 toggle @Override
94    protected boolean retainFeature(SequenceFeature sf, String accessionId)
95    {
96  5 if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
97    SequenceOntologyI.CDS))
98    {
99  2 return false;
100    }
101  3 return featureMayBelong(sf, accessionId);
102    }
103   
104    /**
105    * Answers a list of sequence features (if any) whose type is 'CDS' (or a
106    * subtype of CDS in the Sequence Ontology), and whose Parent is the
107    * transcript we are retrieving
108    */
 
109  2 toggle @Override
110    protected List<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
111    String accId)
112    {
113  2 List<SequenceFeature> result = new ArrayList<>();
114  2 List<SequenceFeature> sfs = seq.getFeatures()
115    .getFeaturesByOntology(SequenceOntologyI.CDS);
116  2 for (SequenceFeature sf : sfs)
117    {
118  7 String parentFeature = (String) sf.getValue(PARENT);
119  7 if (accId.equals(parentFeature))
120    {
121  4 result.add(sf);
122    }
123    }
124  2 return result;
125    }
126   
127    /**
128    * Overrides this method to trivially return a range which is the whole of the
129    * nucleotide sequence. This is both faster than scanning for CDS features,
130    * and also means we don't need to keep CDS features on CDS sequence (where
131    * they are redundant information).
132    */
 
133  0 toggle protected List<int[]> getCdsRanges(SequenceI dnaSeq)
134    {
135  0 int len = dnaSeq.getLength();
136  0 List<int[]> ranges = new ArrayList<>();
137  0 ranges.add(new int[] { 1, len });
138  0 return ranges;
139    }
140   
141    }