Author: scooter
Date: 2010-07-11 20:18:16 -0700 (Sun, 11 Jul 2010)
New Revision: 20901
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Align.java
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/AnalysisCommands.java
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
Log:
Initial align implementation complete
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Align.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Align.java
2010-07-10 17:21:23 UTC (rev 20900)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/actions/Align.java
2010-07-12 03:18:16 UTC (rev 20901)
@@ -63,7 +63,7 @@
* requests to align structures.
*/
public class Align {
- private static final String[] attributeKeys =
{"RMSD","AlignmentScore","AlignedResidues"};
+ public static final String[] attributeKeys =
{"RMSD","AlignmentScore","AlignedResidues"};
/**
* Array offset to the RMSD result
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/AnalysisCommands.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/AnalysisCommands.java
2010-07-10 17:21:23 UTC (rev 20900)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/AnalysisCommands.java
2010-07-12 03:18:16 UTC (rev 20901)
@@ -38,23 +38,44 @@
import cytoscape.command.CyCommandException;
import cytoscape.command.CyCommandResult;
+import structureViz.actions.Align;
import structureViz.actions.AnalysisActions;
import structureViz.actions.Chimera;
import structureViz.actions.DisplayActions;
+import structureViz.model.ChimeraChain;
import structureViz.model.ChimeraModel;
import structureViz.model.ChimeraStructuralObject;
import structureViz.model.Structure;
/**
- *
+ * The analysis commands for structureViz
*/
public class AnalysisCommands extends AbstractCommands {
+ /**
+ * This is called to handle the "find clashes" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param structureList the structureList we're looking to find clashes
between
+ * @param continuous the continuous flag
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult findClashesStructure(Chimera chimera,
CyCommandResult result,
List<Structure>structureList, String continuous) {
- return findClashesSpecList(chimera, result,
specListFromStructureList(chimera, structureList), continuous);
+ return findClashesSpecList(chimera, result,
+ specListFromStructureList(chimera,
structureList), continuous);
}
+ /**
+ * This is called to handle the "find clashes" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param specList the specList we're looking to find clashes between
+ * @param continuous the continuous flag
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult findClashesSpecList(Chimera chimera,
CyCommandResult result,
List<ChimeraStructuralObject>specList, String continuous) {
boolean cont = false;
@@ -73,17 +94,41 @@
return addReplies(result, c, "Finding clashes for "+atomSpec);
}
+ /**
+ * This is called to handle the "clear clashes" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult clearClashes(Chimera chimera,
CyCommandResult result) {
List<String> c = AnalysisActions.clearClashAction(chimera);
result = addReplies(result, c, "Cleared clashes");
return result;
}
+ /**
+ * This is called to handle the "find hbonds" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param structureList the structureList we're looking to find clashes
between
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult findHBondsStructure(Chimera chimera,
CyCommandResult result,
List<Structure>structureList) {
return findHBondsSpecList(chimera, result,
specListFromStructureList(chimera, structureList));
}
+ /**
+ * This is called to handle the "find hbonds" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param specList the specList we're looking to find clashes between
+ * @param continuous the continuous flag
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult findHBondsSpecList(Chimera chimera,
CyCommandResult result,
List<ChimeraStructuralObject>specList) {
String atomSpec = "";
@@ -97,25 +142,95 @@
return addReplies(result, c, "Finding HBonds for "+atomSpec);
}
+ /**
+ * This is called to handle the "clear hbonds" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult clearHBonds(Chimera chimera,
CyCommandResult result) {
List<String> c = AnalysisActions.clearHBondAction(chimera);
result = addReplies(result, c, "Cleared hydrogen bonds");
return result;
}
+ /**
+ * This is called to handle the "align structures" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param referenceStruct the reference structure
+ * @param structureList the list of structures to align to the reference
+ * @param showSequences show the resulting pairwise alignments
+ * @param createEdges create edges in Cytoscape corresponding to the
alignments
+ * @param assignAttributes assign edge attributes with the alignment
results
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult alignStructures(Chimera chimera,
CyCommandResult result,
-
List<Structure>referenceStruct,
-
List<Structure>structureList) {
+ Structure
referenceStruct,
+ List<Structure>
structures,
+ boolean
showSequences, boolean createEdges,
+ boolean assignAttributes)
{
// Do the alignment
-
- return result;
+ Align align = getAlign(chimera, showSequences, createEdges,
assignAttributes);
+ align.align(referenceStruct, structures);
+ List<ChimeraStructuralObject>specList =
specListFromStructureList(chimera, structures);
+ return getAlignResults(align, result, specList);
}
+ /**
+ * This is called to handle the "align chains" command.
+ *
+ * @param chimera the Chimera object
+ * @param result the CyCommandResult
+ * @param referenceChain the reference chain
+ * @param structureList the list of chains to align to the reference
+ * @param showSequences show the resulting pairwise alignments
+ * @param createEdges create edges in Cytoscape corresponding to the
alignments
+ * @param assignAttributes assign edge attributes with the alignment
results
+ * @return the updated CyCommandResult
+ */
static public CyCommandResult alignChains(Chimera chimera,
CyCommandResult result,
-
List<ChimeraStructuralObject>reference,
-
List<ChimeraStructuralObject>chainList) {
+ ChimeraStructuralObject
referenceChain,
+
List<ChimeraStructuralObject>chainList,
+ boolean
showSequences, boolean createEdges,
+ boolean assignAttributes)
+ throws CyCommandException {
// Make sure everything is a chain
+ if (!(referenceChain instanceof ChimeraChain))
+ throw new CyCommandException("Reference chain must be a
chain specification");
+
+ for (ChimeraStructuralObject obj: chainList) {
+ if (!(obj instanceof ChimeraChain))
+ throw new CyCommandException("Chains to align
must be chain specifications");
+ }
// Do the alignment
+ Align align = getAlign(chimera, showSequences, createEdges,
assignAttributes);
+ align.align(referenceChain, chainList);
+ return getAlignResults(align, result, chainList);
+ }
+
+ private static Align getAlign(Chimera chimera, boolean showSequences,
boolean createEdges,
+ boolean assignAttributes) {
+ Align align = new Align(chimera);
+ align.setCreateEdges(assignAttributes);
+ align.setCreateNewEdges(createEdges);
+ align.setShowSequence(showSequences);
+ return align;
+ }
+
+ private static CyCommandResult getAlignResults(Align align,
CyCommandResult result,
+
List<ChimeraStructuralObject> matchList) {
+ for (ChimeraStructuralObject obj: matchList) {
+ float[] matchResults = align.getResults(obj.toString());
+ String resultMessage = "Alignment results for
"+obj.toString()+": ";
+ for (int i = 0; i < 3; i++) {
+ resultMessage +=
Align.attributeKeys[i]+"="+matchResults[i];
+ }
+ result.addMessage(resultMessage);
+ result.addResult(obj.toString(),
""+matchResults[0]+","+matchResults[1]+","+matchResults[2]);
+ }
return result;
}
}
Modified:
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
===================================================================
---
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
2010-07-10 17:21:23 UTC (rev 20900)
+++
csplugins/trunk/ucsf/scooter/structureViz/src/structureViz/commands/StructureVizCommandHandler.java
2010-07-12 03:18:16 UTC (rev 20901)
@@ -58,10 +58,10 @@
enum Command {
ALIGNSTRUCTURES("alignstructures",
"Perform sequence-driven structural superposition on a
group of structures",
- "reference|structurelist"),
+
"reference|structurelist|showsequences=false|createedges=false|assignattributes=true"),
ALIGNCHAINS("alignchains",
"Perform sequence-driven structural superposition on a
group of structures by chain",
- "referencechain|chainlist"),
+
"referencechain|chainlist|showsequences=false|createedges=false|assignattributes=true"),
CLEARCLASHES("clear clashes", "Clear clashes", ""),
CLEARHBONDS("clear hbonds", "Clear hydrogen bonds", ""),
CLEARSELECT("clear selection", "Clear all selection", ""),
@@ -111,10 +111,12 @@
CyLogger logger;
Chimera chimera = null;
+ public static final String ASSIGNATTRIBUTES = "assignattributes";
public static final String ATOMSPEC = "atomspec";
public static final String CHAIN = "chain";
public static final String CHAINLIST = "chainlist";
public static final String CONTINUOUS = "continuous";
+ public static final String CREATEEDGES = "createedges";
public static final String LABELS = "labels";
public static final String MODELLIST = "modellist";
public static final String NODELIST = "nodelist";
@@ -125,6 +127,7 @@
public static final String RIBBONS = "ribbons";
public static final String RIBBONSTYLE = "ribbonstyle";
public static final String SELECTED = "selected";
+ public static final String SHOWSEQUENCES = "showsequences";
public static final String STRUCTURELIST = "structurelist";
public static final String STRUCTURETYPE = "structuretype";
public static final String STYLE = "style";
@@ -171,7 +174,7 @@
//
// ALIGNSTRUCTURES("alignstructures",
// "Perform sequence-driven structural superposition
on a group of structures",
- // "reference|structurelist"),
+ //
"reference|structurelist|showsequences=false|createedges=false|assignattributes=true"),
//
if (Command.ALIGNSTRUCTURES.equals(command)) {
String reference = getArg(command,REFERENCE, args);
@@ -180,12 +183,19 @@
if (reference == null)
throw new CyCommandException("Must specify a
reference structure");
List<Structure> referenceStruct =
CommandUtils.getStructureList(reference, chimera);
- result = AnalysisCommands.alignStructures(chimera,
result, referenceStruct, structureList);
+ if (referenceStruct == null || referenceStruct.size()
!= 1)
+ throw new CyCommandException("Only one
reference structure may be specified");
+ boolean showSequences = getBooleanArg(command,
SHOWSEQUENCES, args);
+ boolean createEdges = getBooleanArg(command,
CREATEEDGES, args);
+ boolean assignAttributes = getBooleanArg(command,
ASSIGNATTRIBUTES, args);
+ result = AnalysisCommands.alignStructures(chimera,
result, referenceStruct.get(0),
+
structureList, showSequences, createEdges,
+
assignAttributes);
//
// ALIGNCHAINS("alignchains",
// "Perform sequence-driven structural superposition on a
group of structures by chain",
- // "referencechain|chainlist"),
+ //
"referencechain|chainlist|showsequences=false|createedges=false|assignattributes=true"),
//
} else if (Command.ALIGNCHAINS.equals(command)) {
String reference = getArg(command,REFERENCECHAIN, args);
@@ -196,7 +206,13 @@
throw new CyCommandException("Must specify a
reference chain");
List<ChimeraStructuralObject> referenceCSO =
CommandUtils.getSpecList(reference,chimera);
List<ChimeraStructuralObject> chainList =
CommandUtils.getSpecList(chainlist,chimera);
- result = AnalysisCommands.alignChains(chimera, result,
referenceCSO, chainList);
+ if (referenceCSO.size() != 1)
+ throw new CyCommandException("Only one
reference chain may be specified");
+ boolean showSequences = getBooleanArg(command,
SHOWSEQUENCES, args);
+ boolean createEdges = getBooleanArg(command,
CREATEEDGES, args);
+ boolean assignAttributes = getBooleanArg(command,
ASSIGNATTRIBUTES, args);
+ result = AnalysisCommands.alignChains(chimera, result,
referenceCSO.get(0), chainList,
+ showSequences,
createEdges, assignAttributes);
//
// CLEARCLASHES("clear clashes", "Clear clashes"),
@@ -450,6 +466,15 @@
return result;
}
+ private boolean getBooleanArg(String command, String arg, Map<String,
Object>args) {
+ String com = getArg(command, arg, args);
+ if (com == null || com.length() == 0) return false;
+ boolean b = false;
+ b = Boolean.parseBoolean(com);
+ // throw new CyCommandException(arg+" must be 'true' or
'false'");
+ return b;
+ }
+
private void addCommand(String command, String description, String
argString) {
// Add the description first
addDescription(command, description);
--
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.