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 java.awt.Color; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.Arrays; |
26 |
|
import java.util.List; |
27 |
|
|
28 |
|
import jalview.structure.AtomSpecModel; |
29 |
|
import jalview.structure.StructureCommand; |
30 |
|
import jalview.structure.StructureCommandI; |
31 |
|
import jalview.structure.StructureCommandsI.AtomSpecType; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
|
|
| 97.6% |
Uncovered Elements: 2 (83) |
Complexity: 22 |
Complexity Density: 0.39 |
|
36 |
|
public class ChimeraXCommands extends ChimeraCommands |
37 |
|
{ |
38 |
|
|
39 |
|
private static final StructureCommand LIST_RESIDUE_ATTRIBUTES = new StructureCommand( |
40 |
|
"info resattr"); |
41 |
|
|
42 |
|
|
43 |
|
private static final StructureCommand CLOSE_CHIMERAX = new StructureCommand( |
44 |
|
"exit"); |
45 |
|
|
46 |
|
|
47 |
|
private static final StructureCommand STOP_NOTIFY_SELECTION = new StructureCommand( |
48 |
|
"info notify stop selection jalview"); |
49 |
|
|
50 |
|
private static final StructureCommand STOP_NOTIFY_MODELS = new StructureCommand( |
51 |
|
"info notify stop models jalview"); |
52 |
|
|
53 |
|
|
54 |
|
private static final StructureCommand GET_SELECTION = new StructureCommand( |
55 |
|
"info selection level residue"); |
56 |
|
|
57 |
|
private static final StructureCommand SHOW_BACKBONE = new StructureCommand( |
58 |
|
"~display all;~ribbon;show @CA|P atoms"); |
59 |
|
|
60 |
|
|
61 |
|
private static final StructureCommand FOCUS_VIEW = new StructureCommand( |
62 |
|
"view"); |
63 |
|
|
64 |
|
private static final StructureCommandI COLOUR_BY_CHARGE = new StructureCommand( |
65 |
|
"color white;color :ASP,GLU red;color :LYS,ARG blue;color :CYS yellow"); |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
1 |
@Override... |
68 |
|
public List<StructureCommandI> colourByCharge() |
69 |
|
{ |
70 |
1 |
return Arrays.asList(COLOUR_BY_CHARGE); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
1 |
@Override... |
74 |
|
public String getResidueSpec(String residue) |
75 |
|
{ |
76 |
1 |
return ":" + residue; |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
4 |
@Override... |
80 |
|
public StructureCommandI colourResidues(String atomSpec, Color colour) |
81 |
|
{ |
82 |
|
|
83 |
4 |
String colourCode = getColourString(colour); |
84 |
|
|
85 |
4 |
return new StructureCommand("color " + atomSpec + " " + colourCode); |
86 |
|
} |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
1 |
@Override... |
89 |
|
public StructureCommandI focusView() |
90 |
|
{ |
91 |
1 |
return FOCUS_VIEW; |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
@inheritDoc |
96 |
|
|
97 |
|
@return |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
99 |
1 |
@Override... |
100 |
|
public int getModelStartNo() |
101 |
|
{ |
102 |
1 |
return 1; |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
@param |
114 |
|
@param |
115 |
|
@param |
116 |
|
@return |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
118 |
7 |
@Override... |
119 |
|
protected StructureCommandI setAttribute(String attributeName, |
120 |
|
String attributeValue, AtomSpecModel atomSpecModel) |
121 |
|
{ |
122 |
7 |
StringBuilder sb = new StringBuilder(128); |
123 |
7 |
sb.append("setattr ") |
124 |
|
.append(getAtomSpec(atomSpecModel, AtomSpecType.RESIDUE_ONLY)); |
125 |
7 |
sb.append(" res ").append(attributeName).append(" '") |
126 |
|
.append(attributeValue).append("'"); |
127 |
7 |
sb.append(" create true"); |
128 |
7 |
return new StructureCommand(sb.toString()); |
129 |
|
} |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
1 |
@Override... |
132 |
|
public StructureCommandI openCommandFile(String path) |
133 |
|
{ |
134 |
|
|
135 |
1 |
return new StructureCommand("open " + path); |
136 |
|
} |
137 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
138 |
1 |
@Override... |
139 |
|
public StructureCommandI saveSession(String filepath) |
140 |
|
{ |
141 |
|
|
142 |
|
|
143 |
1 |
return new StructureCommand("save " + filepath + " format session"); |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
@return |
156 |
|
|
|
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
157 |
36 |
@Override... |
158 |
|
public String getAtomSpec(AtomSpecModel atomSpec, AtomSpecType specType) |
159 |
|
{ |
160 |
36 |
StringBuilder sb = new StringBuilder(128); |
161 |
36 |
boolean firstModel = true; |
162 |
36 |
for (String model : atomSpec.getModels()) |
163 |
|
{ |
164 |
52 |
if (!firstModel) |
165 |
|
{ |
166 |
18 |
sb.append("|"); |
167 |
|
} |
168 |
52 |
firstModel = false; |
169 |
52 |
appendModel(sb, model, atomSpec); |
170 |
52 |
if (specType == AtomSpecType.ALPHA) |
171 |
|
{ |
172 |
19 |
sb.append("@CA"); |
173 |
|
} |
174 |
52 |
if (specType == AtomSpecType.PHOSPHATE) |
175 |
|
{ |
176 |
0 |
sb.append("@P"); |
177 |
|
} |
178 |
|
} |
179 |
36 |
return sb.toString(); |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
@param |
186 |
|
@param |
187 |
|
@param |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
189 |
52 |
protected void appendModel(StringBuilder sb, String model,... |
190 |
|
AtomSpecModel atomSpec) |
191 |
|
{ |
192 |
52 |
sb.append("#").append(model); |
193 |
|
|
194 |
52 |
for (String chain : atomSpec.getChains(model)) |
195 |
|
{ |
196 |
86 |
boolean firstPositionForChain = true; |
197 |
86 |
sb.append("/").append(chain.trim()).append(":"); |
198 |
86 |
List<int[]> rangeList = atomSpec.getRanges(model, chain); |
199 |
86 |
boolean first = true; |
200 |
86 |
for (int[] range : rangeList) |
201 |
|
{ |
202 |
111 |
if (!first) |
203 |
|
{ |
204 |
25 |
sb.append(","); |
205 |
|
} |
206 |
111 |
first = false; |
207 |
111 |
appendRange(sb, range[0], range[1], chain, firstPositionForChain, |
208 |
|
true); |
209 |
|
} |
210 |
|
} |
211 |
|
} |
212 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
213 |
1 |
@Override... |
214 |
|
public List<StructureCommandI> showBackbone() |
215 |
|
{ |
216 |
1 |
return Arrays.asList(SHOW_BACKBONE); |
217 |
|
} |
218 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
219 |
1 |
@Override... |
220 |
|
public List<StructureCommandI> superposeStructures(AtomSpecModel ref, |
221 |
|
AtomSpecModel spec, AtomSpecType backbone) |
222 |
|
{ |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@see |
229 |
|
|
230 |
1 |
StringBuilder cmd = new StringBuilder(); |
231 |
1 |
String atomSpec = getAtomSpec(spec, backbone); |
232 |
1 |
String refSpec = getAtomSpec(ref, backbone); |
233 |
1 |
cmd.append("align ").append(atomSpec).append(" toAtoms ") |
234 |
|
.append(refSpec); |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
1 |
cmd.append("; ribbon "); |
240 |
1 |
cmd.append(getAtomSpec(spec, AtomSpecType.RESIDUE_ONLY)).append("|"); |
241 |
1 |
cmd.append(getAtomSpec(ref, AtomSpecType.RESIDUE_ONLY)) |
242 |
|
.append("; view"); |
243 |
|
|
244 |
1 |
return Arrays.asList(new StructureCommand(cmd.toString())); |
245 |
|
} |
246 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
247 |
1 |
@Override... |
248 |
|
public StructureCommandI openSession(String filepath) |
249 |
|
{ |
250 |
|
|
251 |
|
|
252 |
1 |
return new StructureCommand("open " + filepath + " format session"); |
253 |
|
} |
254 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
255 |
1 |
@Override... |
256 |
|
public StructureCommandI closeViewer() |
257 |
|
{ |
258 |
1 |
return CLOSE_CHIMERAX; |
259 |
|
} |
260 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
261 |
1 |
@Override... |
262 |
|
public List<StructureCommandI> startNotifications(String uri) |
263 |
|
{ |
264 |
1 |
List<StructureCommandI> cmds = new ArrayList<>(); |
265 |
1 |
cmds.add(new StructureCommand( |
266 |
|
"info notify start models jalview prefix ModelChanged url " |
267 |
|
+ uri)); |
268 |
1 |
cmds.add(new StructureCommand( |
269 |
|
"info notify start selection jalview prefix SelectionChanged url " |
270 |
|
+ uri)); |
271 |
1 |
return cmds; |
272 |
|
} |
273 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
274 |
1 |
@Override... |
275 |
|
public List<StructureCommandI> stopNotifications() |
276 |
|
{ |
277 |
1 |
List<StructureCommandI> cmds = new ArrayList<>(); |
278 |
1 |
cmds.add(STOP_NOTIFY_MODELS); |
279 |
1 |
cmds.add(STOP_NOTIFY_SELECTION); |
280 |
1 |
return cmds; |
281 |
|
} |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
283 |
1 |
@Override... |
284 |
|
public StructureCommandI getSelectedResidues() |
285 |
|
{ |
286 |
1 |
return GET_SELECTION; |
287 |
|
} |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
289 |
1 |
@Override... |
290 |
|
public StructureCommandI listResidueAttributes() |
291 |
|
{ |
292 |
1 |
return LIST_RESIDUE_ATTRIBUTES; |
293 |
|
} |
294 |
|
} |