Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 18:27:33 GMT
  2. Package jalview.datamodel

File Profile.java

 

Coverage histogram

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

Code metrics

8
33
15
1
219
117
21
0.64
2.2
15
1.4

Classes

Class Line # Actions
Profile 29 33 21
0.6071428760.7%
 

Contributing tests

This file is covered by 341 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.datamodel;
22   
23    /**
24    * A profile for one column of an alignment
25    *
26    * @author gmcarstairs
27    *
28    */
 
29    public class Profile implements ProfileI
30    {
31    /*
32    * an object holding counts of symbols in the profile
33    */
34    private ResidueCount counts;
35   
36    private SecondaryStructureCount ssCounts;
37   
38    /*
39    * the number of sequences (gapped or not) in the profile
40    */
41    private int height;
42   
43    /*
44    * the number of non-gapped sequences in the profile
45    */
46    private int gapped;
47   
48    /*
49    * the highest count for any residue in the profile
50    */
51    private int maxCount;
52   
53    private int maxSSCount;
54   
55    /*
56    * the residue (e.g. K) or residues (e.g. KQW) with the
57    * highest count in the profile
58    */
59    private String modalResidue;
60   
61    private String modalSS;
62   
63    /**
64    * Constructor which allows derived data to be stored without having to store
65    * the full profile
66    *
67    * @param seqCount
68    * the number of sequences in the profile
69    * @param gaps
70    * the number of gapped sequences
71    * @param max
72    * the highest count for any residue
73    * @param modalres
74    * the residue (or concatenated residues) with the highest count
75    */
 
76  612448 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
77    {
78  612459 this.height = seqCount;
79  612457 this.gapped = gaps;
80  612464 this.maxCount = max;
81  612490 this.modalResidue = modalRes;
82    }
83   
 
84  40058 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount)
85    {
86  40058 this.height = ssCount;
87  40058 this.gapped = gaps;
88  40058 this.maxSSCount = maxSSCount;
89  40058 this.modalSS = modalSS;
90    }
91   
92    /* (non-Javadoc)
93    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
94    */
 
95  594142 toggle @Override
96    public void setCounts(ResidueCount residueCounts)
97    {
98  594145 this.counts = residueCounts;
99    }
100   
 
101  21744 toggle @Override
102    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
103    {
104  21744 this.ssCounts = secondaryStructureCount;
105    }
106   
107    /* (non-Javadoc)
108    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
109    */
 
110  768189 toggle @Override
111    public float getPercentageIdentity(boolean ignoreGaps)
112    {
113  768224 if (height == 0)
114    {
115  0 return 0f;
116    }
117  768222 float pid = 0f;
118  768237 if (ignoreGaps && gapped < height)
119    {
120  487797 pid = (maxCount * 100f) / (height - gapped);
121    }
122    else
123    {
124  280441 pid = (maxCount * 100f) / height;
125    }
126  768216 return pid;
127    }
128   
 
129  0 toggle @Override
130    public float getSSPercentageIdentity(boolean ignoreGaps)
131    {
132  0 if (height == 0)
133    {
134  0 return 0f;
135    }
136  0 float ssPid = 0f;
137  0 if (ignoreGaps && gapped < height)
138    {
139  0 ssPid = (maxSSCount * 100f) / (height - gapped);
140    }
141    else
142    {
143  0 ssPid = (maxSSCount * 100f) / height;
144    }
145  0 return ssPid;
146    }
147   
148    /* (non-Javadoc)
149    * @see jalview.datamodel.ProfileI#getCounts()
150    */
 
151  386381 toggle @Override
152    public ResidueCount getCounts()
153    {
154  386380 return counts;
155    }
156   
 
157  0 toggle @Override
158    public SecondaryStructureCount getSSCounts()
159    {
160  0 return ssCounts;
161    }
162   
163    /* (non-Javadoc)
164    * @see jalview.datamodel.ProfileI#getHeight()
165    */
 
166  117369 toggle @Override
167    public int getHeight()
168    {
169  117369 return height;
170    }
171   
172    /* (non-Javadoc)
173    * @see jalview.datamodel.ProfileI#getGapped()
174    */
 
175  0 toggle @Override
176    public int getGapped()
177    {
178  0 return gapped;
179    }
180   
181    /* (non-Javadoc)
182    * @see jalview.datamodel.ProfileI#getMaxCount()
183    */
 
184  5 toggle @Override
185    public int getMaxCount()
186    {
187  5 return maxCount;
188    }
189   
 
190  0 toggle @Override
191    public int getMaxSSCount()
192    {
193  0 return maxSSCount;
194    }
195   
196    /* (non-Javadoc)
197    * @see jalview.datamodel.ProfileI#getModalResidue()
198    */
 
199  887178 toggle @Override
200    public String getModalResidue()
201    {
202  887214 return modalResidue;
203    }
204   
 
205  0 toggle @Override
206    public String getModalSS()
207    {
208  0 return modalSS;
209    }
210   
211    /* (non-Javadoc)
212    * @see jalview.datamodel.ProfileI#getNonGapped()
213    */
 
214  211539 toggle @Override
215    public int getNonGapped()
216    {
217  211545 return height - gapped;
218    }
219    }