Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:38:20 GMT
  2. Package jalview.datamodel

File Profile.java

 

Coverage histogram

../../img/srcFileCovDistChart9.png
7% 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 99 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  75661 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
79    {
80  75661 this.height = seqCount;
81  75661 this.gapped = gaps;
82  75661 this.maxCount = max;
83  75661 this.modalResidue = modalRes;
84    }
85   
 
86  80240 toggle public Profile(String modalSS, int ssCount, int gaps, int maxSSCount,
87    int seqWithSSCount)
88    {
89  80240 this.height = ssCount;
90  80240 this.gapped = gaps;
91  80240 this.maxSSCount = maxSSCount;
92  80240 this.modalSS = modalSS;
93  80240 this.setSeqWithSSCount(seqWithSSCount);
94    }
95   
96    /* (non-Javadoc)
97    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
98    */
 
99  68050 toggle @Override
100    public void setCounts(ResidueCount residueCounts)
101    {
102  68050 this.counts = residueCounts;
103    }
104   
 
105  72660 toggle @Override
106    public void setSSCounts(SecondaryStructureCount secondaryStructureCount)
107    {
108  72660 this.ssCounts = secondaryStructureCount;
109    }
110   
111    /* (non-Javadoc)
112    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
113    */
 
114  69476 toggle @Override
115    public float getPercentageIdentity(boolean ignoreGaps)
116    {
117  69476 if (height == 0)
118    {
119  0 return 0f;
120    }
121  69476 float pid = 0f;
122  69476 if (ignoreGaps && gapped < height)
123    {
124  12 pid = (maxCount * 100f) / (height - gapped);
125    }
126    else
127    {
128  69464 pid = (maxCount * 100f) / height;
129    }
130  69476 return pid;
131    }
132   
 
133  21194 toggle @Override
134    public float getSSPercentageIdentity(boolean ignoreGaps)
135    {
136  21194 if (height == 0)
137    {
138  12240 return 0f;
139    }
140  8954 float ssPid = 0f;
141  8954 if (ignoreGaps && gapped < height)
142    {
143  0 ssPid = (maxSSCount * 100f) / (height - gapped);
144    }
145    else
146    {
147  8954 ssPid = (maxSSCount * 100f) / height;
148    }
149  8954 return ssPid;
150    }
151   
152    /* (non-Javadoc)
153    * @see jalview.datamodel.ProfileI#getCounts()
154    */
 
155  77685 toggle @Override
156    public ResidueCount getCounts()
157    {
158  77685 return counts;
159    }
160   
 
161  21194 toggle @Override
162    public SecondaryStructureCount getSSCounts()
163    {
164  21194 return ssCounts;
165    }
166   
167    /* (non-Javadoc)
168    * @see jalview.datamodel.ProfileI#getHeight()
169    */
 
170  10868 toggle @Override
171    public int getHeight()
172    {
173  10871 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  134604 toggle @Override
204    public String getModalResidue()
205    {
206  134604 return modalResidue;
207    }
208   
 
209  39392 toggle @Override
210    public String getModalSS()
211    {
212  39392 return modalSS;
213    }
214   
215    /* (non-Javadoc)
216    * @see jalview.datamodel.ProfileI#getNonGapped()
217    */
 
218  88596 toggle @Override
219    public int getNonGapped()
220    {
221  88597 return height - gapped;
222    }
223   
 
224  336 toggle public int getSeqWithSSCount()
225    {
226  336 return seqWithSSCount;
227    }
228   
 
229  80240 toggle public void setSeqWithSSCount(int seqWithSSCount)
230    {
231  80240 this.seqWithSSCount = seqWithSSCount;
232    }
233    }