Clover icon

jalviewX

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

File EnsemblProtein.java

 

Coverage histogram

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

Code metrics

2
15
11
1
145
68
13
0.87
1.36
11
1.18

Classes

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