Clover icon

Coverage Report

  1. Project Clover database Thu Jun 4 2026 14:16:38 BST
  2. Package jalview.schemes

File CovariationColourScheme.java

 

Coverage histogram

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

Code metrics

10
22
7
1
165
80
12
0.55
3.14
7
1.71

Classes

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