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