1. Project Clover database Fri Dec 6 2024 13:47:14 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 262 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  608321 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
79    {
80  608339 this.height = seqCount;
81  608386 this.gapped = gaps;
82  608394 this.maxCount = max;
83  608401 this.modalResidue = modalRes;
84    }
85   
 
86  623117 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount,
87    int seqWithSSCount)
88    {
89  623142 this.height = ssCount;
90  623181 this.gapped = gaps;
91  623195 this.maxSSCount = maxSSCount;
92  623190 this.modalSS = modalSS;
93  623181 this.setSeqWithSSCount(seqWithSSCount);
94    }
95   
96    /* (non-Javadoc)
97    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
98    */
 
99  590019 toggle @Override
100    public void setCounts(ResidueCount residueCounts)
101    {
102  590038 this.counts = residueCounts;
103    }
104   
 
105  604866 toggle @Override
106    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
107    {
108  604871 this.ssCounts = secondaryStructureCount;
109    }
110   
111    /* (non-Javadoc)
112    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
113    */
 
114  666707 toggle @Override
115    public float getPercentageIdentity(boolean ignoreGaps)
116    {
117  666708 if (height == 0)
118    {
119  0 return 0f;
120    }
121  666722 float pid = 0f;
122  666754 if (ignoreGaps && gapped < height)
123    {
124  343310 pid = (maxCount * 100f) / (height - gapped);
125    }
126    else
127    {
128  323424 pid = (maxCount * 100f) / height;
129    }
130  666729 return pid;
131    }
132   
 
133  523138 toggle @Override
134    public float getSSPercentageIdentity(boolean ignoreGaps)
135    {
136  523138 if (height == 0)
137    {
138  501586 return 0f;
139    }
140  21552 float ssPid = 0f;
141  21552 if (ignoreGaps && gapped < height)
142    {
143  0 ssPid = (maxSSCount * 100f) / (height - gapped);
144    }
145    else
146    {
147  21552 ssPid = (maxSSCount * 100f) / height;
148    }
149  21552 return ssPid;
150    }
151   
152    /* (non-Javadoc)
153    * @see jalview.datamodel.ProfileI#getCounts()
154    */
 
155  387103 toggle @Override
156    public ResidueCount getCounts()
157    {
158  387115 return counts;
159    }
160   
 
161  523138 toggle @Override
162    public SecondaryStructureCount getSSCounts()
163    {
164  523138 return ssCounts;
165    }
166   
167    /* (non-Javadoc)
168    * @see jalview.datamodel.ProfileI#getHeight()
169    */
 
170  155412 toggle @Override
171    public int getHeight()
172    {
173  155417 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  790892 toggle @Override
204    public String getModalResidue()
205    {
206  790929 return modalResidue;
207    }
208   
 
209  999120 toggle @Override
210    public String getModalSS()
211    {
212  999120 return modalSS;
213    }
214   
215    /* (non-Javadoc)
216    * @see jalview.datamodel.ProfileI#getNonGapped()
217    */
 
218  740994 toggle @Override
219    public int getNonGapped()
220    {
221  741001 return height - gapped;
222    }
223   
 
224  927 toggle public int getSeqWithSSCount()
225    {
226  927 return seqWithSSCount;
227    }
228   
 
229  623172 toggle public void setSeqWithSSCount(int seqWithSSCount)
230    {
231  623188 this.seqWithSSCount = seqWithSSCount;
232    }
233    }