Clover icon

jalviewX

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

File Consensus.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
19
5
1
97
50
9
0.47
3.8
5
1.8

Classes

Class Line # Actions
Consensus 27 19 9 2
0.937593.8%
 

Contributing tests

This file is covered by 7 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  372 toggle public Consensus(String mask, double threshold)
36    {
37    // this.id = id;
38    // this.mask = mask;
39  372 this.maskstr = mask;
40  372 setMask(mask);
41  372 this.threshold = threshold;
42    }
43   
 
44  372 toggle public void setMask(String s)
45    {
46  372 this.mask = setNums(s);
47   
48    // for (int i=0; i < mask.length; i++) {
49    // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]);
50    // }
51    }
52   
53    /**
54    * @deprecated Use {@link #isConserved(int[][],int,int,boolean)} instead
55    */
 
56  0 toggle public boolean isConserved(int[][] cons2, int col, int size)
57    {
58  0 return isConserved(cons2, col, size, true);
59    }
60   
 
61  154 toggle public boolean isConserved(int[][] cons2, int col, int size,
62    boolean includeGaps)
63    {
64  154 int tot = 0;
65  154 if (!includeGaps)
66    {
67  15 size -= cons2[col][cons2[col].length - 1];
68    }
69  478 for (int i = 0; i < mask.length; i++)
70    {
71  324 tot += cons2[col][mask[i]];
72    }
73   
74  154 if ((double) tot > ((threshold * size) / 100))
75    {
76    // System.out.println("True conserved "+tot+" from "+threshold+" out of
77    // "+size+" : "+maskstr);
78  23 return true;
79    }
80   
81  131 return false;
82    }
83   
 
84  372 toggle int[] setNums(String s)
85    {
86  372 int[] out = new int[s.length()];
87  372 int i = 0;
88   
89  1032 while (i < s.length())
90    {
91  660 out[i] = ResidueProperties.aaIndex[s.charAt(i)];
92  660 i++;
93    }
94   
95  372 return out;
96    }
97    }