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.io.File; |
24 |
|
import java.io.FileOutputStream; |
25 |
|
import java.io.IOException; |
26 |
|
import java.io.PrintWriter; |
27 |
|
import java.net.BindException; |
28 |
|
import java.util.ArrayList; |
29 |
|
import java.util.Collections; |
30 |
|
import java.util.LinkedHashMap; |
31 |
|
import java.util.List; |
32 |
|
import java.util.Map; |
33 |
|
|
34 |
|
import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager; |
35 |
|
import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel; |
36 |
|
import ext.edu.ucsf.rbvi.strucviz2.StructureManager; |
37 |
|
import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType; |
38 |
|
import jalview.api.AlignmentViewPanel; |
39 |
|
import jalview.bin.Cache; |
40 |
|
import jalview.datamodel.PDBEntry; |
41 |
|
import jalview.datamodel.SearchResultMatchI; |
42 |
|
import jalview.datamodel.SearchResultsI; |
43 |
|
import jalview.datamodel.SequenceFeature; |
44 |
|
import jalview.datamodel.SequenceI; |
45 |
|
import jalview.gui.StructureViewer.ViewerType; |
46 |
|
import jalview.httpserver.AbstractRequestHandler; |
47 |
|
import jalview.io.DataSourceType; |
48 |
|
import jalview.structure.AtomSpec; |
49 |
|
import jalview.structure.AtomSpecModel; |
50 |
|
import jalview.structure.StructureCommand; |
51 |
|
import jalview.structure.StructureCommandI; |
52 |
|
import jalview.structure.StructureSelectionManager; |
53 |
|
import jalview.structures.models.AAStructureBindingModel; |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 297 (297) |
Complexity: 79 |
Complexity Density: 0.4 |
|
55 |
|
public abstract class JalviewChimeraBinding extends AAStructureBindingModel |
56 |
|
{ |
57 |
|
public static final String CHIMERA_SESSION_EXTENSION = ".py"; |
58 |
|
|
59 |
|
public static final String CHIMERA_FEATURE_GROUP = "Chimera"; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
private ChimeraManager chimeraManager; |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
private AbstractRequestHandler chimeraListener; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
protected Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<>(); |
75 |
|
|
76 |
|
String lastHighlightCommand; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
@param |
81 |
|
@return |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0 |
protected AtomSpec parseAtomSpec(String atomSpec)... |
84 |
|
{ |
85 |
0 |
return AtomSpec.fromChimeraAtomspec(atomSpec); |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
@param |
95 |
|
@return |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 5 |
Complexity Density: 0.26 |
|
97 |
0 |
public boolean openFile(PDBEntry pe)... |
98 |
|
{ |
99 |
0 |
String file = pe.getFile(); |
100 |
0 |
try |
101 |
|
{ |
102 |
0 |
List<ChimeraModel> modelsToMap = new ArrayList<>(); |
103 |
0 |
List<ChimeraModel> oldList = chimeraManager.getModelList(); |
104 |
0 |
boolean alreadyOpen = false; |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
0 |
for (ChimeraModel open : oldList) |
110 |
|
{ |
111 |
0 |
if (open.getModelName().equals(pe.getId())) |
112 |
|
{ |
113 |
0 |
alreadyOpen = true; |
114 |
0 |
modelsToMap.add(open); |
115 |
|
} |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
0 |
if (!alreadyOpen) |
123 |
|
{ |
124 |
0 |
chimeraManager.openModel(file, pe.getId(), ModelType.PDB_MODEL); |
125 |
0 |
addChimeraModel(pe, modelsToMap); |
126 |
|
} |
127 |
|
|
128 |
0 |
chimeraMaps.put(file, modelsToMap); |
129 |
|
|
130 |
0 |
if (getSsm() != null) |
131 |
|
{ |
132 |
0 |
getSsm().addStructureViewerListener(this); |
133 |
|
} |
134 |
0 |
return true; |
135 |
|
} catch (Exception q) |
136 |
|
{ |
137 |
0 |
log("Exception when trying to open model " + file + "\n" |
138 |
|
+ q.toString()); |
139 |
0 |
q.printStackTrace(); |
140 |
|
} |
141 |
0 |
return false; |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
@param |
149 |
|
@param |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
151 |
0 |
protected void addChimeraModel(PDBEntry pe,... |
152 |
|
List<ChimeraModel> modelsToMap) |
153 |
|
{ |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
0 |
List<ChimeraModel> newList = chimeraManager.getModelList(); |
159 |
|
|
160 |
0 |
for (ChimeraModel cm : newList) |
161 |
|
{ |
162 |
0 |
if (cm.getModelName().equals(pe.getId())) |
163 |
|
{ |
164 |
0 |
modelsToMap.add(cm); |
165 |
|
} |
166 |
|
} |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
@param |
173 |
|
@param |
174 |
|
@param |
175 |
|
@param |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
177 |
0 |
public JalviewChimeraBinding(StructureSelectionManager ssm,... |
178 |
|
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, |
179 |
|
DataSourceType protocol) |
180 |
|
{ |
181 |
0 |
super(ssm, pdbentry, sequenceIs, protocol); |
182 |
0 |
boolean chimeraX = ViewerType.CHIMERAX.equals(getViewerType()); |
183 |
0 |
chimeraManager = chimeraX ? new ChimeraXManager(new StructureManager(true)) : new ChimeraManager(new StructureManager(true)); |
184 |
0 |
setStructureCommands(chimeraX ? new ChimeraXCommands() : new ChimeraCommands()); |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0 |
@Override... |
188 |
|
protected ViewerType getViewerType() |
189 |
|
{ |
190 |
0 |
return ViewerType.CHIMERA; |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
197 |
0 |
public void startChimeraListener()... |
198 |
|
{ |
199 |
0 |
try |
200 |
|
{ |
201 |
0 |
chimeraListener = new ChimeraListener(this); |
202 |
0 |
startListening(chimeraListener.getUri()); |
203 |
|
} catch (BindException e) |
204 |
|
{ |
205 |
0 |
System.err.println( |
206 |
|
"Failed to start Chimera listener: " + e.getMessage()); |
207 |
|
} |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
214 |
0 |
@Override... |
215 |
|
public void closeViewer(boolean closeChimera) |
216 |
|
{ |
217 |
0 |
super.closeViewer(closeChimera); |
218 |
0 |
if (this.chimeraListener != null) |
219 |
|
{ |
220 |
0 |
chimeraListener.shutdown(); |
221 |
0 |
chimeraListener = null; |
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
0 |
if (closeChimera && (getViewerType() == ViewerType.CHIMERA)) |
230 |
|
{ |
231 |
0 |
chimeraManager.getChimeraProcess().destroy(); |
232 |
|
} |
233 |
|
|
234 |
0 |
chimeraManager.clearOnChimeraExit(); |
235 |
0 |
chimeraManager = null; |
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
@param |
249 |
|
@return |
250 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
251 |
0 |
protected String getModelSpec(int pdbfnum)... |
252 |
|
{ |
253 |
0 |
if (pdbfnum < 0 || pdbfnum >= getPdbCount()) |
254 |
|
{ |
255 |
0 |
return "#" + pdbfnum; |
256 |
|
} |
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
0 |
List<ChimeraModel> maps = chimeraMaps.get(getStructureFiles()[pdbfnum]); |
265 |
0 |
boolean hasSubModels = maps != null && maps.size() > 1; |
266 |
0 |
return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : ""); |
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
@return |
275 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
276 |
0 |
public boolean launchChimera()... |
277 |
|
{ |
278 |
0 |
if (chimeraManager.isChimeraLaunched()) |
279 |
|
{ |
280 |
0 |
return true; |
281 |
|
} |
282 |
|
|
283 |
0 |
boolean launched = chimeraManager.launchChimera(getChimeraPaths()); |
284 |
0 |
if (launched) |
285 |
|
{ |
286 |
0 |
startExternalViewerMonitor(chimeraManager.getChimeraProcess()); |
287 |
|
} |
288 |
|
else |
289 |
|
{ |
290 |
0 |
log("Failed to launch Chimera!"); |
291 |
|
} |
292 |
0 |
return launched; |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
@return |
299 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
300 |
0 |
protected List<String> getChimeraPaths()... |
301 |
|
{ |
302 |
0 |
return StructureManager.getChimeraPaths(false); |
303 |
|
} |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
@return |
310 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
311 |
0 |
@Override... |
312 |
|
public boolean isViewerRunning() |
313 |
|
{ |
314 |
0 |
return chimeraManager.isChimeraLaunched(); |
315 |
|
} |
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
@param |
321 |
|
@param |
322 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
323 |
0 |
@Override... |
324 |
|
public List<String> executeCommand(final StructureCommandI command, |
325 |
|
boolean getResponse) |
326 |
|
{ |
327 |
0 |
if (chimeraManager == null || command == null) |
328 |
|
{ |
329 |
|
|
330 |
0 |
return null; |
331 |
|
} |
332 |
0 |
List<String> reply = null; |
333 |
|
|
334 |
0 |
String cmd = command.getCommand().trim(); |
335 |
0 |
List<String> lastReply = chimeraManager |
336 |
|
.sendChimeraCommand(cmd, getResponse); |
337 |
0 |
if (getResponse) |
338 |
|
{ |
339 |
0 |
reply = lastReply; |
340 |
0 |
if (Cache.log.isDebugEnabled()) { |
341 |
0 |
Cache.log.debug( |
342 |
|
"Response from command ('" + cmd + "') was:\n" + lastReply); |
343 |
|
} |
344 |
|
} |
345 |
|
|
346 |
0 |
return reply; |
347 |
|
} |
348 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
349 |
0 |
@Override... |
350 |
|
public synchronized String[] getStructureFiles() |
351 |
|
{ |
352 |
0 |
if (chimeraManager == null) |
353 |
|
{ |
354 |
0 |
return new String[0]; |
355 |
|
} |
356 |
|
|
357 |
0 |
return chimeraMaps.keySet() |
358 |
|
.toArray(modelFileNames = new String[chimeraMaps.size()]); |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 13 |
Complexity Density: 0.43 |
|
365 |
0 |
@Override... |
366 |
|
public void highlightAtoms(List<AtomSpec> atoms) |
367 |
|
{ |
368 |
0 |
if (atoms == null || atoms.size() == 0) |
369 |
|
{ |
370 |
0 |
return; |
371 |
|
} |
372 |
|
|
373 |
0 |
boolean forChimeraX = chimeraManager.isChimeraX(); |
374 |
0 |
StringBuilder cmd = new StringBuilder(128); |
375 |
0 |
boolean first = true; |
376 |
0 |
boolean found = false; |
377 |
|
|
378 |
0 |
for (AtomSpec atom : atoms) |
379 |
|
{ |
380 |
0 |
int pdbResNum = atom.getPdbResNum(); |
381 |
0 |
String chain = atom.getChain(); |
382 |
0 |
String pdbfile = atom.getPdbFile(); |
383 |
0 |
List<ChimeraModel> cms = chimeraMaps.get(pdbfile); |
384 |
0 |
if (cms != null && !cms.isEmpty()) |
385 |
|
{ |
386 |
0 |
if (first) |
387 |
|
{ |
388 |
0 |
cmd.append(forChimeraX ? "label #" : "rlabel #"); |
389 |
|
} |
390 |
|
else |
391 |
|
{ |
392 |
0 |
cmd.append(","); |
393 |
|
} |
394 |
0 |
first = false; |
395 |
0 |
if (forChimeraX) |
396 |
|
{ |
397 |
0 |
cmd.append(cms.get(0).getModelNumber()) |
398 |
|
.append("/").append(chain).append(":").append(pdbResNum); |
399 |
|
} |
400 |
|
else |
401 |
|
{ |
402 |
0 |
cmd.append(cms.get(0).getModelNumber()) |
403 |
|
.append(":").append(pdbResNum); |
404 |
0 |
if (!chain.equals(" ") && !forChimeraX) |
405 |
|
{ |
406 |
0 |
cmd.append(".").append(chain); |
407 |
|
} |
408 |
|
} |
409 |
0 |
found = true; |
410 |
|
} |
411 |
|
} |
412 |
0 |
String command = cmd.toString(); |
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
0 |
if (command.equals(lastHighlightCommand)) |
418 |
|
{ |
419 |
0 |
return; |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
0 |
if (lastHighlightCommand != null) |
426 |
|
{ |
427 |
0 |
executeCommand(false, null, new StructureCommand("~" + lastHighlightCommand)); |
428 |
|
} |
429 |
0 |
if (found) |
430 |
|
{ |
431 |
0 |
executeCommand(false, null, new StructureCommand(command)); |
432 |
|
} |
433 |
0 |
this.lastHighlightCommand = command; |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
439 |
0 |
public void highlightChimeraSelection()... |
440 |
|
{ |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
0 |
StructureCommandI command = getCommandGenerator().getSelectedResidues(); |
445 |
|
|
446 |
0 |
Runnable action = new Runnable() |
447 |
|
{ |
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
448 |
0 |
@Override... |
449 |
|
public void run() |
450 |
|
{ |
451 |
0 |
List<String> chimeraReply = executeCommand(command, true); |
452 |
|
|
453 |
0 |
List<String> selectedResidues = new ArrayList<>(); |
454 |
0 |
if (chimeraReply != null) |
455 |
|
{ |
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
0 |
for (String inputLine : chimeraReply) |
465 |
|
{ |
466 |
0 |
String[] inputLineParts = inputLine.split("\\s+"); |
467 |
0 |
if (inputLineParts.length >= 5) |
468 |
|
{ |
469 |
0 |
selectedResidues.add(inputLineParts[2]); |
470 |
|
} |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
0 |
List<AtomSpec> atomSpecs = convertStructureResiduesToAlignment( |
479 |
|
selectedResidues); |
480 |
|
|
481 |
|
|
482 |
|
|
483 |
|
|
484 |
|
|
485 |
0 |
getSsm().mouseOverStructure(atomSpecs); |
486 |
|
|
487 |
|
} |
488 |
|
}; |
489 |
0 |
new Thread(action).start(); |
490 |
|
} |
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
|
@param |
497 |
|
@return |
498 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
499 |
0 |
protected List<AtomSpec> convertStructureResiduesToAlignment(... |
500 |
|
List<String> structureSelection) |
501 |
|
{ |
502 |
0 |
List<AtomSpec> atomSpecs = new ArrayList<>(); |
503 |
0 |
for (String atomSpec : structureSelection) |
504 |
|
{ |
505 |
0 |
try |
506 |
|
{ |
507 |
0 |
AtomSpec spec = parseAtomSpec(atomSpec); |
508 |
0 |
String pdbfilename = getPdbFileForModel(spec.getModelNumber()); |
509 |
0 |
spec.setPdbFile(pdbfilename); |
510 |
0 |
atomSpecs.add(spec); |
511 |
|
} catch (IllegalArgumentException e) |
512 |
|
{ |
513 |
0 |
Cache.log.error("Failed to parse atomspec: " + atomSpec); |
514 |
|
} |
515 |
|
} |
516 |
0 |
return atomSpecs; |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
|
@param |
521 |
|
@return |
522 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
523 |
0 |
protected String getPdbFileForModel(int modelId)... |
524 |
|
{ |
525 |
|
|
526 |
|
|
527 |
|
|
528 |
0 |
String pdbfilename = modelFileNames[0]; |
529 |
0 |
findfileloop: for (String pdbfile : this.chimeraMaps.keySet()) |
530 |
|
{ |
531 |
0 |
for (ChimeraModel cm : chimeraMaps.get(pdbfile)) |
532 |
|
{ |
533 |
0 |
if (cm.getModelNumber() == modelId) |
534 |
|
{ |
535 |
0 |
pdbfilename = pdbfile; |
536 |
0 |
break findfileloop; |
537 |
|
} |
538 |
|
} |
539 |
|
} |
540 |
0 |
return pdbfilename; |
541 |
|
} |
542 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
543 |
0 |
private void log(String message)... |
544 |
|
{ |
545 |
0 |
System.err.println("## Chimera log: " + message); |
546 |
|
} |
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
|
|
556 |
|
@param |
557 |
|
@return |
558 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
559 |
0 |
public int sendFeaturesToViewer(AlignmentViewPanel avp)... |
560 |
|
{ |
561 |
|
|
562 |
|
|
563 |
0 |
Map<String, Map<Object, AtomSpecModel>> featureValues = buildFeaturesMap( |
564 |
|
avp); |
565 |
0 |
List<StructureCommandI> commands = getCommandGenerator() |
566 |
|
.setAttributes(featureValues); |
567 |
0 |
if (commands.size() > 10) |
568 |
|
{ |
569 |
0 |
sendCommandsByFile(commands); |
570 |
|
} |
571 |
|
else |
572 |
|
{ |
573 |
0 |
executeCommands(commands, false, null); |
574 |
|
} |
575 |
0 |
return commands.size(); |
576 |
|
} |
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
@param |
584 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
585 |
0 |
protected void sendCommandsByFile(List<StructureCommandI> commands)... |
586 |
|
{ |
587 |
0 |
try |
588 |
|
{ |
589 |
0 |
File tmp = File.createTempFile("chim", getCommandFileExtension()); |
590 |
0 |
tmp.deleteOnExit(); |
591 |
0 |
PrintWriter out = new PrintWriter(new FileOutputStream(tmp)); |
592 |
0 |
for (StructureCommandI command : commands) |
593 |
|
{ |
594 |
0 |
out.println(command.getCommand()); |
595 |
|
} |
596 |
0 |
out.flush(); |
597 |
0 |
out.close(); |
598 |
0 |
String path = tmp.getAbsolutePath(); |
599 |
0 |
StructureCommandI command = getCommandGenerator() |
600 |
|
.openCommandFile(path); |
601 |
0 |
executeCommand(false, null, command); |
602 |
|
} catch (IOException e) |
603 |
|
{ |
604 |
0 |
System.err.println("Sending commands to Chimera via file failed with " |
605 |
|
+ e.getMessage()); |
606 |
|
} |
607 |
|
} |
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
@return |
613 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
614 |
0 |
protected String getCommandFileExtension()... |
615 |
|
{ |
616 |
0 |
return ".com"; |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
@param |
631 |
|
@param |
632 |
|
@return |
633 |
|
|
|
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 7 |
Complexity Density: 0.21 |
|
634 |
0 |
protected int createFeaturesForAttributes(String attName,... |
635 |
|
List<String> residues) |
636 |
|
{ |
637 |
0 |
int featuresAdded = 0; |
638 |
0 |
String featureGroup = getViewerFeatureGroup(); |
639 |
|
|
640 |
0 |
for (String residue : residues) |
641 |
|
{ |
642 |
0 |
AtomSpec spec = null; |
643 |
0 |
String[] tokens = residue.split(" "); |
644 |
0 |
if (tokens.length < 5) |
645 |
|
{ |
646 |
0 |
continue; |
647 |
|
} |
648 |
0 |
String atomSpec = tokens[2]; |
649 |
0 |
String attValue = tokens[4]; |
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
|
654 |
0 |
if ("None".equalsIgnoreCase(attValue) |
655 |
|
|| "False".equalsIgnoreCase(attValue)) |
656 |
|
{ |
657 |
0 |
continue; |
658 |
|
} |
659 |
|
|
660 |
0 |
try |
661 |
|
{ |
662 |
0 |
spec = parseAtomSpec(atomSpec); |
663 |
|
} catch (IllegalArgumentException e) |
664 |
|
{ |
665 |
0 |
Cache.log.error("Problem parsing atomspec " + atomSpec); |
666 |
0 |
continue; |
667 |
|
} |
668 |
|
|
669 |
0 |
String chainId = spec.getChain(); |
670 |
0 |
String description = attValue; |
671 |
0 |
float score = Float.NaN; |
672 |
0 |
try |
673 |
|
{ |
674 |
0 |
score = Float.valueOf(attValue); |
675 |
0 |
description = chainId; |
676 |
|
} catch (NumberFormatException e) |
677 |
|
{ |
678 |
|
|
679 |
|
} |
680 |
|
|
681 |
0 |
String pdbFile = getPdbFileForModel(spec.getModelNumber()); |
682 |
0 |
spec.setPdbFile(pdbFile); |
683 |
|
|
684 |
0 |
List<AtomSpec> atoms = Collections.singletonList(spec); |
685 |
|
|
686 |
|
|
687 |
|
|
688 |
|
|
689 |
0 |
SearchResultsI sr = getSsm() |
690 |
|
.findAlignmentPositionsForStructurePositions(atoms); |
691 |
|
|
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
|
696 |
0 |
for (SearchResultMatchI m : sr.getResults()) |
697 |
|
{ |
698 |
0 |
SequenceI seq = m.getSequence(); |
699 |
0 |
int start = m.getStart(); |
700 |
0 |
int end = m.getEnd(); |
701 |
0 |
SequenceFeature sf = new SequenceFeature(attName, description, |
702 |
|
start, end, score, featureGroup); |
703 |
|
|
704 |
|
|
705 |
0 |
if (seq.addSequenceFeature(sf)) |
706 |
|
{ |
707 |
0 |
featuresAdded++; |
708 |
|
} |
709 |
|
} |
710 |
|
} |
711 |
0 |
return featuresAdded; |
712 |
|
} |
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
@return |
719 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
720 |
0 |
protected String getViewerFeatureGroup()... |
721 |
|
{ |
722 |
|
|
723 |
0 |
return CHIMERA_FEATURE_GROUP; |
724 |
|
} |
725 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
726 |
0 |
@Override... |
727 |
|
public String getModelIdForFile(String pdbFile) |
728 |
|
{ |
729 |
0 |
List<ChimeraModel> foundModels = chimeraMaps.get(pdbFile); |
730 |
0 |
if (foundModels != null && !foundModels.isEmpty()) |
731 |
|
{ |
732 |
0 |
return String.valueOf(foundModels.get(0).getModelNumber()); |
733 |
|
} |
734 |
0 |
return ""; |
735 |
|
} |
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
|
|
741 |
|
@return |
742 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
743 |
0 |
public List<String> getChimeraAttributes()... |
744 |
|
{ |
745 |
0 |
List<String> attributes = new ArrayList<>(); |
746 |
0 |
StructureCommandI command = getCommandGenerator().listResidueAttributes(); |
747 |
0 |
final List<String> reply = executeCommand(command, true); |
748 |
0 |
if (reply != null) |
749 |
|
{ |
750 |
0 |
for (String inputLine : reply) |
751 |
|
{ |
752 |
0 |
String[] lineParts = inputLine.split("\\s"); |
753 |
0 |
if (lineParts.length == 2 && lineParts[0].equals("resattr")) |
754 |
|
{ |
755 |
0 |
String attName = lineParts[1]; |
756 |
|
|
757 |
|
|
758 |
|
|
759 |
0 |
if (!attName.startsWith(ChimeraCommands.NAMESPACE_PREFIX)) |
760 |
|
{ |
761 |
0 |
attributes.add(attName); |
762 |
|
} |
763 |
|
} |
764 |
|
} |
765 |
|
} |
766 |
0 |
return attributes; |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
@return |
773 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
774 |
0 |
@Override... |
775 |
|
public String getSessionFileExtension() |
776 |
|
{ |
777 |
0 |
return CHIMERA_SESSION_EXTENSION; |
778 |
|
} |
779 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
780 |
0 |
@Override... |
781 |
|
public String getHelpURL() |
782 |
|
{ |
783 |
0 |
return "https://www.cgl.ucsf.edu/chimera/docs/UsersGuide"; |
784 |
|
} |
785 |
|
} |