import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResultsI;
String lastHighlightCommand;
/**
- * Returns a model of the structure positions described by the Chimera format atomspec
+ * Returns a model of the structure positions described by the Chimera format
+ * atomspec
+ *
* @param atomSpec
* @return
*/
- protected AtomSpec parseAtomSpec(String atomSpec)
+ protected AtomSpec parseAtomSpec(String atomSpec)
{
return AtomSpec.fromChimeraAtomspec(atomSpec);
}
/**
* Open a PDB structure file in Chimera and set up mappings from Jalview.
*
- * We check if the PDB model id is already loaded in Chimera, if so don't reopen
- * it. This is the case if Chimera has opened a saved session file.
+ * We check if the PDB model id is already loaded in Chimera, if so don't
+ * reopen it. This is the case if Chimera has opened a saved session file.
*
* @param pe
* @return
{
super(ssm, pdbentry, sequenceIs, protocol);
boolean chimeraX = ViewerType.CHIMERAX.equals(getViewerType());
- chimeraManager = chimeraX ? new ChimeraXManager(new StructureManager(true)) : new ChimeraManager(new StructureManager(true));
- setStructureCommands(chimeraX ? new ChimeraXCommands() : new ChimeraCommands());
+ chimeraManager = chimeraX
+ ? new ChimeraXManager(new StructureManager(true))
+ : new ChimeraManager(new StructureManager(true));
+ setStructureCommands(
+ chimeraX ? new ChimeraXCommands() : new ChimeraCommands());
}
@Override
}
/**
- * Start a dedicated HttpServer to listen for Chimera notifications, and tell it
- * to start listening
+ * Start a dedicated HttpServer to listen for Chimera notifications, and tell
+ * it to start listening
*/
public void startChimeraListener()
{
startListening(chimeraListener.getUri());
} catch (BindException e)
{
- System.err.println(
+ jalview.bin.Console.errPrintln(
"Failed to start Chimera listener: " + e.getMessage());
}
}
chimeraListener.shutdown();
chimeraListener = null;
}
-
+
/*
* the following call is added to avoid a stack trace error in Chimera
* after "stop really" is sent; Chimera > 1.14 will not need it; see also
@Override
public boolean isViewerRunning()
{
- return chimeraManager.isChimeraLaunched();
+ return chimeraManager != null && chimeraManager.isChimeraLaunched();
}
/**
List<String> reply = null;
// trim command or it may never find a match in the replyLog!!
String cmd = command.getCommand().trim();
- List<String> lastReply = chimeraManager
- .sendChimeraCommand(cmd, getResponse);
+ List<String> lastReply = chimeraManager.sendChimeraCommand(cmd,
+ getResponse);
if (getResponse)
{
reply = lastReply;
- if (Cache.log.isDebugEnabled()) {
- Cache.log.debug(
- "Response from command ('" + cmd + "') was:\n" + lastReply);
+ if (Console.isDebugEnabled())
+ {
+ Console.debug(
+ "Response from command ('" + cmd + "') was:\n" + lastReply);
+ }
+ }
+ else
+ {
+ if (Console.isDebugEnabled())
+ {
+ Console.debug("Command executed: " + cmd);
}
}
}
/**
- * Construct and send a command to highlight zero, one or more atoms. We do this
- * by sending an "rlabel" command to show the residue label at that position.
+ * Construct and send a command to highlight zero, one or more atoms. We do
+ * this by sending an "rlabel" command to show the residue label at that
+ * position.
*/
@Override
public void highlightAtoms(List<AtomSpec> atoms)
first = false;
if (forChimeraX)
{
- cmd.append(cms.get(0).getModelNumber())
- .append("/").append(chain).append(":").append(pdbResNum);
+ cmd.append(cms.get(0).getModelNumber()).append("/").append(chain)
+ .append(":").append(pdbResNum);
}
else
{
- cmd.append(cms.get(0).getModelNumber())
- .append(":").append(pdbResNum);
+ cmd.append(cms.get(0).getModelNumber()).append(":")
+ .append(pdbResNum);
if (!chain.equals(" ") && !forChimeraX)
{
cmd.append(".").append(chain);
{
return;
}
-
+ if (!found)
+ {
+ // not a valid residue label command, so clear
+ cmd.setLength(0);
+ }
/*
- * unshow the label for the previous residue
+ * prepend with command
+ * to unshow the label for the previous residue
*/
if (lastHighlightCommand != null)
{
- executeCommand(false, null, new StructureCommand("~" + lastHighlightCommand));
+ cmd.insert(0, ";");
+ cmd.insert(0, lastHighlightCommand);
+ cmd.insert(0, "~");
+
+ }
+ if (cmd.length() > 0)
+ {
+ executeCommand(true, null, new StructureCommand(cmd.toString()));
}
+
if (found)
{
- executeCommand(false, null, new StructureCommand(command));
+ this.lastHighlightCommand = command;
}
- this.lastHighlightCommand = command;
}
/**
* Ask Chimera for its current selection
*/
StructureCommandI command = getCommandGenerator().getSelectedResidues();
-
+
Runnable action = new Runnable()
{
@Override
public void run()
{
List<String> chimeraReply = executeCommand(command, true);
-
+
List<String> selectedResidues = new ArrayList<>();
if (chimeraReply != null)
{
* selections)
*/
getSsm().mouseOverStructure(atomSpecs);
-
+
}
};
new Thread(action).start();
}
/**
- * Converts a list of Chimera(X) atomspecs to a list of AtomSpec representing the
- * corresponding residues (if any) in Jalview
+ * Converts a list of Chimera(X) atomspecs to a list of AtomSpec representing
+ * the corresponding residues (if any) in Jalview
*
* @param structureSelection
* @return
atomSpecs.add(spec);
} catch (IllegalArgumentException e)
{
- Cache.log.error("Failed to parse atomspec: " + atomSpec);
+ Console.error("Failed to parse atomspec: " + atomSpec);
}
}
return atomSpecs;
private void log(String message)
{
- System.err.println("## Chimera log: " + message);
+ jalview.bin.Console.errPrintln("## Chimera log: " + message);
}
/**
}
/**
- * Write commands to a temporary file, and send a command to Chimera to open the
- * file as a commands script. For use when sending a large number of separate
- * commands would overload the REST interface mechanism.
+ * Write commands to a temporary file, and send a command to Chimera to open
+ * the file as a commands script. For use when sending a large number of
+ * separate commands would overload the REST interface mechanism.
*
* @param commands
*/
executeCommand(false, null, command);
} catch (IOException e)
{
- System.err.println("Sending commands to Chimera via file failed with "
+ jalview.bin.Console.errPrintln("Sending commands to Chimera via file failed with "
+ e.getMessage());
}
}
/**
* Returns the file extension required for a file of commands to be read by
* the structure viewer
+ *
* @return
*/
protected String getCommandFileExtension()
spec = parseAtomSpec(atomSpec);
} catch (IllegalArgumentException e)
{
- Cache.log.error("Problem parsing atomspec " + atomSpec);
+ Console.error("Problem parsing atomspec " + atomSpec);
continue;
}
public List<String> getChimeraAttributes()
{
List<String> attributes = new ArrayList<>();
- StructureCommandI command = getCommandGenerator().listResidueAttributes();
+ StructureCommandI command = getCommandGenerator()
+ .listResidueAttributes();
final List<String> reply = executeCommand(command, true);
if (reply != null)
{