Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.datamodel

File Profile.java

 

Coverage histogram

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

Code metrics

4
18
9
1
162
69
12
0.67
2
9
1.33

Classes

Class Line # Actions
Profile 29 18 12 4
0.8709677587.1%
 

Contributing tests

This file is covered by 85 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    /*
37    * the number of sequences (gapped or not) in the profile
38    */
39    private int height;
40   
41    /*
42    * the number of non-gapped sequences in the profile
43    */
44    private int gapped;
45   
46    /*
47    * the highest count for any residue in the profile
48    */
49    private int maxCount;
50   
51    /*
52    * the residue (e.g. K) or residues (e.g. KQW) with the
53    * highest count in the profile
54    */
55    private String modalResidue;
56   
57    /**
58    * Constructor which allows derived data to be stored without having to store
59    * the full profile
60    *
61    * @param seqCount
62    * the number of sequences in the profile
63    * @param gaps
64    * the number of gapped sequences
65    * @param max
66    * the highest count for any residue
67    * @param modalres
68    * the residue (or concatenated residues) with the highest count
69    */
 
70  117505 toggle public Profile(int seqCount, int gaps, int max, String modalRes)
71    {
72  117504 this.height = seqCount;
73  117505 this.gapped = gaps;
74  117506 this.maxCount = max;
75  117506 this.modalResidue = modalRes;
76    }
77   
78    /* (non-Javadoc)
79    * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
80    */
 
81  96615 toggle @Override
82    public void setCounts(ResidueCount residueCounts)
83    {
84  96615 this.counts = residueCounts;
85    }
86   
87    /* (non-Javadoc)
88    * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
89    */
 
90  371857 toggle @Override
91    public float getPercentageIdentity(boolean ignoreGaps)
92    {
93  371861 if (height == 0)
94    {
95  0 return 0f;
96    }
97  371864 float pid = 0f;
98  371943 if (ignoreGaps && gapped < height)
99    {
100  275092 pid = (maxCount * 100f) / (height - gapped);
101    }
102    else
103    {
104  96856 pid = (maxCount * 100f) / height;
105    }
106  371894 return pid;
107    }
108   
109    /* (non-Javadoc)
110    * @see jalview.datamodel.ProfileI#getCounts()
111    */
 
112  144745 toggle @Override
113    public ResidueCount getCounts()
114    {
115  144745 return counts;
116    }
117   
118    /* (non-Javadoc)
119    * @see jalview.datamodel.ProfileI#getHeight()
120    */
 
121  48224 toggle @Override
122    public int getHeight()
123    {
124  48224 return height;
125    }
126   
127    /* (non-Javadoc)
128    * @see jalview.datamodel.ProfileI#getGapped()
129    */
 
130  0 toggle @Override
131    public int getGapped()
132    {
133  0 return gapped;
134    }
135   
136    /* (non-Javadoc)
137    * @see jalview.datamodel.ProfileI#getMaxCount()
138    */
 
139  5 toggle @Override
140    public int getMaxCount()
141    {
142  5 return maxCount;
143    }
144   
145    /* (non-Javadoc)
146    * @see jalview.datamodel.ProfileI#getModalResidue()
147    */
 
148  421730 toggle @Override
149    public String getModalResidue()
150    {
151  421731 return modalResidue;
152    }
153   
154    /* (non-Javadoc)
155    * @see jalview.datamodel.ProfileI#getNonGapped()
156    */
 
157  116460 toggle @Override
158    public int getNonGapped()
159    {
160  116459 return height - gapped;
161    }
162    }