Clover icon

Coverage Report

  1. Project Clover database Wed Dec 3 2025 17:03:17 GMT
  2. Package jalview.ext.ensembl

File EnsemblCdna.java

 

Coverage histogram

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

Code metrics

4
17
9
1
149
75
11
0.65
1.89
9
1.22

Classes

Class Line # Actions
EnsemblCdna 41 17 11
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.datamodel.SequenceI;
25    import jalview.io.gff.SequenceOntologyI;
26    import jalview.util.Platform;
27   
28    import java.util.ArrayList;
29    import java.util.List;
30   
31    import com.stevesoft.pat.Regex;
32   
33    /**
34    * A client to fetch CDNA sequence from Ensembl (i.e. that part of the genomic
35    * sequence that is transcribed to RNA, but not necessarily translated to
36    * protein)
37    *
38    * @author gmcarstairs
39    *
40    */
 
41    public class EnsemblCdna extends EnsemblSeqProxy
42    {
43    /*
44    * accepts ENST or ENSTG with 11 digits
45    * or ENSMUST or similar for other species
46    * or CCDSnnnnn.nn with at least 3 digits
47    */
48    private static final Regex ACCESSION_REGEX = Platform.newRegex(
49    "(ENS([A-Z]{3}|)[TG][0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
50   
51    /*
52    * fetch exon features on genomic sequence (to identify the cdna regions)
53    * and cds and variation features (to retain)
54    */
55    private static final EnsemblFeatureType[] FEATURES_TO_FETCH = {
56    EnsemblFeatureType.exon, EnsemblFeatureType.cds,
57    EnsemblFeatureType.variation };
58   
59    /**
60    * Default constructor (to use rest.ensembl.org)
61    */
 
62  10 toggle public EnsemblCdna()
63    {
64  10 super();
65    }
66   
67    /**
68    * Constructor given the target domain to fetch data from
69    *
70    * @param d
71    */
 
72  0 toggle public EnsemblCdna(String d)
73    {
74  0 super(d);
75    }
76   
 
77  0 toggle @Override
78    public String getDbName()
79    {
80  0 return "ENSEMBL (CDNA)";
81    }
82   
 
83  0 toggle @Override
84    protected EnsemblSeqType getSourceEnsemblType()
85    {
86  0 return EnsemblSeqType.CDNA;
87    }
88   
 
89  6 toggle @Override
90    public Regex getAccessionValidator()
91    {
92  6 return ACCESSION_REGEX;
93    }
94   
 
95  0 toggle @Override
96    protected EnsemblFeatureType[] getFeaturesToFetch()
97    {
98  0 return FEATURES_TO_FETCH;
99    }
100   
101    /**
102    * Answers true unless the feature type is 'transcript' (or a sub-type in the
103    * Sequence Ontology).
104    */
 
105  7 toggle @Override
106    protected boolean retainFeature(SequenceFeature sf, String accessionId)
107    {
108  7 if (isTranscript(sf.getType()))
109    {
110  3 return false;
111    }
112  4 return featureMayBelong(sf, accessionId);
113    }
114   
115    /**
116    * Answers a list of sequence features (if any) whose type is 'exon' (or a
117    * subtype of exon in the Sequence Ontology), and whose Parent is the
118    * transcript we are retrieving
119    */
 
120  4 toggle @Override
121    protected List<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
122    String accId)
123    {
124  4 List<SequenceFeature> result = new ArrayList<>();
125  4 List<SequenceFeature> sfs = seq.getFeatures()
126    .getFeaturesByOntology(SequenceOntologyI.EXON);
127  4 for (SequenceFeature sf : sfs)
128    {
129  12 String parentFeature = (String) sf.getValue(PARENT);
130  12 if (accId.equals(parentFeature))
131    {
132  6 result.add(sf);
133    }
134    }
135   
136  4 return result;
137    }
138   
139    /**
140    * Parameter object_type=Transcaript added to ensure cdna and not peptide is
141    * returned (JAL-2529)
142    */
 
143  0 toggle @Override
144    protected String getObjectType()
145    {
146  0 return OBJECT_TYPE_TRANSCRIPT;
147    }
148   
149    }