Author: scooter
Date: 2012-10-11 20:11:14 -0700 (Thu, 11 Oct 2012)
New Revision: 30659
Added:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/MCSSMenus.java
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
Log:
MCSS now has UI
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
2012-10-11 22:28:48 UTC (rev 30658)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
2012-10-12 03:11:14 UTC (rev 30659)
@@ -55,6 +55,11 @@
chemViz.menu.reloadstructures.thisNode=for this node
chemViz.menu.reloadstructures.all=for all nodes and edges
chemViz.menu.reloadstructures.selectedNodes=for selected nodes
+chemViz.menu.showmcss=Show Maximum Common Substructure (MCSS)
+chemViz.menu.showmcss.thisEdge=for this edge
+chemViz.menu.showmcss.selectedEdges=for selected edges
+chemViz.menu.showmcss.thisNode=for this node
+chemViz.menu.showmcss.selectedNodes=for selected nodes
##
# 2D Structure Depictor Messages
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
2012-10-11 22:28:48 UTC (rev 30658)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -340,7 +340,7 @@
showresult =
Boolean.parseBoolean(args.get(SHOWRESULT).toString());
}
- CreateMCSSTask mcssTask = new CreateMCSSTask(gObjList,
attributes, dialog);
+ CreateMCSSTask mcssTask = new CreateMCSSTask(gObjList,
attributes, dialog, false);
TaskManager.executeTask(mcssTask,
mcssTask.getDefaultTaskConfig());
try {
@@ -355,7 +355,7 @@
if (showresult) {
String label = "MCSS = "+mcss;
List<Compound> mcssList =
ValueUtils.getCompounds(null, mcss, AttriType.smiles, null, null);
- CreatePopupTask loader = new
CreatePopupTask(mcssList, null, dialog, label, dialog.getMaxCompounds());
+ CreatePopupTask loader = new
CreatePopupTask(mcssList, null, dialog, label, 1);
TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
if (popupTasks == null) popupTasks = new
HashMap<Integer, CreatePopupTask>();
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
2012-10-11 22:28:48 UTC (rev 30658)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -121,12 +121,13 @@
new DepictionMenus(m, systemProperties, settingsDialog,
(EdgeView) context);
new AttributesMenu(m, systemProperties, settingsDialog,
(EdgeView) context);
new StructureMenus(m, systemProperties, settingsDialog,
(EdgeView) context);
+ new MCSSMenus(m, systemProperties, settingsDialog,
(EdgeView) context);
updateLinkOut(((EdgeView)context).getEdge());
} else {
new DepictionMenus(m, systemProperties, settingsDialog,
(NodeView) context);
new NodeGraphicsMenus(m, systemProperties,
settingsDialog, (NodeView) context);
new AttributesMenu(m, systemProperties, settingsDialog,
(NodeView) context);
- new StructureMenus(m, systemProperties, settingsDialog,
(NodeView) context);
+ new MCSSMenus(m, systemProperties, settingsDialog,
(NodeView) context);
updateLinkOut(((NodeView)context).getNode());
}
new SimilarityMenu(m, systemProperties, settingsDialog);
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
2012-10-11 22:28:48 UTC (rev 30658)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -98,6 +98,7 @@
new SimilarityMenu(m, systemProps, settingsDialog);
new AttributesMenu(m, systemProps, settingsDialog, null);
new StructureMenus(m, systemProps, settingsDialog, null);
+ new MCSSMenus(m, systemProps, settingsDialog, null);
new SettingsMenu(m, systemProps, settingsDialog);
}
Added: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/MCSSMenus.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/MCSSMenus.java
(rev 0)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/MCSSMenus.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -0,0 +1,206 @@
+/*
+ Copyright (c) 2006, 2007, 2008 The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package chemViz.menus;
+
+import giny.model.GraphObject;
+import giny.view.EdgeView;
+import giny.view.NodeView;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import cytoscape.CyEdge;
+import cytoscape.CyNetwork;
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.task.Task;
+import cytoscape.task.util.TaskManager;
+
+import chemViz.model.Compound;
+import chemViz.ui.ChemInfoSettingsDialog;
+import chemViz.tasks.CreateMCSSTask;
+import chemViz.tasks.CreatePopupTask;
+
+
+/**
+ * This plugin adds cheminformatics tools to Cytoscape.
+ */
+public class MCSSMenus extends ChemVizAbstractMenu implements ActionListener {
+
+ Object context = null;
+
+ /**
+ * This is the main constructor, which will be called by Cytoscape's
Plugin Manager.
+ * Add our listeners and create the main menu.
+ */
+ public MCSSMenus(JMenu menu, Properties systemProps,
+ ChemInfoSettingsDialog settingsDialog, Object context) {
+ super(systemProps, settingsDialog);
+
+ this.context = context;
+ JMenu clear = new
JMenu(systemProps.getProperty("chemViz.menu.showmcss"));
+ if (context == null) {
+ addEdgeMCSSMenus(clear, "chemViz.menu.showmcss", null);
+ addNodeMCSSMenus(clear, "chemViz.menu.showmcss", null);
+ } else if (context instanceof NodeView) {
+ addNodeMCSSMenus(clear, "chemViz.menu.showmcss",
(NodeView)context);
+ } else {
+ addEdgeMCSSMenus(clear, "chemViz.menu.showmcss",
(EdgeView)context);
+ }
+ menu.add(clear);
+
+ }
+
+ /**
+ * Builds the popup menu for edge depiction
+ *
+ * @param menu the menu we're going add our items to
+ * @param edgeContext the EdgeView this menu is for
+ */
+ private void addEdgeMCSSMenus(JMenu menu, String prefix, EdgeView
edgeContext) {
+ // Check and see if we have any edge attributes
+ Collection<CyEdge> selectedEdges =
Cytoscape.getCurrentNetwork().getSelectedEdges();
+
+ if (edgeContext == null) {
+ // Populating main menu
+ if (selectedEdges != null && selectedEdges.size() > 0) {
+ JMenuItem item2 =
buildMenuItem(prefix+".selectedEdges", prefix+".selectedEdges");
+ if
(!settingsDialog.hasEdgeCompounds(selectedEdges)) {
+ item2.setEnabled(false);
+ }
+ menu.add(item2);
+ }
+ return;
+ }
+
+ menu.add(buildMenuItem(prefix+".thisEdge",
+ prefix+".thisEdge"));
+
+ if (selectedEdges == null) selectedEdges = new ArrayList();
+
+ if (!selectedEdges.contains(edgeContext.getEdge()))
+ selectedEdges.add((CyEdge)edgeContext.getEdge());
+
+ menu.add(buildMenuItem(prefix+".selectedEdges",
+ prefix+".selectedEdges"));
+
+ if (!settingsDialog.hasEdgeCompounds(selectedEdges)) {
+ menu.setEnabled(false);
+ }
+ return;
+ }
+
+ /**
+ * Builds the popup menu for node depiction
+ *
+ * @param menu the menu we're going add our items to
+ * @param nodeContext the NodeView this menu is for
+ */
+ private void addNodeMCSSMenus(JMenu menu, String prefix, NodeView
nodeContext) {
+ // Check and see if we have any node attributes
+ Collection<CyNode> selectedNodes =
Cytoscape.getCurrentNetwork().getSelectedNodes();
+
+ if (nodeContext == null) {
+ // Populating main menu
+ JMenuItem item = buildMenuItem(prefix+".all",
prefix+".all");
+ if (!settingsDialog.hasNodeCompounds(null))
+ item.setEnabled(false);
+
+ menu.add(item);
+ if (selectedNodes != null && selectedNodes.size() > 0) {
+ JMenuItem item2 =
buildMenuItem(prefix+".selectedNodes", prefix+".selectedNodes");
+ if
(!settingsDialog.hasNodeCompounds(selectedNodes))
+ item2.setEnabled(false);
+ menu.add(item2);
+ }
+ return;
+ }
+
+ // Populating popup menu
+ menu.add(buildMenuItem(prefix+".thisNode", prefix+".thisNode"));
+
+ if (selectedNodes == null) selectedNodes = new ArrayList();
+
+ if (!selectedNodes.contains(nodeContext.getNode()))
+ selectedNodes.add((CyNode)nodeContext.getNode());
+
+ menu.add(buildMenuItem(prefix+".selectedNodes",
prefix+".selectedNodes"));
+
+ if (!settingsDialog.hasNodeCompounds(selectedNodes)) {
+ menu.setEnabled(false);
+ }
+ return;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent evt) {
+ String cmd = evt.getActionCommand();
+ GraphObject obj = null;
+ List<GraphObject> gObjList = new ArrayList<GraphObject>();
+ CyAttributes attributes = null;
+ if (context instanceof NodeView) {
+ obj = ((NodeView)context).getNode();
+ attributes = Cytoscape.getNodeAttributes();
+ } else {
+ obj = ((EdgeView)context).getEdge();
+ attributes = Cytoscape.getEdgeAttributes();
+ }
+
+ if (cmd.equals("chemViz.menu.showmcss.thisNode") ||
cmd.equals("chemViz.menu.showmcss.thisEdge")) {
+ gObjList.add(obj);
+ } else if (cmd.equals("chemViz.menu.showmcss.selectedNodes")) {
+
gObjList.addAll(Cytoscape.getCurrentNetwork().getSelectedNodes());
+ } else if (cmd.equals("chemViz.menu.showmcss.selectedEdges")) {
+
gObjList.addAll(Cytoscape.getCurrentNetwork().getSelectedEdges());
+ }
+
+ CreateMCSSTask task = new CreateMCSSTask(gObjList, attributes,
settingsDialog, true);
+ TaskManager.executeTask(task, task.getDefaultTaskConfig());
+ }
+}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
2012-10-11 22:28:48 UTC (rev 30658)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -45,8 +45,9 @@
import cytoscape.CyNode;
import cytoscape.Cytoscape;
import cytoscape.data.CyAttributes;
-import cytoscape.task.Task;
+import cytoscape.task.util.TaskManager;
+import chemViz.commands.ValueUtils;
import chemViz.model.Compound;
import chemViz.model.Compound.AttriType;
import chemViz.ui.ChemInfoSettingsDialog;
@@ -72,13 +73,15 @@
CyAttributes attributes;
List<Compound> compoundList;
IMolecule mcss = null;
+ boolean showResult = false;
boolean calculationComplete = false;
/**
* Creates the task.
*
*/
- public CreateMCSSTask(List<GraphObject> gObjList, CyAttributes attributes,
ChemInfoSettingsDialog dialog) {
+ public CreateMCSSTask(List<GraphObject> gObjList, CyAttributes attributes,
+ ChemInfoSettingsDialog dialog, boolean
showResult) {
this.objectList = gObjList;
if (gObjList.get(0) instanceof CyNode)
@@ -88,6 +91,7 @@
this.dialog = dialog;
this.canceled = false;
this.attributes = attributes;
+ this.showResult = showResult;
}
public String getTitle() {
@@ -120,6 +124,13 @@
}
} catch (CDKException e) {}
calculationComplete = true;
+ if (showResult) {
+ String mcssSmiles = getMCSSSmiles();
+ String label = "MCSS = "+mcssSmiles;
+ List<Compound> mcssList = ValueUtils.getCompounds(null,
mcssSmiles, AttriType.smiles, null, null);
+ CreatePopupTask loader = new CreatePopupTask(mcssList,
null, dialog, label, 1);
+ TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
+ }
}
private IMolecule maximumStructure(List<IAtomContainer> mcsslist) {
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2012-10-11 22:28:48 UTC (rev 30658)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2012-10-12 03:11:14 UTC (rev 30659)
@@ -161,8 +161,10 @@
} else {
String textLabel = labelAttribute;
if (attributes != null) {
- textLabel =
attributes.getAttribute(compound.getSource().getIdentifier(),labelAttribute).toString();
- if (textLabel == null)
+ Object lbl =
attributes.getAttribute(compound.getSource().getIdentifier(),labelAttribute);
+ if (lbl != null)
+ textLabel = lbl.toString();
+ else
textLabel =
compound.getSource().getIdentifier();
}
label = new JLabel(textLabel.toString(), new
ImageIcon(img), JLabel.CENTER);
--
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.