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 java.awt.Color; |
27 |
|
import java.util.HashMap; |
28 |
|
import java.util.LinkedHashMap; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Map; |
31 |
|
|
32 |
|
import org.testng.annotations.BeforeClass; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
35 |
|
import jalview.structure.AtomSpecModel; |
36 |
|
import jalview.structure.StructureCommand; |
37 |
|
import jalview.structure.StructureCommandI; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (165) |
Complexity: 23 |
Complexity Density: 0.16 |
|
39 |
|
public class ChimeraXCommandsTest |
40 |
|
{ |
41 |
|
private ChimeraXCommands testee; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
43 |
1 |
@BeforeClass(alwaysRun = true)... |
44 |
|
public void setUp() |
45 |
|
{ |
46 |
1 |
testee = new ChimeraXCommands(); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
49 |
1 |
@Test(groups = { "Functional" })... |
50 |
|
public void testColourByCharge() |
51 |
|
{ |
52 |
1 |
List<StructureCommandI> cmd = testee.colourByCharge(); |
53 |
1 |
assertEquals(cmd.size(), 1); |
54 |
1 |
assertEquals(cmd.get(0).getCommand(), |
55 |
|
"color white;color :ASP,GLU red;color :LYS,ARG blue;color :CYS yellow"); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
58 |
1 |
@Test(groups = { "Functional" })... |
59 |
|
public void testColourByChain() |
60 |
|
{ |
61 |
1 |
StructureCommandI cmd = testee.colourByChain(); |
62 |
1 |
assertEquals(cmd.getCommand(), "rainbow chain"); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
65 |
1 |
@Test(groups = { "Functional" })... |
66 |
|
public void testFocusView() |
67 |
|
{ |
68 |
1 |
StructureCommandI cmd = testee.focusView(); |
69 |
1 |
assertEquals(cmd.getCommand(), "view"); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
72 |
1 |
@Test(groups = { "Functional" })... |
73 |
|
public void testSetBackgroundColour() |
74 |
|
{ |
75 |
1 |
StructureCommandI cmd = testee.setBackgroundColour(Color.PINK); |
76 |
1 |
assertEquals(cmd.getCommand(), "set bgColor #ffafaf"); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
79 |
1 |
@Test(groups = { "Functional" })... |
80 |
|
public void testOpenSession() |
81 |
|
{ |
82 |
1 |
StructureCommandI cmd = testee.openSession("/some/filepath"); |
83 |
1 |
assertEquals(cmd.getCommand(), "open /some/filepath format session"); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
86 |
1 |
@Test(groups = { "Functional" })... |
87 |
|
public void testColourBySequence() |
88 |
|
{ |
89 |
1 |
Map<Object, AtomSpecModel> map = new LinkedHashMap<>(); |
90 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.blue, "1", 2, 5, "A"); |
91 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.blue, "1", 7, 7, "B"); |
92 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.blue, "1", 9, 23, "A"); |
93 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.blue, "2", 1, 1, "A"); |
94 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.blue, "2", 4, 7, "B"); |
95 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.yellow, "2", 8, 8, "A"); |
96 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.yellow, "2", 3, 5, "A"); |
97 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.red, "1", 3, 5, "A"); |
98 |
1 |
ChimeraCommands.addAtomSpecRange(map, Color.red, "1", 6, 9, "A"); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
1 |
List<StructureCommandI> commands = testee.colourBySequence(map); |
105 |
1 |
assertEquals(commands.size(), 1); |
106 |
1 |
assertEquals(commands.get(0).getCommand(), |
107 |
|
"color #1/A:2-5,9-23/B:7|#2/A:1/B:4-7 #0000ff;color #2/A:3-5,8 #ffff00;color #1/A:3-9 #ff0000"); |
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
110 |
1 |
@Test(groups = { "Functional" })... |
111 |
|
public void testSetAttributes() |
112 |
|
{ |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
1 |
Map<String, Map<Object, AtomSpecModel>> featuresMap = new LinkedHashMap<>(); |
117 |
1 |
Map<Object, AtomSpecModel> featureValues = new HashMap<>(); |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
1 |
featuresMap.put("chain", featureValues); |
123 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "X", "0", 8, 20, "A"); |
124 |
|
|
125 |
1 |
List<StructureCommandI> commands = testee.setAttributes(featuresMap); |
126 |
1 |
assertEquals(commands.size(), 1); |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
1 |
assertEquals(commands.get(0).getCommand(), |
133 |
|
"setattr #0/A:8-20 res jv_chain 'X' create true"); |
134 |
|
|
135 |
|
|
136 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "X", "0", 3, 9, "A"); |
137 |
|
|
138 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "X", "0", 21, 25, "A"); |
139 |
1 |
commands = testee.setAttributes(featuresMap); |
140 |
1 |
assertEquals(commands.size(), 1); |
141 |
1 |
assertEquals(commands.get(0).getCommand(), |
142 |
|
"setattr #0/A:3-25 res jv_chain 'X' create true"); |
143 |
|
|
144 |
|
|
145 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "X", "0", 21, 25, "B"); |
146 |
|
|
147 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "X", "1", 26, 30, "A"); |
148 |
1 |
commands = testee.setAttributes(featuresMap); |
149 |
1 |
assertEquals(commands.size(), 1); |
150 |
1 |
String expected1 = "setattr #0/A:3-25/B:21-25|#1/A:26-30 res jv_chain 'X' create true"; |
151 |
1 |
assertEquals(commands.get(0).getCommand(), expected1); |
152 |
|
|
153 |
|
|
154 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, "Y", "0", 40, 50, "A"); |
155 |
1 |
commands = testee.setAttributes(featuresMap); |
156 |
1 |
assertEquals(2, commands.size()); |
157 |
|
|
158 |
|
|
159 |
1 |
String cmd1 = commands.get(0).getCommand(); |
160 |
1 |
String cmd2 = commands.get(1).getCommand(); |
161 |
1 |
assertTrue(cmd1.equals(expected1) || cmd2.equals(expected1)); |
162 |
1 |
String expected2 = "setattr #0/A:40-50 res jv_chain 'Y' create true"; |
163 |
1 |
assertTrue(cmd1.equals(expected2) || cmd2.equals(expected2)); |
164 |
|
|
165 |
1 |
featuresMap.clear(); |
166 |
1 |
featureValues.clear(); |
167 |
1 |
featuresMap.put("side-chain binding!", featureValues); |
168 |
1 |
ChimeraCommands.addAtomSpecRange(featureValues, |
169 |
|
"<html>metal <a href=\"http:a.b.c/x\"> 'ion!", "0", 7, 15, "A"); |
170 |
|
|
171 |
|
|
172 |
1 |
commands = testee.setAttributes(featuresMap); |
173 |
1 |
assertEquals(commands.size(), 1); |
174 |
1 |
String expected3 = "setattr #0/A:7-15 res jv_side_chain_binding_ '<html>metal <a href=\"http:a.b.c/x\"> 'ion!' create true"; |
175 |
1 |
assertTrue(commands.get(0).getCommand().equals(expected3)); |
176 |
|
} |
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
178 |
1 |
@Test(groups = { "Functional" })... |
179 |
|
public void testSuperposeStructures() |
180 |
|
{ |
181 |
1 |
AtomSpecModel ref = new AtomSpecModel(); |
182 |
1 |
ref.addRange("1", 12, 14, "A"); |
183 |
1 |
ref.addRange("1", 18, 18, "B"); |
184 |
1 |
ref.addRange("1", 22, 23, "B"); |
185 |
1 |
AtomSpecModel toAlign = new AtomSpecModel(); |
186 |
1 |
toAlign.addRange("2", 15, 17, "B"); |
187 |
1 |
toAlign.addRange("2", 20, 21, "B"); |
188 |
1 |
toAlign.addRange("2", 22, 22, "C"); |
189 |
1 |
List<StructureCommandI> command = testee.superposeStructures(ref, |
190 |
|
toAlign); |
191 |
1 |
assertEquals(command.size(), 1); |
192 |
1 |
String cmd = command.get(0).getCommand(); |
193 |
1 |
String refSpec = "#1/A:12-14/B:18,22-23"; |
194 |
1 |
String toAlignSpec = "#2/B:15-17,20-21/C:22"; |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
1 |
String expected = String.format( |
201 |
|
"align %s@CA toAtoms %s@CA; ribbon %s|%s; view", toAlignSpec, |
202 |
|
refSpec, toAlignSpec, refSpec); |
203 |
1 |
assertEquals(cmd, expected); |
204 |
|
} |
205 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
206 |
1 |
@Test(groups = "Functional")... |
207 |
|
public void testGetAtomSpec() |
208 |
|
{ |
209 |
1 |
AtomSpecModel model = new AtomSpecModel(); |
210 |
1 |
assertEquals(testee.getAtomSpec(model, false), ""); |
211 |
1 |
model.addRange("1", 2, 4, "A"); |
212 |
1 |
assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4"); |
213 |
1 |
model.addRange("1", 8, 8, "A"); |
214 |
1 |
assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4,8"); |
215 |
1 |
model.addRange("1", 5, 7, "B"); |
216 |
1 |
assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4,8/B:5-7"); |
217 |
1 |
model.addRange("1", 3, 5, "A"); |
218 |
1 |
assertEquals(testee.getAtomSpec(model, false), "#1/A:2-5,8/B:5-7"); |
219 |
1 |
model.addRange("0", 1, 4, "B"); |
220 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
221 |
|
"#0/B:1-4|#1/A:2-5,8/B:5-7"); |
222 |
1 |
model.addRange("0", 5, 9, "C"); |
223 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
224 |
|
"#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-7"); |
225 |
1 |
model.addRange("1", 8, 10, "B"); |
226 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
227 |
|
"#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-10"); |
228 |
1 |
model.addRange("1", 8, 9, "B"); |
229 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
230 |
|
"#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-10"); |
231 |
1 |
model.addRange("0", 3, 10, "C"); |
232 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
233 |
|
"#0/B:1-4/C:3-10|#1/A:2-5,8/B:5-10"); |
234 |
1 |
model.addRange("5", 25, 35, " "); |
235 |
1 |
assertEquals(testee.getAtomSpec(model, false), |
236 |
|
"#0/B:1-4/C:3-10|#1/A:2-5,8/B:5-10|#5/:25-35"); |
237 |
|
} |
238 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
239 |
1 |
@Test(groups = "Functional")... |
240 |
|
public void testGetAtomSpec_alphaOnly() |
241 |
|
{ |
242 |
1 |
AtomSpecModel model = new AtomSpecModel(); |
243 |
1 |
assertEquals(testee.getAtomSpec(model, true), ""); |
244 |
1 |
model.addRange("1", 2, 4, "A"); |
245 |
1 |
assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4@CA"); |
246 |
1 |
model.addRange("1", 8, 8, "A"); |
247 |
1 |
assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4,8@CA"); |
248 |
1 |
model.addRange("1", 5, 7, "B"); |
249 |
1 |
assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4,8/B:5-7@CA"); |
250 |
1 |
model.addRange("1", 3, 5, "A"); |
251 |
1 |
assertEquals(testee.getAtomSpec(model, true), "#1/A:2-5,8/B:5-7@CA"); |
252 |
1 |
model.addRange("0", 1, 4, "B"); |
253 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
254 |
|
"#0/B:1-4@CA|#1/A:2-5,8/B:5-7@CA"); |
255 |
1 |
model.addRange("0", 5, 9, "C"); |
256 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
257 |
|
"#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-7@CA"); |
258 |
1 |
model.addRange("1", 8, 10, "B"); |
259 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
260 |
|
"#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-10@CA"); |
261 |
1 |
model.addRange("1", 8, 9, "B"); |
262 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
263 |
|
"#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-10@CA"); |
264 |
1 |
model.addRange("0", 3, 10, "C"); |
265 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
266 |
|
"#0/B:1-4/C:3-10@CA|#1/A:2-5,8/B:5-10@CA"); |
267 |
1 |
model.addRange("5", 25, 35, " "); |
268 |
1 |
assertEquals(testee.getAtomSpec(model, true), |
269 |
|
"#0/B:1-4/C:3-10@CA|#1/A:2-5,8/B:5-10@CA|#5/:25-35@CA"); |
270 |
|
} |
271 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
272 |
1 |
@Test(groups = "Functional")... |
273 |
|
public void testGetModelStartNo() |
274 |
|
{ |
275 |
1 |
assertEquals(testee.getModelStartNo(), 1); |
276 |
|
} |
277 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
278 |
1 |
@Test(groups = "Functional")... |
279 |
|
public void testGetResidueSpec() |
280 |
|
{ |
281 |
1 |
assertEquals(testee.getResidueSpec("ALA"), ":ALA"); |
282 |
|
} |
283 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
284 |
1 |
@Test(groups = "Functional")... |
285 |
|
public void testShowBackbone() |
286 |
|
{ |
287 |
1 |
List<StructureCommandI> showBackbone = testee.showBackbone(); |
288 |
1 |
assertEquals(showBackbone.size(), 1); |
289 |
1 |
assertEquals(showBackbone.get(0).getCommand(), |
290 |
|
"~display all;~ribbon;show @CA|P atoms"); |
291 |
|
} |
292 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
293 |
1 |
@Test(groups = "Functional")... |
294 |
|
public void testOpenCommandFile() |
295 |
|
{ |
296 |
1 |
assertEquals(testee.openCommandFile("nowhere").getCommand(), |
297 |
|
"open nowhere"); |
298 |
|
} |
299 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
300 |
1 |
@Test(groups = "Functional")... |
301 |
|
public void testSaveSession() |
302 |
|
{ |
303 |
1 |
assertEquals(testee.saveSession("somewhere").getCommand(), |
304 |
|
"save somewhere format session"); |
305 |
|
} |
306 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
307 |
1 |
@Test(groups = "Functional")... |
308 |
|
public void testGetColourCommand() |
309 |
|
{ |
310 |
1 |
assertEquals(testee.colourResidues("something", Color.MAGENTA) |
311 |
|
.getCommand(), |
312 |
|
"color something #ff00ff"); |
313 |
|
} |
314 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
315 |
1 |
@Test(groups = "Functional")... |
316 |
|
public void testSetAttribute() |
317 |
|
{ |
318 |
1 |
AtomSpecModel model = new AtomSpecModel(); |
319 |
1 |
model.addRange("1", 89, 92, "A"); |
320 |
1 |
model.addRange("2", 12, 20, "B"); |
321 |
1 |
model.addRange("2", 8, 9, "B"); |
322 |
1 |
assertEquals(testee.setAttribute("jv_kd", "27.3", model) |
323 |
|
.getCommand(), |
324 |
|
"setattr #1/A:89-92|#2/B:8-9,12-20 res jv_kd '27.3' create true"); |
325 |
|
} |
326 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
327 |
1 |
@Test(groups = "Functional")... |
328 |
|
public void testCloseViewer() |
329 |
|
{ |
330 |
1 |
assertEquals(testee.closeViewer(), new StructureCommand("exit")); |
331 |
|
} |
332 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
333 |
1 |
@Test(groups = "Functional")... |
334 |
|
public void testGetSelectedResidues() |
335 |
|
{ |
336 |
1 |
assertEquals(testee.getSelectedResidues(), |
337 |
|
new StructureCommand("info selection level residue")); |
338 |
|
} |
339 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
340 |
1 |
@Test(groups = "Functional")... |
341 |
|
public void testStartNotifications() |
342 |
|
{ |
343 |
1 |
List<StructureCommandI> cmds = testee.startNotifications("to here"); |
344 |
1 |
assertEquals(cmds.size(), 2); |
345 |
1 |
assertEquals(cmds.get(0), new StructureCommand("info notify start models prefix ModelChanged jalview url to here")); |
346 |
1 |
assertEquals(cmds.get(1), new StructureCommand("info notify start selection jalview prefix SelectionChanged url to here")); |
347 |
|
} |
348 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
349 |
1 |
@Test(groups = "Functional")... |
350 |
|
public void testStopNotifications() |
351 |
|
{ |
352 |
1 |
List<StructureCommandI> cmds = testee.stopNotifications(); |
353 |
1 |
assertEquals(cmds.size(), 2); |
354 |
1 |
assertEquals(cmds.get(0), new StructureCommand("info notify stop models jalview")); |
355 |
1 |
assertEquals(cmds.get(1), new StructureCommand("info notify stop selection jalview")); |
356 |
|
} |
357 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
358 |
1 |
@Test(groups = "Functional")... |
359 |
|
public void testListResidueAttributes() |
360 |
|
{ |
361 |
1 |
assertEquals(testee.listResidueAttributes(), |
362 |
|
new StructureCommand("info resattr")); |
363 |
|
} |
364 |
|
} |