Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 10:11:34 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 218 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  608791 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
79    {
80  608814 this.height = seqCount;
81  608847 this.gapped = gaps;
82  608891 this.maxCount = max;
83  608877 this.modalResidue = modalRes;
84    }
85   
 
86  625952 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount,
87    int seqWithSSCount)
88    {
89  626036 this.height = ssCount;
90  626048 this.gapped = gaps;
91  626062 this.maxSSCount = maxSSCount;
92  626063 this.modalSS = modalSS;
93  626055 this.setSeqWithSSCount(seqWithSSCount);
94    }
95   
96    /* (non-Javadoc)
97    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
98    */
 
99  590507 toggle @Override
100    public void setCounts(ResidueCount residueCounts)
101    {
102  590521 this.counts = residueCounts;
103    }
104   
 
105  607730 toggle @Override
106    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
107    {
108  607736 this.ssCounts = secondaryStructureCount;
109    }
110   
111    /* (non-Javadoc)
112    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
113    */
 
114  615923 toggle @Override
115    public float getPercentageIdentity(boolean ignoreGaps)
116    {
117  616004 if (height == 0)
118    {
119  0 return 0f;
120    }
121  615986 float pid = 0f;
122  616015 if (ignoreGaps && gapped < height)
123    {
124  341849 pid = (maxCount * 100f) / (height - gapped);
125    }
126    else
127    {
128  274157 pid = (maxCount * 100f) / height;
129    }
130  615995 return pid;
131    }
132   
 
133  526484 toggle @Override
134    public float getSSPercentageIdentity(boolean ignoreGaps)
135    {
136  526484 if (height == 0)
137    {
138  503082 return 0f;
139    }
140  23402 float ssPid = 0f;
141  23402 if (ignoreGaps && gapped < height)
142    {
143  0 ssPid = (maxSSCount * 100f) / (height - gapped);
144    }
145    else
146    {
147  23402 ssPid = (maxSSCount * 100f) / height;
148    }
149  23402 return ssPid;
150    }
151   
152    /* (non-Javadoc)
153    * @see jalview.datamodel.ProfileI#getCounts()
154    */
 
155  396383 toggle @Override
156    public ResidueCount getCounts()
157    {
158  396386 return counts;
159    }
160   
 
161  526484 toggle @Override
162    public SecondaryStructureCount getSSCounts()
163    {
164  526484 return ssCounts;
165    }
166   
167    /* (non-Javadoc)
168    * @see jalview.datamodel.ProfileI#getHeight()
169    */
 
170  157103 toggle @Override
171    public int getHeight()
172    {
173  157107 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  732262 toggle @Override
204    public String getModalResidue()
205    {
206  732266 return modalResidue;
207    }
208   
 
209  1003784 toggle @Override
210    public String getModalSS()
211    {
212  1003784 return modalSS;
213    }
214   
215    /* (non-Javadoc)
216    * @see jalview.datamodel.ProfileI#getNonGapped()
217    */
 
218  747347 toggle @Override
219    public int getNonGapped()
220    {
221  747366 return height - gapped;
222    }
223   
 
224  947 toggle public int getSeqWithSSCount()
225    {
226  947 return seqWithSSCount;
227    }
228   
 
229  626050 toggle public void setSeqWithSSCount(int seqWithSSCount)
230    {
231  626055 this.seqWithSSCount = seqWithSSCount;
232    }
233    }