Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 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
149
72
13
0.87
1.36
11
1.18

Classes

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