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