Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 18:27:33 GMT
  2. Package jalview.renderer

File OverviewRendererTest.java

 

Code metrics

0
22
1
1
97
57
1
0.05
22
1
1

Classes

Class Line # Actions
OverviewRendererTest 43 22 1
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.renderer;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.datamodel.Alignment;
26    import jalview.datamodel.AlignmentI;
27    import jalview.datamodel.Sequence;
28    import jalview.datamodel.SequenceFeature;
29    import jalview.datamodel.SequenceI;
30    import jalview.gui.AlignViewport;
31    import jalview.renderer.seqfeatures.FeatureRenderer;
32    import jalview.schemes.FeatureColour;
33    import jalview.schemes.ZappoColourScheme;
34    import jalview.viewmodel.AlignmentViewport;
35    import jalview.viewmodel.OverviewDimensions;
36    import jalview.viewmodel.OverviewDimensionsShowHidden;
37    import jalview.viewmodel.ViewportRanges;
38   
39    import java.awt.Color;
40   
41    import org.testng.annotations.Test;
42   
 
43    public class OverviewRendererTest
44    {
45   
 
46  0 toggle @Test
47    public void testGetColumnColourFromSequence()
48    {
49    // gapColour, residueColour, hiddenColour
50  0 OverviewResColourFinder cf = new OverviewResColourFinder(Color.PINK,
51    Color.white, Color.green);
52  0 Sequence seq1 = new Sequence("seq1", "PQ-RL-");
53  0 Sequence seq2 = new Sequence("seq2", "FVE");
54  0 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
55  0 AlignmentViewport av = new AlignViewport(al);
56  0 OverviewDimensions od = new OverviewDimensionsShowHidden(
57    new ViewportRanges(al), false);
58  0 ResidueShaderI rs = new ResidueShader(new ZappoColourScheme());
59  0 FeatureRenderer fr = new FeatureRenderer(av);
60  0 OverviewRenderer or = new OverviewRenderer(fr, od, al, rs, cf);
61   
62    // P is magenta (see ResidueProperties.zappo)
63  0 assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
64    Color.magenta.getRGB());
65    // Q is green
66  0 assertEquals(or.getColumnColourFromSequence(null, seq1, 1),
67    Color.green.getRGB());
68    // gap is pink (specified in OverviewResColourFinder constructor above)
69  0 assertEquals(or.getColumnColourFromSequence(null, seq1, 2),
70    Color.pink.getRGB());
71    // F is orange
72  0 assertEquals(or.getColumnColourFromSequence(null, seq2, 0),
73    Color.orange.getRGB());
74    // E is red
75  0 assertEquals(or.getColumnColourFromSequence(null, seq2, 2),
76    Color.red.getRGB());
77    // past end of sequence colour as gap (JAL-2929)
78  0 assertEquals(or.getColumnColourFromSequence(null, seq2, 3),
79    Color.pink.getRGB());
80   
81    /*
82    * now add a feature on seq1
83    */
84  0 seq1.addSequenceFeature(
85    new SequenceFeature("Pfam", "desc", 1, 4, null));
86  0 fr.findAllFeatures(true);
87  0 av.setShowSequenceFeatures(true);
88  0 fr.setColour("Pfam", new FeatureColour(Color.yellow));
89  0 assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
90    Color.yellow.getRGB());
91   
92    // don't show sequence features
93  0 av.setShowSequenceFeatures(false);
94  0 assertEquals(or.getColumnColourFromSequence(null, seq1, 0),
95    Color.magenta.getRGB());
96    }
97    }