Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.ext.ensembl

File EnsemblProtein.java

 

Coverage histogram

../../../img/srcFileCovDistChart5.png
43% of files have more coverage

Code metrics

2
15
11
1
150
73
13
0.87
1.36
11
1.18

Classes

Class Line # Actions
EnsemblProtein 39 15 13
0.4285714342.9%
 

Contributing tests

This file is covered by 2 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.AlignmentI;
24    import jalview.datamodel.SequenceFeature;
25    import jalview.datamodel.SequenceI;
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 protein translated sequence for an Ensembl identifier
35    *
36    * @author gmcarstairs
37    *
38    */
 
39    public class EnsemblProtein extends EnsemblSeqProxy
40    {
41    /*
42    * accepts ENSP with 11 digits
43    * or ENSMUSP or similar for other species
44    * or CCDSnnnnn.nn with at least 3 digits
45    */
46    private static final Regex ACCESSION_REGEX = Platform.newRegex(
47    "(ENS([A-Z]{3}|)P[0-9]{11}$)" + "|" + "(CCDS[0-9.]{3,}$)");
48   
49    /**
50    * Default constructor (to use rest.ensembl.org)
51    */
 
52  10 toggle public EnsemblProtein()
53    {
54  10 super();
55    }
56   
57    /**
58    * Constructor given the target domain to fetch data from
59    *
60    * @param d
61    */
 
62  0 toggle public EnsemblProtein(String d)
63    {
64  0 super(d);
65    }
66   
 
67  0 toggle @Override
68    public String getDbName()
69    {
70  0 return "ENSEMBL (Protein)";
71    }
72   
 
73  0 toggle @Override
74    protected EnsemblSeqType getSourceEnsemblType()
75    {
76  0 return EnsemblSeqType.PROTEIN;
77    }
78   
79    /**
80    * Returns false, as this fetcher does not retrieve DNA sequences.
81    */
 
82  0 toggle @Override
83    public boolean isDnaCoding()
84    {
85  0 return false;
86    }
87   
88    /**
89    * Test query is to the protein translation of transcript ENST00000288602
90    */
 
91  0 toggle @Override
92    public String getTestQuery()
93    {
94  0 return "ENSP00000288602";
95    }
96   
97    /**
98    * Overrides base class method to do nothing - genomic features are not
99    * applicable to the protein product sequence
100    */
 
101  0 toggle @Override
102    protected void addFeaturesAndProduct(String accId, AlignmentI alignment)
103    {
104    }
105   
 
106  0 toggle @Override
107    protected EnsemblFeatureType[] getFeaturesToFetch()
108    {
109    // not applicable - can't fetch genomic features for a protein sequence
110  0 return null;
111    }
112   
 
113  0 toggle @Override
114    protected List<SequenceFeature> getIdentifyingFeatures(SequenceI seq,
115    String accId)
116    {
117  0 return new ArrayList<>();
118    }
119   
 
120  5 toggle @Override
121    public Regex getAccessionValidator()
122    {
123  5 return ACCESSION_REGEX;
124    }
125   
126    /**
127    * Returns an accession id for a query, including conversion of ENST* to
128    * ENSP*. This supports querying for the protein sequence for a transcript
129    * (ENST identifier) and returning the ENSP identifier.
130    */
 
131  6 toggle @Override
132    public String getAccessionIdFromQuery(String query)
133    {
134  6 String accId = super.getAccessionIdFromQuery(query);
135   
136    /*
137    * ensure last character before (11) digits is P
138    * ENST00000288602 -> ENSP00000288602
139    * ENSMUST00000288602 -> ENSMUSP00000288602
140    */
141  6 if (accId != null && accId.length() >= 12)
142    {
143  6 char[] chars = accId.toCharArray();
144  6 chars[chars.length - 12] = 'P';
145  6 accId = new String(chars);
146    }
147  6 return accId;
148    }
149   
150    }