From: j.procter@dundee.ac.uk Date: Tue, 22 Jul 2014 18:37:34 +0000 (+0100) Subject: JAL-1333 more superposition debugging and deadlock avoidance X-Git-Tag: Jalview_2_9~179^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5cdee2262acaf572fe92b3410044ee93e666b818;p=jalview.git JAL-1333 more superposition debugging and deadlock avoidance --- diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java index 95ea0d7..c0b3a39 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java @@ -21,13 +21,13 @@ import ext.edu.ucsf.rbvi.strucviz2.port.ListenerThreads; public class ChimeraManager { - static private Process chimera; + private Process chimera; - static private ListenerThreads chimeraListenerThreads; + private ListenerThreads chimeraListenerThreads; - static private Map currentModelsMap; + private Map currentModelsMap; - private static Logger logger = LoggerFactory + private Logger logger = LoggerFactory .getLogger(ext.edu.ucsf.rbvi.strucviz2.ChimeraManager.class); private StructureManager structureManager; @@ -38,7 +38,7 @@ public class ChimeraManager chimera = null; chimeraListenerThreads = null; currentModelsMap = new HashMap(); - + } public List getChimeraModels(String modelName) @@ -627,7 +627,9 @@ public class ChimeraManager } return values; } - private volatile boolean busy=false; + + private volatile boolean busy = false; + /** * Send a command to Chimera. * @@ -647,11 +649,15 @@ public class ChimeraManager } while (busy) { - try { + try + { Thread.sleep(25); - } catch (InterruptedException q) {}; + } catch (InterruptedException q) + { + } + ; } - busy=true; + busy = true; chimeraListenerThreads.clearResponse(command); String text = command.concat("\n"); // System.out.println("send command to chimera: " + text); @@ -667,16 +673,16 @@ public class ChimeraManager logger.warn("Unable to execute command: " + text); logger.warn("Exiting..."); clearOnChimeraExit(); - busy=false; + busy = false; return null; } if (!reply) { - busy=false; + busy = false; return null; } List rsp = chimeraListenerThreads.getResponse(command); - busy=false; + busy = false; return rsp; } @@ -685,4 +691,9 @@ public class ChimeraManager return structureManager; } + public boolean isBusy() + { + return busy; + } + } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 5fc3a6f..fcf89af 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -326,7 +326,7 @@ public abstract class JalviewChimeraBinding extends if (cmd.length() > 0) cmd.setLength(cmd.length() - 4); evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmd + ";focus " - + cmd); + + cmd,false); } public void closeViewer() @@ -353,14 +353,14 @@ public abstract class JalviewChimeraBinding extends // TODO: colour by chain should colour each chain distinctly across all // visible models // TODO: http://issues.jalview.org/browse/JAL-628 - evalStateCommand("select *;color chain"); + evalStateCommand("select *;color chain",false); } public void colourByCharge() { colourBySequence = false; evalStateCommand("colour *;color white;select ASP,GLU;color red;" - + "select LYS,ARG;color blue;select CYS;color yellow"); + + "select LYS,ARG;color blue;select CYS;color yellow", false); } /** @@ -408,7 +408,7 @@ public abstract class JalviewChimeraBinding extends int[] _refStructure, ColumnSelection[] _hiddenCols) { assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length); - + StringBuffer allComs = new StringBuffer(); // whole shebang for superposition String[] files = getPdbFile(); // check to see if we are still waiting for Jmol files long starttime = System.currentTimeMillis(); @@ -483,6 +483,7 @@ public abstract class JalviewChimeraBinding extends // reference structure - all others are superposed in it String[] targetC = new String[files.length]; String[] chainNames = new String[files.length]; + String[] atomS = new String[files.length]; for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]); @@ -550,6 +551,7 @@ public abstract class JalviewChimeraBinding extends } chainNames[pdbfnum] = mapping[m].getPdbId() + targetC[pdbfnum]; + atomS[pdbfnum] = asp.getRNA()!=null ? "P" : "CA"; // move on to next pdb file s = sequence[pdbfnum].length; break; @@ -590,8 +592,7 @@ public abstract class JalviewChimeraBinding extends { molsel.append((run ? "" : ":") + lpos); molsel.append(chainCd); - // molsel.append("} {"); - // molsel.append(","); + molsel.append(","); } } else @@ -620,12 +621,11 @@ public abstract class JalviewChimeraBinding extends { selcom[pdbfnum] = molsel.toString(); selectioncom.append("#" + pdbfnum); - selectioncom.append(selcom[pdbfnum].substring(1, - selcom[pdbfnum].length() - 1)); + selectioncom.append(selcom[pdbfnum]); selectioncom.append(" "); if (pdbfnum < files.length - 1) { - selectioncom.append("|"); + selectioncom.append("| "); } } else @@ -641,24 +641,29 @@ public abstract class JalviewChimeraBinding extends { continue; } - command.append("match "); + if (command.length()>0) + { + command.append(";"); + } + command.append("match"); // form the matched pair strings for (int s = 0; s < 2; s++) { + command.append(" #"+(s == 0 ? pdbfnum : refStructure)+".1"); + // note - need to select on first model, otherwise it all goes wrong! command.append(selcom[(s == 0 ? pdbfnum : refStructure)]); + command.append("@"+atomS[(s == 0 ? pdbfnum : refStructure)]); // match on backbone alpha/polyphosphate } } if (selectioncom.length() > 0) { System.out.println("Select regions:\n" + selectioncom.toString()); - evalStateCommand("~display *; trace *; ribbons " - + selectioncom.toString() + ""); - // selcom.append("; ribbons; "); System.out .println("Superimpose command(s):\n" + command.toString()); - - evalStateCommand(command.toString()); + allComs.append("~display all; chain @CA|P; ribbon " + + selectioncom.toString() + ";"+command.toString()); + // selcom.append("; ribbons; "); } } if (selectioncom.length() > 0) @@ -668,10 +673,12 @@ public abstract class JalviewChimeraBinding extends selectioncom.setLength(selectioncom.length() - 1); } System.out.println("Select regions:\n" + selectioncom.toString()); - evalStateCommand("~display *; trace *; ribbons " + allComs.append("; ~display all; chain @CA|P; ribbon " + selectioncom.toString() + ""); // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString()); + evalStateCommand(allComs.toString(),false); } + } private void checkLaunched() @@ -686,7 +693,7 @@ public abstract class JalviewChimeraBinding extends } } - public void evalStateCommand(final String command) + public void evalStateCommand(final String command, boolean resp) { viewerCommandHistory(false); checkLaunched(); @@ -697,7 +704,7 @@ public abstract class JalviewChimeraBinding extends // @Override // public void run() // { - lastReply = viewer.sendChimeraCommand(command, true); + lastReply = viewer.sendChimeraCommand(command, resp); if (debug) { log("Response from command ('" + command + "') was:\n" @@ -748,10 +755,23 @@ public abstract class JalviewChimeraBinding extends alignment)) for (String cbyseq : cpdbbyseq.commands) { - evalStateCommand(cbyseq); + waitForChimera(); + evalStateCommand(cbyseq, false); + waitForChimera(); } } + private void waitForChimera() + { + while (viewer.isBusy()) + { + try { + Thread.sleep(15); + } catch (InterruptedException q) + {} + } + } + public boolean isColourBySequence() { return colourBySequence; @@ -899,7 +919,7 @@ public abstract class JalviewChimeraBinding extends int mdlNum = cms.get(0).getModelNumber(); viewerCommandHistory(false); - viewer.stopListening(); + // viewer.stopListening(); if (resetLastRes.length() > 0) { eval.setLength(0); @@ -926,7 +946,7 @@ public abstract class JalviewChimeraBinding extends viewer.sendChimeraCommand(eval.toString(), false); viewerCommandHistory(true); - viewer.startListening(); + // viewer.startListening(); } } @@ -1198,7 +1218,7 @@ public abstract class JalviewChimeraBinding extends + col.getGreen() + "," + col.getBlue() + "];"); } - evalStateCommand(command.toString()); + evalStateCommand(command.toString(),false); viewerCommandHistory(true); } diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 815957f..10082eb 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -586,7 +586,7 @@ public class ChimeraViewFrame extends GStructureViewer implements Runnable, { command = ""; } - jmb.evalStateCommand(command); + jmb.evalStateCommand(command, false); jmb.setFinishedInit(true); } @@ -845,13 +845,13 @@ public class ChimeraViewFrame extends GStructureViewer implements Runnable, // do superposition if asked to if (alignAddedStructures) { - javax.swing.SwingUtilities.invokeLater(new Runnable() + new Thread(new Runnable() { public void run() { alignStructs_withAllAlignPanels(); } - }); + }).start(); alignAddedStructures = false; } addingStructures = false;