Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.schemes

File CovariationColourScheme.java

 

Coverage histogram

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

Code metrics

8
19
7
1
160
74
11
0.58
2.71
7
1.57

Classes

Class Line # Actions
CovariationColourScheme 38 19 11
0.00%
 

Contributing tests

No tests hitting this source file were found.

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    import jalview.api.AlignViewportI;
24    import jalview.datamodel.AlignmentAnnotation;
25    import jalview.datamodel.AnnotatedCollectionI;
26    import jalview.util.ColorUtils;
27   
28    import java.awt.Color;
29    import java.util.Hashtable;
30    import java.util.Map;
31   
32    /**
33    * Became RNAHelicesColour.java. Placeholder for true covariation color scheme
34    *
35    * @author Lauren Michelle Lui
36    * @version 2.5
37    */
 
38    public class CovariationColourScheme extends ResidueColourScheme
39    {
40    public Map<String, Color> helixcolorhash = new Hashtable<>();
41   
42    public Map<Integer, String> positionsToHelix = new Hashtable<>();
43   
44    int numHelix = 0;
45   
46    public AlignmentAnnotation annotation;
47   
48    /**
49    * Returns a new instance of this colour scheme with which the given data may
50    * be coloured
51    */
 
52  0 toggle @Override
53    public ColourSchemeI getInstance(AlignViewportI view,
54    AnnotatedCollectionI coll)
55    {
56  0 return new CovariationColourScheme(coll.getAlignmentAnnotation()[0]);
57    }
58   
59    /**
60    * Creates a new CovariationColourScheme object.
61    */
 
62  0 toggle public CovariationColourScheme(AlignmentAnnotation annotation)
63    {
64  0 this.annotation = annotation;
65   
66  0 for (int x = 0; x < this.annotation._rnasecstr.length; x++)
67    {
68    // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x] + " Begin"
69    // +
70    // this.annotation._rnasecstr[x].getBegin());
71    // jalview.bin.Console.outPrintln(this.annotation._rnasecstr[x].getFeatureGroup());
72    // pairs.put(this.annotation._rnasecstr[x].getBegin(),
73    // this.annotation._rnasecstr[x].getEnd());
74   
75  0 positionsToHelix.put(this.annotation._rnasecstr[x].getBegin(),
76    this.annotation._rnasecstr[x].getFeatureGroup());
77  0 positionsToHelix.put(this.annotation._rnasecstr[x].getEnd(),
78    this.annotation._rnasecstr[x].getFeatureGroup());
79   
80  0 if (Integer.parseInt(
81    this.annotation._rnasecstr[x].getFeatureGroup()) > numHelix)
82    {
83  0 numHelix = Integer
84    .parseInt(this.annotation._rnasecstr[x].getFeatureGroup());
85    }
86   
87    }
88   
89  0 for (int j = 0; j <= numHelix; j++)
90    {
91  0 helixcolorhash.put(String.valueOf(j),
92    ColorUtils.generateRandomColor(Color.white));
93    }
94   
95    }
96   
97    /**
98    * DOCUMENT ME!
99    *
100    * @param n
101    * DOCUMENT ME!
102    *
103    * @return DOCUMENT ME!
104    */
 
105  0 toggle @Override
106    public Color findColour(char c)
107    {
108    // jalview.bin.Console.outPrintln("called"); log.debug
109    // Generate a random pastel color
110   
111  0 return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];// jalview.util.ColorUtils.generateRandomColor(Color.white);
112    }
113   
114    /**
115    * DOCUMENT ME!
116    *
117    * @param n
118    * DOCUMENT ME!
119    * @param j
120    * DOCUMENT ME!
121    *
122    * @return DOCUMENT ME!
123    */
 
124  0 toggle public Color findColour(char c, int j)
125    {
126  0 Color currentColour = Color.white;
127  0 String currentHelix = null;
128    // jalview.bin.Console.outPrintln(c + " " + j);
129  0 currentHelix = positionsToHelix.get(j);
130    // jalview.bin.Console.outPrintln(positionsToHelix.get(j));
131   
132  0 if (currentHelix != null)
133    {
134  0 currentColour = helixcolorhash.get(currentHelix);
135    }
136   
137    // jalview.bin.Console.outPrintln(c + " " + j + " helix " + currentHelix + "
138    // " +
139    // currentColour);
140  0 return currentColour;
141    }
142   
 
143  0 toggle @Override
144    public boolean isNucleotideSpecific()
145    {
146  0 return true;
147    }
148   
 
149  0 toggle @Override
150    public String getSchemeName()
151    {
152  0 return "Covariation";
153    }
154   
 
155  0 toggle @Override
156    public boolean isSimple()
157    {
158  0 return false;
159    }
160    }