Clover icon

Coverage Report

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

File ColourSchemePropertyTest.java

 

Code metrics

0
89
2
1
158
119
2
0.02
44.5
2
1

Classes

Class Line # Actions
ColourSchemePropertyTest 36 89 2
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 static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertNull;
25    import static org.testng.Assert.assertTrue;
26   
27    import jalview.datamodel.Alignment;
28    import jalview.datamodel.AlignmentI;
29    import jalview.datamodel.Sequence;
30    import jalview.datamodel.SequenceI;
31   
32    import java.awt.Color;
33   
34    import org.testng.annotations.Test;
35   
 
36    public class ColourSchemePropertyTest
37    {
 
38  0 toggle @Test(groups = "Functional")
39    public void testGetColourName()
40    {
41  0 SequenceI seq = new Sequence("Seq1", "abcd");
42  0 AlignmentI al = new Alignment(new SequenceI[] { seq });
43  0 ColourSchemeI cs = new ClustalxColourScheme(al, null);
44  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Clustal");
45  0 cs = new Blosum62ColourScheme();
46  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Blosum62");
47  0 cs = new PIDColourScheme();
48  0 assertEquals(ColourSchemeProperty.getColourName(cs), "% Identity");
49  0 cs = new HydrophobicColourScheme();
50  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Hydrophobic");
51  0 cs = new ZappoColourScheme();
52  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Zappo");
53  0 cs = new TaylorColourScheme();
54  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Taylor");
55  0 cs = new HelixColourScheme();
56  0 assertEquals(ColourSchemeProperty.getColourName(cs),
57    "Helix Propensity");
58  0 cs = new StrandColourScheme();
59  0 assertEquals(ColourSchemeProperty.getColourName(cs),
60    "Strand Propensity");
61  0 cs = new TurnColourScheme();
62  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Turn Propensity");
63  0 cs = new BuriedColourScheme();
64  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Buried Index");
65  0 cs = new NucleotideColourScheme();
66  0 assertEquals(ColourSchemeProperty.getColourName(cs), "Nucleotide");
67  0 cs = new PurinePyrimidineColourScheme();
68  0 assertEquals(ColourSchemeProperty.getColourName(cs),
69    "Purine/Pyrimidine");
70  0 cs = new TCoffeeColourScheme(al);
71  0 assertEquals(ColourSchemeProperty.getColourName(cs), "T-Coffee Scores");
72  0 cs = new RNAHelicesColour(al);
73  0 assertEquals(ColourSchemeProperty.getColourName(cs), "RNA Helices");
74  0 cs = new RNAInteractionColourScheme();
75  0 assertEquals(ColourSchemeProperty.getColourName(cs),
76    "RNA Interaction type");
77  0 cs = new UserColourScheme();
78  0 assertEquals(ColourSchemeProperty.getColourName(cs), "User Defined");
79   
80    /*
81    * UserColourScheme may have a bespoke name
82    */
83  0 ((UserColourScheme) cs).setName("stripy");
84  0 assertEquals(ColourSchemeProperty.getColourName(cs), "stripy");
85  0 ((UserColourScheme) cs).setName("");
86  0 assertEquals(ColourSchemeProperty.getColourName(cs), "User Defined");
87  0 ((UserColourScheme) cs).setName(null);
88  0 assertEquals(ColourSchemeProperty.getColourName(cs), "User Defined");
89   
90  0 assertEquals(ColourSchemeProperty.getColourName(null), "None");
91    }
92   
 
93  0 toggle @Test(groups = "Functional")
94    public void testGetColourScheme()
95    {
96  0 SequenceI seq = new Sequence("Seq1", "abcd");
97  0 AlignmentI al = new Alignment(new SequenceI[] { seq });
98    // the strings here correspond to JalviewColourScheme.toString() values
99  0 ColourSchemeI cs = ColourSchemeProperty.getColourScheme(null, al,
100    "Clustal");
101  0 assertTrue(cs instanceof ClustalxColourScheme);
102    // not case-sensitive
103  0 cs = ColourSchemeProperty.getColourScheme(null, al, "CLUSTAL");
104  0 assertTrue(cs instanceof ClustalxColourScheme);
105  0 cs = ColourSchemeProperty.getColourScheme(null, al, "clustal");
106  0 assertTrue(cs instanceof ClustalxColourScheme);
107  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Blosum62");
108  0 assertTrue(cs instanceof Blosum62ColourScheme);
109  0 cs = ColourSchemeProperty.getColourScheme(null, al, "% Identity");
110  0 assertTrue(cs instanceof PIDColourScheme);
111  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Zappo");
112  0 assertTrue(cs instanceof ZappoColourScheme);
113  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Taylor");
114  0 assertTrue(cs instanceof TaylorColourScheme);
115  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Hydrophobic");
116  0 assertTrue(cs instanceof HydrophobicColourScheme);
117  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Helix Propensity");
118  0 assertTrue(cs instanceof HelixColourScheme);
119  0 cs = ColourSchemeProperty.getColourScheme(null, al,
120    "Strand Propensity");
121  0 assertTrue(cs instanceof StrandColourScheme);
122  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Turn Propensity");
123  0 assertTrue(cs instanceof TurnColourScheme);
124  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Buried Index");
125  0 assertTrue(cs instanceof BuriedColourScheme);
126  0 cs = ColourSchemeProperty.getColourScheme(null, al, "Nucleotide");
127  0 assertTrue(cs instanceof NucleotideColourScheme);
128  0 cs = ColourSchemeProperty.getColourScheme(null, al,
129    "Purine/Pyrimidine");
130  0 assertTrue(cs instanceof PurinePyrimidineColourScheme);
131  0 cs = ColourSchemeProperty.getColourScheme(null, al, "T-Coffee Scores");
132  0 assertTrue(cs instanceof TCoffeeColourScheme);
133  0 cs = ColourSchemeProperty.getColourScheme(null, al, "RNA Helices");
134  0 assertTrue(cs instanceof RNAHelicesColour);
135    // 'None' is a special value
136  0 assertNull(ColourSchemeProperty.getColourScheme(null, al, "None"));
137  0 assertNull(ColourSchemeProperty.getColourScheme(null, al, "none"));
138    // default is to convert the name into a fixed colour
139  0 cs = ColourSchemeProperty.getColourScheme(null, al, "elephants");
140  0 assertTrue(cs instanceof UserColourScheme);
141   
142    /*
143    * explicit aa colours
144    */
145  0 UserColourScheme ucs = (UserColourScheme) ColourSchemeProperty
146    .getColourScheme(null, al,
147    "R,G=red;C=blue;c=green;Q=10,20,30;S,T=11ffdd");
148  0 assertEquals(ucs.findColour('H'), Color.white);
149  0 assertEquals(ucs.findColour('R'), Color.red);
150  0 assertEquals(ucs.findColour('r'), Color.red);
151  0 assertEquals(ucs.findColour('G'), Color.red);
152  0 assertEquals(ucs.findColour('C'), Color.blue);
153  0 assertEquals(ucs.findColour('c'), Color.green);
154  0 assertEquals(ucs.findColour('Q'), new Color(10, 20, 30));
155  0 assertEquals(ucs.findColour('S'), new Color(0x11ffdd));
156  0 assertEquals(ucs.findColour('T'), new Color(0x11ffdd));
157    }
158    }