Clover icon

Coverage Report

  1. Project Clover database Mon Sep 2 2024 17:57:51 BST
  2. Package jalview.datamodel

File Profile.java

 

Coverage histogram

../../img/srcFileCovDistChart9.png
13% 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.8571428785.7%
 

Contributing tests

This file is covered by 202 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  608637 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
77    {
78  608646 this.height = seqCount;
79  608644 this.gapped = gaps;
80  608655 this.maxCount = max;
81  608661 this.modalResidue = modalRes;
82    }
83   
 
84  609488 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount)
85    {
86  609516 this.height = ssCount;
87  609540 this.gapped = gaps;
88  609562 this.maxSSCount = maxSSCount;
89  609567 this.modalSS = modalSS;
90    }
91   
92    /* (non-Javadoc)
93    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
94    */
 
95  590280 toggle @Override
96    public void setCounts(ResidueCount residueCounts)
97    {
98  590281 this.counts = residueCounts;
99    }
100   
 
101  591254 toggle @Override
102    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
103    {
104  591261 this.ssCounts = secondaryStructureCount;
105    }
106   
107    /* (non-Javadoc)
108    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
109    */
 
110  1006987 toggle @Override
111    public float getPercentageIdentity(boolean ignoreGaps)
112    {
113  1007017 if (height == 0)
114    {
115  0 return 0f;
116    }
117  1007046 float pid = 0f;
118  1007095 if (ignoreGaps && gapped < height)
119    {
120  327429 pid = (maxCount * 100f) / (height - gapped);
121    }
122    else
123    {
124  679693 pid = (maxCount * 100f) / height;
125    }
126  1007125 return pid;
127    }
128   
 
129  584153 toggle @Override
130    public float getSSPercentageIdentity(boolean ignoreGaps)
131    {
132  584204 if (height == 0)
133    {
134  571307 return 0f;
135    }
136  12960 float ssPid = 0f;
137  12960 if (ignoreGaps && gapped < height)
138    {
139  0 ssPid = (maxSSCount * 100f) / (height - gapped);
140    }
141    else
142    {
143  12960 ssPid = (maxSSCount * 100f) / height;
144    }
145  12960 return ssPid;
146    }
147   
148    /* (non-Javadoc)
149    * @see jalview.datamodel.ProfileI#getCounts()
150    */
 
151  772224 toggle @Override
152    public ResidueCount getCounts()
153    {
154  772230 return counts;
155    }
156   
 
157  584102 toggle @Override
158    public SecondaryStructureCount getSSCounts()
159    {
160  584118 return ssCounts;
161    }
162   
163    /* (non-Javadoc)
164    * @see jalview.datamodel.ProfileI#getHeight()
165    */
 
166  148051 toggle @Override
167    public int getHeight()
168    {
169  148056 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  1534362 toggle @Override
200    public String getModalResidue()
201    {
202  1534585 return modalResidue;
203    }
204   
 
205  1108323 toggle @Override
206    public String getModalSS()
207    {
208  1109051 return modalSS;
209    }
210   
211    /* (non-Javadoc)
212    * @see jalview.datamodel.ProfileI#getNonGapped()
213    */
 
214  1199818 toggle @Override
215    public int getNonGapped()
216    {
217  1199841 return height - gapped;
218    }
219    }