Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.schemes

File Consensus.java

 

Coverage histogram

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

Code metrics

8
20
5
1
101
52
9
0.45
4
5
1.8

Classes

Class Line # Actions
Consensus 27 20 9
0.9090909490.9%
 

Contributing tests

This file is covered by 8 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.schemes;
22   
23    // //////////////////////////////////////////
24    // This does nothing at all at the moment!!!!!!!!!!
25    // AW 15th Dec 2004
26    // ///////////////////////////////////////
 
27    public class Consensus
28    {
29    int[] mask;
30   
31    double threshold;
32   
33    String maskstr;
34   
 
35  527 toggle public Consensus(String mask, double threshold)
36    {
37    // this.id = id;
38    // this.mask = mask;
39  527 this.maskstr = mask;
40  527 setMask(mask);
41  527 this.threshold = threshold;
42    }
43   
 
44  527 toggle public void setMask(String s)
45    {
46  527 this.mask = setNums(s);
47   
48    // for (int i=0; i < mask.length; i++) {
49    // jalview.bin.Console.outPrintln(mask[i] + " " +
50    // ResidueProperties.aa[mask[i]]);
51    // }
52    }
53   
54    /**
55    * @deprecated Use {@link #isConserved(int[][],int,int,boolean)} instead
56    */
 
57  0 toggle @Deprecated
58    public boolean isConserved(int[][] cons2, int col, int size)
59    {
60  0 jalview.bin.Console.outPrintln("DEPRECATED!!!!");
61  0 return isConserved(cons2, col, size, true);
62    }
63   
 
64  154 toggle public boolean isConserved(int[][] cons2, int col, int size,
65    boolean includeGaps)
66    {
67  154 int tot = 0;
68  154 if (!includeGaps)
69    {
70  15 size -= cons2[col][cons2[col].length - 1];
71    }
72  478 for (int i = 0; i < mask.length; i++)
73    {
74  324 tot += cons2[col][mask[i]];
75    }
76   
77  154 if (tot > ((threshold * size) / 100))
78    {
79    // jalview.bin.Console.outPrintln("True conserved "+tot+" from
80    // "+threshold+" out of
81    // "+size+" : "+maskstr);
82  23 return true;
83    }
84   
85  131 return false;
86    }
87   
 
88  527 toggle int[] setNums(String s)
89    {
90  527 int[] out = new int[s.length()];
91  527 int i = 0;
92   
93  1462 while (i < s.length())
94    {
95  935 out[i] = ResidueProperties.aaIndex[s.charAt(i)];
96  935 i++;
97    }
98   
99  527 return out;
100    }
101    }