Author: scooter
Date: 2010-07-08 22:01:18 -0700 (Thu, 08 Jul 2010)
New Revision: 20864
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/CyChimera.java
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/DisplayActions.java
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/DisplayCommands.java
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
Log:
More clean-up, debugging, and additional options. Still haven't implemented
align, though
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/CyChimera.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/CyChimera.java
2010-07-09 00:08:23 UTC (rev 20863)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/CyChimera.java
2010-07-09 05:01:18 UTC (rev 20864)
@@ -180,6 +180,7 @@
* @return a comma-separated String of PDB structures
*/
public static String getStructureName(String nodeID) {
+ if (cyAttributes == null) cyAttributes =
Cytoscape.getNodeAttributes();
for (int key = 0; key < structureKeys.length; key++) {
if (structureKeys[key] == null) continue;
if (cyAttributes.hasAttribute(nodeID, structureKeys[key])) {
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/DisplayActions.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/DisplayActions.java
2010-07-09 00:08:23 UTC (rev 20863)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/DisplayActions.java
2010-07-09 05:01:18 UTC (rev 20864)
@@ -52,23 +52,25 @@
return chimera.commandReply("preset apply "+preset);
}
- public static List<String> displayAction(Chimera chimera, String
atomSpec, boolean hide) {
+ public static List<String> displayAction(Chimera chimera, String
atomSpec, String structSpec, boolean hide) {
String command = "display";
if (hide) command = "~display";
- return chimera.commandReply(addAtomSpec("command",atomSpec));
+ return
chimera.commandReply(addAtomSpec(command,atomSpec,structSpec));
}
public static List<String> focusAction(Chimera chimera, String
atomSpec) {
return chimera.commandReply(addAtomSpec("focus",atomSpec));
}
- public static List<String> selectAction(Chimera chimera, String
atomSpec) {
- return chimera.commandReply(addAtomSpec("select",atomSpec));
+ public static List<String> selectAction(Chimera chimera, String
atomSpec, String structSpec, boolean clear) {
+ String command = "select";
+ if (clear) command = "~select";
+ return
chimera.commandReply(addAtomSpec(command,atomSpec,structSpec));
}
public static List<String> depictAtomsAction(Chimera chimera, String
atomSpec, String depiction) {
if (depiction.equals("none"))
- return displayAction(chimera, atomSpec, true);
+ return displayAction(chimera, atomSpec, null, true);
return chimera.commandReply(addAtomSpec("repr "+depiction,
atomSpec));
}
@@ -109,6 +111,15 @@
return chimera.commandReply(command);
}
+ private static String addAtomSpec(String command, String atomSpec,
String structSpec) {
+ String com = addAtomSpec(command, atomSpec);
+ if (atomSpec != null)
+ com += " & "+structSpec;
+ else
+ com += " "+structSpec;
+ return com;
+ }
+
private static String addAtomSpec(String command, String atomSpec) {
if (atomSpec != null) {
return command+" "+atomSpec;
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/DisplayCommands.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/DisplayCommands.java
2010-07-09 00:08:23 UTC (rev 20863)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/DisplayCommands.java
2010-07-09 05:01:18 UTC (rev 20864)
@@ -114,16 +114,22 @@
}
static public CyCommandResult displayStructure(Chimera chimera,
CyCommandResult result,
-
List<Structure>structureList, boolean hide) {
- return displaySpecList(chimera, result,
specListFromStructureList(chimera, structureList), hide);
+
List<Structure>structureList, String structSpec, boolean hide)
+
throws CyCommandException {
+ return displaySpecList(chimera, result,
specListFromStructureList(chimera, structureList), structSpec, hide);
}
static public CyCommandResult displaySpecList(Chimera chimera,
CyCommandResult result,
-
List<ChimeraStructuralObject>specList, boolean hide) {
+
List<ChimeraStructuralObject>specList, String structSpec, boolean hide)
+
throws CyCommandException {
+ checkStructSpec(structSpec);
for (ChimeraStructuralObject cso: specList) {
String atomSpec = cso.toSpec();
- List<String> c = DisplayActions.displayAction(chimera,
atomSpec, hide);
- result = addReplies(result, c, "Hid "+cso);
+ List<String> c = DisplayActions.displayAction(chimera,
atomSpec, structSpec, hide);
+ if (hide)
+ result = addReplies(result, c, "Hid "+cso);
+ else
+ result = addReplies(result, c, "Showing "+cso);
}
return result;
@@ -152,21 +158,29 @@
}
static public CyCommandResult selectStructure(Chimera chimera,
CyCommandResult result,
-
List<Structure>structureList) {
- return selectSpecList(chimera, result,
specListFromStructureList(chimera, structureList));
+
List<Structure>structureList, String structSpec, boolean clear)
+
throws CyCommandException {
+ return selectSpecList(chimera, result,
specListFromStructureList(chimera, structureList), structSpec, clear);
}
static public CyCommandResult selectSpecList(Chimera chimera,
CyCommandResult result,
-
List<ChimeraStructuralObject>specList) {
+
List<ChimeraStructuralObject>specList, String structSpec, boolean clear)
+
throws CyCommandException {
+ checkStructSpec(structSpec);
if (specList == null || specList.size() == 0) {
- List<String> c = DisplayActions.selectAction(chimera,
null);
- result = addReplies(result, c, "Selected entire scene");
+ if (structSpec == null) {
+ List<String> c =
DisplayActions.selectAction(chimera, null, null, clear);
+ result = addReplies(result, c, "Selected entire
scene");
+ } else {
+ List<String> c =
DisplayActions.selectAction(chimera, null, structSpec, clear);
+ result = addReplies(result, c, "Selected
"+structSpec+" in entire scene");
+ }
return result;
}
for (ChimeraStructuralObject cso: specList) {
String atomSpec = cso.toSpec();
- List<String> c = DisplayActions.selectAction(chimera,
atomSpec);
+ List<String> c = DisplayActions.selectAction(chimera,
atomSpec, structSpec, clear);
result = addReplies(result, c, "Selected "+cso);
}
@@ -277,4 +291,20 @@
addReplies(result, c, "Rotated "+modelSpec+" "+d+" degrees in
the "+axis+" direction");
}
+ static private void checkStructSpec(String structSpec) throws
CyCommandException {
+ // Legal structure designations
+ String[] legalStructSpec = {"full","minimal",
"ions","ligand","main","nucleic acid","protein","helix","strand","turn",
+ "with CA/C1'", "without
CA/C1'","solvent"};
+
+ if (structSpec == null) return;
+
+ String legalList = "";
+ for (String s: legalStructSpec) legalList += ","+s;
+
+ if (!legalArgument(structSpec, legalStructSpec))
+ throw new CyCommandException("structuretype
specification "+structSpec+
+ " is unknown. Legal
values are: ["+legalList.substring(1)+"]");
+ return;
+ }
+
}
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
2010-07-09 00:08:23 UTC (rev 20863)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
2010-07-09 05:01:18 UTC (rev 20864)
@@ -61,6 +61,7 @@
"reference|structureList|referencechain|chainlist"),
CLEARCLASHES("clear clashes", "Clear clashes", ""),
CLEARHBONDS("clear hbonds", "Clear hydrogen bonds", ""),
+ CLEARSELECT("clear selection", "Clear all selection", ""),
CLOSE("close", "Close some or all of the currently opened
structures","structurelist=selected"),
COLOR("color", "Color part of all of a structure",
"preset|residues|labels|ribbons|surfaces|structurelist|atomspec"),
@@ -70,7 +71,7 @@
FINDCLASHES("find clashes", "Find clashes between two models or parts
of models","structurelist|atomspec=selected|continuous"),
FINDHBONDS("find hbonds", "Find hydrogen bonds between two models or
parts of models","structurelist|atomspec=selected"),
FOCUS("focus", "Focus on a structure or part of a
structure","structurelist|atomspec"),
- HIDE("hide", "Hide parts of a structure",
"structurelist|atomspec=selected"),
+ HIDE("hide", "Hide parts of a structure",
"structurelist|atomspec=selected|structuretype"),
LISTCHAINS("list chains", "List the chains in a structure",
"structurelist=all"),
LISTRES("list residues", "List the residues in a structure",
"structurelist=all|chain"),
LISTSTRUCTURES("list structures", "List all of the open structures",""),
@@ -79,9 +80,9 @@
RAINBOW("rainbow", "Color part of all of a structure in a rainbow
scheme",
"structurelist|atomspec"),
ROTATE("rotate", "Rotate a
model","x|y|z|center|structurelist=selected"),
- SELECT("select", "Select a structure or parts of a structure",
"structurelist|atomspec"),
+ SELECT("select", "Select a structure or parts of a structure",
"structurelist|atomspec|structuretype"),
SEND("send", "Send a command to chimera", "command"),
- SHOW("show", "Show parts of a structure", "structurelist|atomspec");
+ SHOW("show", "Show parts of a structure",
"structurelist|atomspec|structuretype");
private String command = null;
private String argList = null;
@@ -118,7 +119,8 @@
public static final String RIBBONS = "ribbons";
public static final String RIBBONSTYLE = "ribbonstyle";
public static final String SELECTED = "selected";
- public static final String STRUCTURELIST = "structureList";
+ public static final String STRUCTURELIST = "structurelist";
+ public static final String STRUCTURETYPE = "structuretype";
public static final String STYLE = "style";
public static final String SURFACES = "surfaces";
public static final String SURFACESTYLE = "surfacestyle";
@@ -143,6 +145,13 @@
throws
CyCommandException, RuntimeException {
CyCommandResult result = new CyCommandResult();
+ // Check all args to handle any errors
+ List<String> legalArgs = getArguments(command);
+ for (String arg: args.keySet()) {
+ if (!legalArgs.contains(arg))
+ throw new RuntimeException("structureviz
"+command+": unknown argument: "+arg);
+ }
+
// Launch Chimera
this.chimera =
Chimera.GetChimeraInstance(Cytoscape.getCurrentNetworkView(), logger);
if (!chimera.isLaunched() && !launchChimera(result, chimera))
@@ -150,7 +159,6 @@
String structureSpec = getArg(command, STRUCTURELIST, args);
List<Structure> structureList =
CommandUtils.getStructureList(structureSpec, chimera);
- // System.out.println("Structurelist = "+structureList);
// Main command cascade
if (Command.ALIGNSTRUCTURES.equals(command)) {
@@ -168,6 +176,19 @@
result = AnalysisCommands.clearHBonds(chimera,
result);
//
+ // CLEARSELECT("clear selection", "Clear all selection", ""),
+ //
+ } else if (Command.CLEARSELECT.equals(command)) {
+ String structSpec = getArg(command,STRUCTURETYPE, args);
+ if (structureList != null) {
+ result =
DisplayCommands.selectStructure(chimera, result, structureList, structSpec,
true);
+ } else {
+ String atomSpec = getArg(command,ATOMSPEC,
args);
+ List<ChimeraStructuralObject> specList =
CommandUtils.getSpecList(atomSpec,chimera);
+ result =
DisplayCommands.selectSpecList(chimera, result, specList, structSpec, true);
+ }
+
+ //
// CLOSE("close", "Close some or all of the currently opened
structures","structurelist=selected"),
//
} else if (Command.CLOSE.equals(command)) {
@@ -266,12 +287,13 @@
// HIDE("hide", "Hide parts of a structure",
"structurelist|atomspec=selected"),
//
} else if (Command.HIDE.equals(command)) {
+ String structSpec = getArg(command,STRUCTURETYPE, args);
if (structureList != null) {
- result =
DisplayCommands.displayStructure(chimera, result, structureList, true);
+ result =
DisplayCommands.displayStructure(chimera, result, structureList, structSpec,
true);
} else {
String atomSpec = getArg(command,ATOMSPEC,
args);
List<ChimeraStructuralObject> specList =
CommandUtils.getSpecList(atomSpec,chimera);
- result =
DisplayCommands.displaySpecList(chimera, result, specList, true);
+ result =
DisplayCommands.displaySpecList(chimera, result, specList, structSpec, true);
}
//
@@ -356,12 +378,13 @@
// SELECT("select", "Select a structure or parts of a
structure", "structurelist|atomspec"),
//
} else if (Command.SELECT.equals(command)) {
+ String structSpec = getArg(command,STRUCTURETYPE, args);
if (structureList != null) {
- result =
DisplayCommands.selectStructure(chimera, result, structureList);
+ result =
DisplayCommands.selectStructure(chimera, result, structureList, structSpec,
false);
} else {
String atomSpec = getArg(command,ATOMSPEC,
args);
List<ChimeraStructuralObject> specList =
CommandUtils.getSpecList(atomSpec,chimera);
- result =
DisplayCommands.selectSpecList(chimera, result, specList);
+ result =
DisplayCommands.selectSpecList(chimera, result, specList, structSpec, false);
}
//
@@ -379,12 +402,13 @@
// SHOW("show", "Show parts of a structure",
"structurelist|atomspec");
//
} else if (Command.SHOW.equals(command)) {
+ String structSpec = getArg(command,STRUCTURETYPE, args);
if (structureList != null) {
- result =
DisplayCommands.displayStructure(chimera, result, structureList, false);
+ result =
DisplayCommands.displayStructure(chimera, result, structureList, structSpec,
false);
} else {
String atomSpec = getArg(command,ATOMSPEC,
args);
List<ChimeraStructuralObject> specList =
CommandUtils.getSpecList(atomSpec,chimera);
- result =
DisplayCommands.displaySpecList(chimera, result, specList, false);
+ result =
DisplayCommands.displaySpecList(chimera, result, specList, structSpec, false);
}
}
@@ -392,6 +416,9 @@
}
private void addCommand(String command, String description, String
argString) {
+ // Add the description first
+ addDescription(command, description);
+
if (argString == null) {
addArgument(command);
return;
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.