1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.rbvi.chimera; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertTrue; |
25 |
|
|
26 |
|
import jalview.datamodel.Alignment; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.ColumnSelection; |
29 |
|
import jalview.datamodel.Sequence; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.gui.AlignFrame; |
32 |
|
import jalview.gui.JvOptionPane; |
33 |
|
import jalview.gui.SequenceRenderer; |
34 |
|
import jalview.schemes.JalviewColourScheme; |
35 |
|
import jalview.structure.StructureMapping; |
36 |
|
import jalview.structure.StructureMappingcommandSet; |
37 |
|
import jalview.structure.StructureSelectionManager; |
38 |
|
|
39 |
|
import java.awt.Color; |
40 |
|
import java.util.HashMap; |
41 |
|
import java.util.LinkedHashMap; |
42 |
|
import java.util.List; |
43 |
|
import java.util.Map; |
44 |
|
|
45 |
|
import org.testng.annotations.BeforeClass; |
46 |
|
import org.testng.annotations.Test; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (86) |
Complexity: 6 |
Complexity Density: 0.08 |
|
48 |
|
public class ChimeraCommandsTest |
49 |
|
{ |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
1 |
@BeforeClass(alwaysRun = true)... |
52 |
|
public void setUpJvOptionPane() |
53 |
|
{ |
54 |
1 |
JvOptionPane.setInteractiveMode(false); |
55 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
58 |
1 |
@Test(groups = { "Functional" })... |
59 |
|
public void testBuildColourCommands() |
60 |
|
{ |
61 |
|
|
62 |
1 |
Map<Object, AtomSpecModel> map = new LinkedHashMap<Object, AtomSpecModel>(); |
63 |
1 |
ChimeraCommands.addColourRange(map, Color.blue, 0, 2, 5, "A"); |
64 |
1 |
ChimeraCommands.addColourRange(map, Color.blue, 0, 7, 7, "B"); |
65 |
1 |
ChimeraCommands.addColourRange(map, Color.blue, 0, 9, 23, "A"); |
66 |
1 |
ChimeraCommands.addColourRange(map, Color.blue, 1, 1, 1, "A"); |
67 |
1 |
ChimeraCommands.addColourRange(map, Color.blue, 1, 4, 7, "B"); |
68 |
1 |
ChimeraCommands.addColourRange(map, Color.yellow, 1, 8, 8, "A"); |
69 |
1 |
ChimeraCommands.addColourRange(map, Color.yellow, 1, 3, 5, "A"); |
70 |
1 |
ChimeraCommands.addColourRange(map, Color.red, 0, 3, 5, "A"); |
71 |
1 |
ChimeraCommands.addColourRange(map, Color.red, 0, 6, 9, "A"); |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
1 |
String command = ChimeraCommands.buildColourCommands(map).get(0); |
76 |
1 |
assertEquals( |
77 |
|
command, |
78 |
|
"color #0000ff #0:2-5.A,9-23.A,7.B|#1:1.A,4-7.B; color #ffff00 #1:3-5.A,8.A; color #ff0000 #0:3-9.A"); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
81 |
1 |
@Test(groups = { "Functional" })... |
82 |
|
public void testBuildSetAttributeCommands() |
83 |
|
{ |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
1 |
Map<String, Map<Object, AtomSpecModel>> featuresMap = new LinkedHashMap<String, Map<Object, AtomSpecModel>>(); |
88 |
1 |
Map<Object, AtomSpecModel> featureValues = new HashMap<Object, AtomSpecModel>(); |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
1 |
featuresMap.put("chain", featureValues); |
94 |
1 |
ChimeraCommands.addColourRange(featureValues, "X", 0, 8, 20, "A"); |
95 |
|
|
96 |
1 |
List<String> commands = ChimeraCommands |
97 |
|
.buildSetAttributeCommands(featuresMap); |
98 |
1 |
assertEquals(1, commands.size()); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
1 |
assertEquals(commands.get(0), "setattr r jv_chain 'X' #0:8-20.A"); |
105 |
|
|
106 |
|
|
107 |
1 |
ChimeraCommands.addColourRange(featureValues, "X", 0, 3, 9, "A"); |
108 |
|
|
109 |
1 |
ChimeraCommands.addColourRange(featureValues, "X", 0, 21, 25, "A"); |
110 |
1 |
commands = ChimeraCommands.buildSetAttributeCommands(featuresMap); |
111 |
1 |
assertEquals(1, commands.size()); |
112 |
1 |
assertEquals(commands.get(0), "setattr r jv_chain 'X' #0:3-25.A"); |
113 |
|
|
114 |
|
|
115 |
1 |
ChimeraCommands.addColourRange(featureValues, "X", 0, 21, 25, "B"); |
116 |
|
|
117 |
1 |
ChimeraCommands.addColourRange(featureValues, "X", 1, 26, 30, "A"); |
118 |
1 |
commands = ChimeraCommands.buildSetAttributeCommands(featuresMap); |
119 |
1 |
assertEquals(1, commands.size()); |
120 |
1 |
assertEquals(commands.get(0), |
121 |
|
"setattr r jv_chain 'X' #0:3-25.A,21-25.B|#1:26-30.A"); |
122 |
|
|
123 |
|
|
124 |
1 |
ChimeraCommands.addColourRange(featureValues, "Y", 0, 40, 50, "A"); |
125 |
1 |
commands = ChimeraCommands.buildSetAttributeCommands(featuresMap); |
126 |
1 |
assertEquals(2, commands.size()); |
127 |
|
|
128 |
|
|
129 |
1 |
assertTrue(commands |
130 |
|
.contains("setattr r jv_chain 'X' #0:3-25.A,21-25.B|#1:26-30.A")); |
131 |
1 |
assertTrue(commands.contains("setattr r jv_chain 'Y' #0:40-50.A")); |
132 |
|
|
133 |
1 |
featuresMap.clear(); |
134 |
1 |
featureValues.clear(); |
135 |
1 |
featuresMap.put("side-chain binding!", featureValues); |
136 |
1 |
ChimeraCommands.addColourRange(featureValues, |
137 |
|
"<html>metal <a href=\"http:a.b.c/x\"> 'ion!", 0, 7, 15, |
138 |
|
"A"); |
139 |
|
|
140 |
|
|
141 |
1 |
commands = ChimeraCommands.buildSetAttributeCommands(featuresMap); |
142 |
1 |
assertTrue(commands |
143 |
|
.contains("setattr r jv_side_chain_binding_ '<html>metal <a href=\"http:a.b.c/x\"> 'ion!' #0:7-15.A")); |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
150 |
1 |
@Test(groups = { "Functional" })... |
151 |
|
public void testMakeAttributeName() |
152 |
|
{ |
153 |
1 |
assertEquals(ChimeraCommands.makeAttributeName(null), "jv_"); |
154 |
1 |
assertEquals(ChimeraCommands.makeAttributeName(""), "jv_"); |
155 |
1 |
assertEquals(ChimeraCommands.makeAttributeName("helix"), "jv_helix"); |
156 |
1 |
assertEquals(ChimeraCommands.makeAttributeName("Hello World 24"), |
157 |
|
"jv_Hello_World_24"); |
158 |
1 |
assertEquals( |
159 |
|
ChimeraCommands.makeAttributeName("!this is-a_very*{odd(name"), |
160 |
|
"jv__this_is_a_very__odd_name"); |
161 |
|
|
162 |
1 |
assertEquals(ChimeraCommands.makeAttributeName("helixColor"), |
163 |
|
"jv_helixColor_"); |
164 |
|
} |
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 2 |
Complexity Density: 0.06 |
1PASS
|
|
166 |
1 |
@Test(groups = { "Functional" })... |
167 |
|
public void testGetColourBySequenceCommands_hiddenColumns() |
168 |
|
{ |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
1 |
SequenceI seq1 = new Sequence("seq1", "MHRSQSSSGG"); |
174 |
1 |
SequenceI seq2 = new Sequence("seq2", "MVRSNGGSSS"); |
175 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 }); |
176 |
1 |
AlignFrame af = new AlignFrame(al, 800, 500); |
177 |
1 |
af.changeColour_actionPerformed(JalviewColourScheme.Strand.toString()); |
178 |
1 |
ColumnSelection cs = new ColumnSelection(); |
179 |
1 |
cs.addElement(2); |
180 |
1 |
cs.addElement(3); |
181 |
1 |
cs.addElement(4); |
182 |
1 |
af.getViewport().setColumnSelection(cs); |
183 |
1 |
af.hideSelColumns_actionPerformed(null); |
184 |
1 |
SequenceRenderer sr = new SequenceRenderer(af.getViewport()); |
185 |
1 |
SequenceI[][] seqs = new SequenceI[][] { { seq1 }, { seq2 } }; |
186 |
1 |
String[] files = new String[] { "seq1.pdb", "seq2.pdb" }; |
187 |
1 |
StructureSelectionManager ssm = new StructureSelectionManager(); |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
1 |
HashMap<Integer, int[]> map = new HashMap<Integer, int[]>(); |
193 |
11 |
for (int pos = 1; pos <= seq1.getLength(); pos++) |
194 |
|
{ |
195 |
10 |
map.put(pos, new int[] { 20 + pos, 5 * (20 + pos) }); |
196 |
|
} |
197 |
1 |
StructureMapping sm1 = new StructureMapping(seq1, "seq1.pdb", "pdb1", |
198 |
|
"A", map, null); |
199 |
1 |
ssm.addStructureMapping(sm1); |
200 |
1 |
StructureMapping sm2 = new StructureMapping(seq2, "seq2.pdb", "pdb2", |
201 |
|
"B", map, null); |
202 |
1 |
ssm.addStructureMapping(sm2); |
203 |
|
|
204 |
1 |
StructureMappingcommandSet[] commands = ChimeraCommands |
205 |
|
.getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel); |
206 |
1 |
assertEquals(1, commands.length); |
207 |
1 |
assertEquals(1, commands[0].commands.length); |
208 |
1 |
String theCommand = commands[0].commands[0]; |
209 |
|
|
210 |
1 |
assertTrue(theCommand.contains("color #82827d #0:21.A|#1:21.B")); |
211 |
|
|
212 |
1 |
assertTrue(theCommand.contains("color #60609f #0:22.A")); |
213 |
|
|
214 |
1 |
assertTrue(theCommand.contains("color #ffff00 #1:22.B")); |
215 |
|
|
216 |
1 |
assertTrue(theCommand.contains("color #808080 #0:23-25.A|#1:23-25.B")); |
217 |
|
|
218 |
1 |
assertTrue(theCommand.contains("color #4949b6 #0:26-30.A|#1:26-30.B")); |
219 |
|
} |
220 |
|
} |