Clover icon

jalviewX

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

File ResidueColourFinder.java

 

Coverage histogram

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

Code metrics

16
21
5
1
156
70
14
0.67
4.2
5
2.8

Classes

Class Line # Actions
ResidueColourFinder 29 21 14 1
0.9761904597.6%
 

Contributing tests

This file is covered by 14 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.renderer;
22   
23    import jalview.datamodel.SequenceGroup;
24    import jalview.datamodel.SequenceI;
25    import jalview.renderer.seqfeatures.FeatureColourFinder;
26   
27    import java.awt.Color;
28   
 
29    public class ResidueColourFinder
30    {
 
31  237 toggle public ResidueColourFinder()
32    {
33    }
34   
35    /**
36    * Get the colour of a residue in a sequence
37    *
38    * @param showBoxes
39    * true if the viewport's Show Boxes setting is true
40    * @param shader
41    * the viewport's colour scheme
42    * @param allGroups
43    * all the groups which seq participates in
44    * @param seq
45    * the sequence containing the residue
46    * @param position
47    * the position of the residue in the sequence
48    * @param finder
49    * FeatureColourFinder for the viewport
50    * @return colour of the residue
51    */
 
52  3349 toggle public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
53    SequenceGroup[] allGroups,
54    final SequenceI seq, int position, FeatureColourFinder finder)
55    {
56  3349 Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq,
57    position);
58   
59    // if there's a FeatureColourFinder we might override the residue colour
60    // here with feature colouring
61  3349 if (finder != null)
62    {
63  3298 col = finder.findFeatureColour(col, seq, position);
64    }
65  3349 return col;
66    }
67   
68    /**
69    * Get the residue colour without accounting for any features
70    *
71    * @param showBoxes
72    * true if the viewport's Show Boxes setting is true
73    * @param shader
74    * the viewport's colour scheme
75    * @param allGroups
76    * all the groups which seq participates in
77    * @param seq
78    * the sequence containing the residue
79    * @param i
80    * the position of the residue in the sequence
81    * @return
82    */
 
83  3331 toggle protected Color getResidueBoxColour(boolean showBoxes,
84    ResidueShaderI shader,
85    SequenceGroup[] allGroups,
86    SequenceI seq, int i)
87    {
88  3331 SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups,
89    i);
90  3331 if (currentSequenceGroup != null)
91    {
92  1 if (currentSequenceGroup.getDisplayBoxes())
93    {
94  1 return getBoxColour(currentSequenceGroup.getGroupColourScheme(),
95    seq, i);
96    }
97    }
98  3330 else if (showBoxes)
99    {
100  3322 return getBoxColour(shader, seq, i);
101    }
102   
103  8 return Color.white;
104    }
105   
106    /**
107    * Search all the groups for a sequence to find the one which a given res
108    * falls into
109    *
110    * @param allGroups
111    * all the groups a sequence participates in
112    * @param res
113    * the residue to search for
114    * @return a sequence group for res, or null if no sequence group applies
115    */
 
116  700009 toggle public SequenceGroup getCurrentSequenceGroup(SequenceGroup[] allGroups,
117    int res)
118    {
119  700009 if (allGroups == null)
120    {
121  34 return null;
122    }
123   
124  709720 for (int i = 0; i < allGroups.length; i++)
125    {
126  539314 if ((allGroups[i].getStartRes() <= res)
127    && (allGroups[i].getEndRes() >= res))
128    {
129  529569 return (allGroups[i]);
130    }
131    }
132   
133  170406 return null;
134    }
135   
136    /**
137    * DOCUMENT ME!
138    *
139    * @param shader
140    * the viewport's colour scheme
141    * @param seq
142    * the sequence containing the residue
143    * @param i
144    * the position of the residue in the sequence
145    */
 
146  351653 toggle public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
147    {
148  351653 Color resBoxColour = Color.white;
149  351653 if (shader.getColourScheme() != null)
150    {
151  270685 resBoxColour = shader.findColour(seq.getCharAt(i), i, seq);
152    }
153  351653 return resBoxColour;
154    }
155   
156    }