Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 20:42:03 GMT
  2. Package jalview.datamodel

File Profile.java

 

Coverage histogram

../../img/srcFileCovDistChart9.png
12% of files have more coverage

Code metrics

8
36
17
1
233
128
23
0.64
2.12
17
1.35

Classes

Class Line # Actions
Profile 29 36 23
0.8688524486.9%
 

Contributing tests

This file is covered by 211 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    private int seqWithSSCount = -1;
39   
40    /*
41    * the number of sequences (gapped or not) in the profile
42    */
43    private int height;
44   
45    /*
46    * the number of non-gapped sequences in the profile
47    */
48    private int gapped;
49   
50    /*
51    * the highest count for any residue in the profile
52    */
53    private int maxCount;
54   
55    private int maxSSCount;
56   
57    /*
58    * the residue (e.g. K) or residues (e.g. KQW) with the
59    * highest count in the profile
60    */
61    private String modalResidue;
62   
63    private String modalSS;
64   
65    /**
66    * Constructor which allows derived data to be stored without having to store
67    * the full profile
68    *
69    * @param seqCount
70    * the number of sequences in the profile
71    * @param gaps
72    * the number of gapped sequences
73    * @param max
74    * the highest count for any residue
75    * @param modalres
76    * the residue (or concatenated residues) with the highest count
77    */
 
78  610316 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
79    {
80  610326 this.height = seqCount;
81  610336 this.gapped = gaps;
82  610383 this.maxCount = max;
83  610468 this.modalResidue = modalRes;
84    }
85   
 
86  622984 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount,
87    int seqWithSSCount)
88    {
89  622990 this.height = ssCount;
90  623021 this.gapped = gaps;
91  623030 this.maxSSCount = maxSSCount;
92  623025 this.modalSS = modalSS;
93  622997 this.setSeqWithSSCount(seqWithSSCount);
94    }
95   
96    /* (non-Javadoc)
97    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
98    */
 
99  592104 toggle @Override
100    public void setCounts(ResidueCount residueCounts)
101    {
102  592121 this.counts = residueCounts;
103    }
104   
 
105  604627 toggle @Override
106    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
107    {
108  604668 this.ssCounts = secondaryStructureCount;
109    }
110   
111    /* (non-Javadoc)
112    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
113    */
 
114  840262 toggle @Override
115    public float getPercentageIdentity(boolean ignoreGaps)
116    {
117  840318 if (height == 0)
118    {
119  0 return 0f;
120    }
121  840311 float pid = 0f;
122  840325 if (ignoreGaps && gapped < height)
123    {
124  544610 pid = (maxCount * 100f) / (height - gapped);
125    }
126    else
127    {
128  295709 pid = (maxCount * 100f) / height;
129    }
130  840300 return pid;
131    }
132   
 
133  523141 toggle @Override
134    public float getSSPercentageIdentity(boolean ignoreGaps)
135    {
136  523141 if (height == 0)
137    {
138  501726 return 0f;
139    }
140  21415 float ssPid = 0f;
141  21415 if (ignoreGaps && gapped < height)
142    {
143  0 ssPid = (maxSSCount * 100f) / (height - gapped);
144    }
145    else
146    {
147  21415 ssPid = (maxSSCount * 100f) / height;
148    }
149  21415 return ssPid;
150    }
151   
152    /* (non-Javadoc)
153    * @see jalview.datamodel.ProfileI#getCounts()
154    */
 
155  459077 toggle @Override
156    public ResidueCount getCounts()
157    {
158  459083 return counts;
159    }
160   
 
161  523141 toggle @Override
162    public SecondaryStructureCount getSSCounts()
163    {
164  523141 return ssCounts;
165    }
166   
167    /* (non-Javadoc)
168    * @see jalview.datamodel.ProfileI#getHeight()
169    */
 
170  178151 toggle @Override
171    public int getHeight()
172    {
173  178159 return height;
174    }
175   
176    /* (non-Javadoc)
177    * @see jalview.datamodel.ProfileI#getGapped()
178    */
 
179  0 toggle @Override
180    public int getGapped()
181    {
182  0 return gapped;
183    }
184   
185    /* (non-Javadoc)
186    * @see jalview.datamodel.ProfileI#getMaxCount()
187    */
 
188  5 toggle @Override
189    public int getMaxCount()
190    {
191  5 return maxCount;
192    }
193   
 
194  0 toggle @Override
195    public int getMaxSSCount()
196    {
197  0 return maxSSCount;
198    }
199   
200    /* (non-Javadoc)
201    * @see jalview.datamodel.ProfileI#getModalResidue()
202    */
 
203  959737 toggle @Override
204    public String getModalResidue()
205    {
206  959791 return modalResidue;
207    }
208   
 
209  999434 toggle @Override
210    public String getModalSS()
211    {
212  999434 return modalSS;
213    }
214   
215    /* (non-Javadoc)
216    * @see jalview.datamodel.ProfileI#getNonGapped()
217    */
 
218  755569 toggle @Override
219    public int getNonGapped()
220    {
221  755570 return height - gapped;
222    }
223   
 
224  924 toggle public int getSeqWithSSCount()
225    {
226  924 return seqWithSSCount;
227    }
228   
 
229  622974 toggle public void setSeqWithSSCount(int seqWithSSCount)
230    {
231  622994 this.seqWithSSCount = seqWithSSCount;
232    }
233    }