Author: scooter
Date: 2012-10-09 15:10:58 -0700 (Tue, 09 Oct 2012)
New Revision: 30641
Added:
csplugins/trunk/ucsf/scooter/chemViz/lib/cdk-1.4.14.jar
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/StructureMenus.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Fingerprinter.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateCompoundsTask.java
Removed:
csplugins/trunk/ucsf/scooter/chemViz/lib/cdk-1.4.0.jar
Modified:
csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
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/model/Compound.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/AbstractCompoundTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
Log:
Move to CDK 1.4.14 and add ability to use alternative fingerprinters
Deleted: csplugins/trunk/ucsf/scooter/chemViz/lib/cdk-1.4.0.jar
===================================================================
(Binary files differ)
Added: csplugins/trunk/ucsf/scooter/chemViz/lib/cdk-1.4.14.jar
===================================================================
(Binary files differ)
Property changes on: csplugins/trunk/ucsf/scooter/chemViz/lib/cdk-1.4.14.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
Modified: csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props 2012-10-09
20:38:04 UTC (rev 30640)
+++ csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props 2012-10-09
22:10:58 UTC (rev 30641)
@@ -13,10 +13,10 @@
pluginDescription=This plugin provides cheminformatics tools to cytoscape
# Plugin version number, this must be two numbers separated by a decimlal.
Ex. 0.2, 14.03
-pluginVersion=1.2
+pluginVersion=1.3
# Compatible Cytoscape version
-cytoscapeVersion=2.7,2.8
+cytoscapeVersion=2.8
# Category, use one of the categories listed on the website or create your own
pluginCategory=Analysis
@@ -31,4 +31,4 @@
pluginAuthorsIntsitutions=John "Scooter" Morris:UCSF;Dazhi Jiao:Indiana
University School of Informatics
# Date this plugin/plugin version was released
-releaseDate=December 1th, 2010
+releaseDate=December 1th, 2012
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
2012-10-09 20:38:04 UTC (rev 30640)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/chemViz.props
2012-10-09 22:10:58 UTC (rev 30641)
@@ -43,6 +43,18 @@
chemViz.menu.createattributes.allNodes=for all nodes
chemViz.menu.createattributes.selectedNodes=for selected nodes
chemViz.menu.settings=Settings...
+chemViz.menu.clearstructures=Clear compounds
+chemViz.menu.clearstructures.thisEdge=for this edge
+chemViz.menu.clearstructures.selectedEdges=for selected edges
+chemViz.menu.clearstructures.thisNode=for this node
+chemViz.menu.clearstructures.all=for all nodes and edges
+chemViz.menu.clearstructures.selectedNodes=for selected nodes
+chemViz.menu.reloadstructures=Reload compounds
+chemViz.menu.reloadstructures.thisEdge=for this edge
+chemViz.menu.reloadstructures.selectedEdges=for selected edges
+chemViz.menu.reloadstructures.thisNode=for this node
+chemViz.menu.reloadstructures.all=for all nodes and edges
+chemViz.menu.reloadstructures.selectedNodes=for selected nodes
##
# 2D Structure Depictor Messages
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
2012-10-09 20:38:04 UTC (rev 30640)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizContextMenu.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -56,6 +56,7 @@
import chemViz.model.Compound;
import chemViz.model.Compound.AttriType;
+import chemViz.tasks.CreateCompoundsTask;
import chemViz.ui.ChemInfoSettingsDialog;
/**
@@ -118,11 +119,13 @@
if (context instanceof EdgeView) {
new DepictionMenus(m, systemProperties, settingsDialog,
(EdgeView) context);
new AttributesMenu(m, systemProperties, settingsDialog,
(EdgeView) context);
+ new StructureMenus(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);
updateLinkOut(((NodeView)context).getNode());
}
new SimilarityMenu(m, systemProperties, settingsDialog);
@@ -148,10 +151,12 @@
type = "edge";
}
- // Only get the loaded compounds so our popup menus don't get
really slow
- List<Compound> cList = Compound.getCompounds(go, attributes,
-
settingsDialog.getCompoundAttributes(type,AttriType.smiles),
-
settingsDialog.getCompoundAttributes(type,AttriType.inchi), true);
+ // This little bit of strangeness is to avoid duplicating bunch
of code to handle
+ // the creation of compounds that's already in
AbstractCompoundTask. Here, we
+ // create a task, but just execute the run method directly
(synchronously)...
+ CreateCompoundsTask t = new CreateCompoundsTask(go, attributes,
settingsDialog);
+ t.run();
+ List<Compound> cList = t.getCompoundList();
Properties cytoProps = CytoscapeInit.getProperties();
if (cList == null || cList.size() == 0) {
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
2012-10-09 20:38:04 UTC (rev 30640)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/ChemVizMenu.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -97,6 +97,7 @@
new NodeGraphicsMenus(m, systemProps, settingsDialog, null);
new SimilarityMenu(m, systemProps, settingsDialog);
new AttributesMenu(m, systemProps, settingsDialog, null);
+ new StructureMenus(m, systemProps, settingsDialog, null);
new SettingsMenu(m, systemProps, settingsDialog);
}
Added:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/StructureMenus.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/StructureMenus.java
(rev 0)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/StructureMenus.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -0,0 +1,224 @@
+/*
+ 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.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.task.Task;
+import cytoscape.task.util.TaskManager;
+
+import chemViz.model.Compound;
+import chemViz.ui.ChemInfoSettingsDialog;
+import chemViz.tasks.CreateCompoundTableTask;
+import chemViz.tasks.CreatePopupTask;
+
+
+/**
+ * This plugin adds cheminformatics tools to Cytoscape.
+ */
+public class StructureMenus 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 StructureMenus(JMenu menu, Properties systemProps,
+ ChemInfoSettingsDialog settingsDialog, Object context) {
+ super(systemProps, settingsDialog);
+
+ this.context = context;
+ JMenu clear = new
JMenu(systemProps.getProperty("chemViz.menu.clearstructures"));
+ if (context == null) {
+ addEdgeStructureMenus(clear,
"chemViz.menu.clearstructures", null);
+ addNodeStructureMenus(clear,
"chemViz.menu.clearstructures", null);
+ } else if (context instanceof NodeView) {
+ addNodeStructureMenus(clear,
"chemViz.menu.clearstructures", (NodeView)context);
+ } else {
+ addEdgeStructureMenus(clear,
"chemViz.menu.clearstructures", (EdgeView)context);
+ }
+ menu.add(clear);
+
+ JMenu reload = new
JMenu(systemProps.getProperty("chemViz.menu.reloadstructures"));
+ if (context == null) {
+ addEdgeStructureMenus(reload,
"chemViz.menu.reloadstructures", null);
+ addNodeStructureMenus(reload,
"chemViz.menu.reloadstructures", null);
+ } else if (context instanceof NodeView) {
+ addNodeStructureMenus(reload,
"chemViz.menu.reloadstructures", (NodeView)context);
+ } else {
+ addEdgeStructureMenus(reload,
"chemViz.menu.reloadstructures", (EdgeView)context);
+ }
+ menu.add(reload);
+ }
+
+ /**
+ * 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 addEdgeStructureMenus(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 addNodeStructureMenus(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;
+ if (context instanceof NodeView)
+ obj = ((NodeView)context).getNode();
+ else
+ obj = ((EdgeView)context).getEdge();
+
+ if (cmd.equals("chemViz.menu.clearstructures.thisNode")) {
+ Compound.clearStructures(obj);
+ } else if
(cmd.equals("chemViz.menu.clearstructures.selectedNodes")) {
+ Set<CyNode> nodes =
(Set<CyNode>)Cytoscape.getCurrentNetwork().getSelectedNodes();
+ for (CyNode node: nodes) Compound.clearStructures(node);
+ } else if (cmd.equals("chemViz.menu.clearstructures.all")) {
+ Compound.clearStructures(null);
+ } else if (cmd.equals("chemViz.menu.clearstructures.thisEdge"))
{
+ Compound.clearStructures(obj);
+ } else if
(cmd.equals("chemViz.menu.clearstructures.selectedEdges")) {
+ Set<CyEdge> edges =
(Set<CyEdge>)Cytoscape.getCurrentNetwork().getSelectedEdges();
+ for (CyEdge edge: edges) Compound.clearStructures(edge);
+ } else if
(cmd.equals("chemViz.menu.reloadstructures.thisNode")) {
+ Compound.reloadStructures(obj);
+ } else if
(cmd.equals("chemViz.menu.reloadstructures.selectedNodes")) {
+ Set<CyNode> nodes =
(Set<CyNode>)Cytoscape.getCurrentNetwork().getSelectedNodes();
+ for (CyNode node: nodes)
Compound.reloadStructures(node);
+ } else if (cmd.equals("chemViz.menu.reloadstructures.all")) {
+ Compound.reloadStructures(null);
+ } else if
(cmd.equals("chemViz.menu.reloadstructures.thisEdge")) {
+ Compound.reloadStructures(obj);
+ } else if
(cmd.equals("chemViz.menu.reloadstructures.selectedEdges")) {
+ Set<CyEdge> edges =
(Set<CyEdge>)Cytoscape.getCurrentNetwork().getSelectedEdges();
+ for (CyEdge edge: edges)
Compound.reloadStructures(edge);
+ }
+ }
+}
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java
2012-10-09 20:38:04 UTC (rev 30640)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -78,7 +78,7 @@
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
-import org.openscience.cdk.fingerprint.Fingerprinter;
+import org.openscience.cdk.fingerprint.IFingerprinter;
import org.openscience.cdk.geometry.GeometryTools;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.inchi.InChIGenerator;
@@ -167,6 +167,7 @@
// Class variables
static private HashMap<GraphObject, List<Compound>> compoundMap;
static private CyLogger logger = CyLogger.getLogger(Compound.class);
+ static private Fingerprinter fingerprinter = Fingerprinter.CDK;
static private DescriptorType[] descriptorTypes = {
DescriptorType.IMAGE, DescriptorType.ATTRIBUTE,
DescriptorType.IDENTIFIER, DescriptorType.WEIGHT,
DescriptorType.MASS,
@@ -179,72 +180,15 @@
DescriptorType.WEINERPATH,DescriptorType.WEINERPOL
};
-
/*********************************************************************************************************************
- * Class (static)
methods *
-
********************************************************************************************************************/
-
- /**
- * Returns all of the Compounds for a list of graph objects (Nodes or
Edges) based on the SMILES
- * and InChI attributes.
- *
- * @param goSet the Collection of graph objects we're looking at
- * @param attributes the appropriate set of attributes (nodeAttributes
or edgeAttributes)
- * @param sList the list of attributes that contain SMILES strings
- * @param iList the list of attributes that contain InChI strings
- * @return the list of compounds. If the compounds have not already
been created, they are created
- * as a byproduct of this method.
- */
- static public List<Compound> getCompounds(Collection<GraphObject>
goSet, CyAttributes attributes,
- List<String> sList,
List<String> iList) {
- List<Compound> cList = new ArrayList();
- for (GraphObject go: goSet)
- cList.addAll(getCompounds(go, attributes, sList, iList,
false));
-
- return cList;
- }
-
- /**
- * Returns all of the Compounds for a single graph object (Node or
Edge) based on the SMILES
- * and InChI attributes.
- *
- * @param go the graph object we're looking at
- * @param attributes the appropriate set of attributes (nodeAttributes
or edgeAttributes)
- * @param sList the list of attributes that contain SMILES strings
- * @param iList the list of attributes that contain InChI strings
- * @param noStructures if 'true', the structures are fetched in the
background
- * @return the list of compounds. If the compounds have not already
been created, they are created
- * as a byproduct of this method.
- */
- static public List<Compound> getCompounds(GraphObject go, CyAttributes
attributes,
- List<String> sList,
List<String> iList,
- boolean noStructures) {
- if ((sList == null || sList.size() == 0)
- && (iList == null || iList.size() == 0))
- return null;
-
- List<Compound> cList = new ArrayList();
-
- // Get the compound list from each attribute
- for (String attr: sList) {
- cList.addAll(getCompounds(go, attributes, attr,
AttriType.smiles, noStructures));
- }
-
- for (String attr: iList) {
- cList.addAll(getCompounds(go, attributes, attr,
AttriType.inchi, noStructures));
- }
-
- return cList;
- }
-
- /**
- * Returns the compound that matches the passed arguments or null if no
such compound exists.
- *
- * @param go the graph object we're looking at
- * @param attr the attribute that contains the compound descriptor
- * @param molString the compound descriptor
- * @param type the type of the attribute (smiles or inchi)
- * @return the compound that matched or 'null' if no such compound
exists.
- */
+ /**
+ * Returns the compound that matches the passed arguments or null if no
such compound exists.
+ *
+ * @param go the graph object we're looking at
+ * @param attr the attribute that contains the compound descriptor
+ * @param molString the compound descriptor
+ * @param type the type of the attribute (smiles or inchi)
+ * @return the compound that matched or 'null' if no such compound
exists.
+ */
static public Compound getCompound(GraphObject go, String attr, String
molString, AttriType type) {
if (compoundMap == null) return null;
@@ -260,119 +204,41 @@
}
/**
- * Returns the list of attributes that might contain compound
descriptors and are
- * used by any of the passed graph objects.
+ * Static method to set the fingerprinter to use.
*
- * @param goList the list of graph objects we're looking at
- * @param attributes the appropriate set of attributes (nodeAttributes
or edgeAttributes)
- * @param attrList the entire list of compound attributes
- * @return the list of attributes that are in the attrList and used by
objects in the goList
+ * @param fp the Fingerprinter we want to use
*/
- static public List<String> findAttributes(Collection<GraphObject>
goList, CyAttributes attributes,
- List<String> attrList) {
-
- // Now get the names of all of the object attributes
- String[] attrNames = attributes.getAttributeNames();
-
- // Now see if any of the attributes are in our list
- ArrayList<String>attrsFound = new ArrayList();
- for (int i = 0; i < attrNames.length; i++) {
- if (attrList.contains(attrNames[i])) {
- attrsFound.add(attrNames[i]);
- }
- }
-
- if (attrsFound.size() == 0)
- return null;
-
- if (goList == null)
- return attrsFound;
-
- // We we know all of the attributes we're interested in -- see
if these objects have any of them
- ArrayList<String>hasAttrs = new ArrayList();
- for (GraphObject go: goList) {
- for (String attribute: attrsFound) {
- if
(attributes.hasAttribute(go.getIdentifier(),attribute)) {
- hasAttrs.add(attribute);
- }
- }
- }
-
- if (hasAttrs.size() > 0)
- return hasAttrs;
-
- return null;
+ static public void setFingerprinter(Fingerprinter fp) {
+ fingerprinter = fp;
}
static public List<DescriptorType> getDescriptorList() {
return Arrays.asList(descriptorTypes);
}
- /**
- * Returns all of the Compounds for a single graph object (Node or
Edge) based on the designated
- * attribute of the specific type
- *
- * @param go the graph object we're looking at
- * @param attributes the appropriate set of attributes (nodeAttributes
or edgeAttributes)
- * @param attr the attribute that contains the compound descriptor
- * @param type the type of the attribute (smiles or inchi)
- * @param noStructures if 'true', the structures are fetched in the
background
- * @return the list of compounds. If the compounds have not already
been created, they are created
- * as a byproduct of this method.
- */
- static private List<Compound> getCompounds(GraphObject go, CyAttributes
attributes,
- String attr, AttriType type,
- boolean noStructures) {
- byte atype = attributes.getType(attr);
- List<Compound> cList = new ArrayList();
-
- if (!attributes.hasAttribute(go.getIdentifier(), attr))
- return cList;
- if (atype == CyAttributes.TYPE_STRING) {
- String cstring =
attributes.getStringAttribute(go.getIdentifier(), attr);
- cList.addAll(getCompounds(go, attr, cstring, type,
noStructures));
- } else if (atype == CyAttributes.TYPE_SIMPLE_LIST) {
- List<String> stringList =
attributes.getListAttribute(go.getIdentifier(), attr);
- for (String cstring: stringList)
- cList.addAll(getCompounds(go, attr, cstring,
type, noStructures));
+ static public void clearStructures(GraphObject object) {
+ if (object == null) {
+ compoundMap = null;
+ } else {
+ if (compoundMap.containsKey(object)) {
+ compoundMap.remove(object);
+ }
}
- return cList;
}
- /**
- * Returns all of the Compounds for a single graph object (Node or
Edge) based on the designated
- * attribute of the specific type
- *
- * @param go the graph object we're looking at
- * @param attr the attribute that contains the compound descriptor
- * @param compundString the compound descriptor
- * @param type the type of the attribute (smiles or inchi)
- * @param noStructures if 'true', the structures are fetched in the
background
- * @return the list of compounds. If the compounds have not already
been created, they are created
- * as a byproduct of this method.
- */
- static private List<Compound> getCompounds(GraphObject go, String attr,
- String compoundString,
AttriType type,
- boolean noStructures) {
- List<Compound> cList = new ArrayList();
-
- String[] cstrings = null;
-
- if (type == AttriType.smiles) {
- cstrings = compoundString.split(",");
- } else {
- cstrings = new String[1];
- cstrings[0] = compoundString;
+ static public void reloadStructures(GraphObject object) {
+ if (object == null) {
+ for (List<Compound> cList: compoundMap.values()) {
+ for (Compound c: cList) {
+ c.createStructure();
+ }
+ }
+ } else if (compoundMap.containsKey(object)) {
+ List<Compound> cList = compoundMap.get(object);
+ for (Compound c: cList) {
+ c.createStructure();
+ }
}
-
- for (int i = 0; i < cstrings.length; i++) {
- Compound c = getCompound(go, attr, cstrings[i], type);
- if (c == null)
- c = new Compound(go, attr, cstrings[i], type,
noStructures);
-
- cList.add(c);
- }
- return cList;
}
/*********************************************************************************************************************
@@ -390,6 +256,7 @@
private IMolecule iMolecule;
private IMolecule iMolecule3D;
private BitSet fingerPrint;
+ private IFingerprinter fp;
private int lastImageWidth = -1;
private int lastImageHeight = -1;
private boolean lastImageFailed = false;
@@ -411,12 +278,6 @@
this.attribute = attribute;
this.moleculeString = mstring.trim();
this.attrType = attrType;
- this.renderedImage = null;
- this.laidOut = false;
- this.iMolecule = null;
- this.iMolecule3D = null;
- this.fingerPrint = null;
- this.smilesStr = null;
List<Compound> mapList = null;
if (Compound.compoundMap == null)
@@ -429,14 +290,25 @@
}
mapList.add(this);
Compound.compoundMap.put(source, mapList);
+ createStructure();
+ }
+ public void createStructure() {
+ this.renderedImage = null;
+ this.laidOut = false;
+ this.iMolecule = null;
+ this.iMolecule3D = null;
+ this.smilesStr = null;
+ this.fp = Compound.fingerprinter.getFingerprinter();
+ this.fingerPrint = null;
+
if (attrType == AttriType.inchi) {
// Convert to smiles
this.smilesStr = convertInchiToSmiles(moleculeString);
} else {
- if (mstring != null && mstring.length() > 0) {
+ if (moleculeString != null && moleculeString.length() >
0) {
// Strip any blanks in the string
- this.smilesStr = mstring.replaceAll(" ", "");
+ this.smilesStr = moleculeString.replaceAll(" ",
"");
}
}
@@ -446,8 +318,7 @@
logger.debug("smiles string = "+smilesStr);
// Create the CDK Molecule object
- SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder
- .getInstance());
+ SmilesParser sp = new
SmilesParser(DefaultChemObjectBuilder.getInstance());
try {
iMolecule = sp.parseSmiles(this.smilesStr);
} catch (InvalidSmilesException e) {
@@ -464,14 +335,11 @@
CDKHydrogenAdder adder =
CDKHydrogenAdder.getInstance(iMolecule.getBuilder());
adder.addImplicitHydrogens(iMolecule);
- // Get our fingerprint
- Fingerprinter fp = new Fingerprinter();
// Do we need to do the addh here?
fingerPrint = fp.getFingerprint(addh(iMolecule));
} catch (CDKException e1) {
fingerPrint = null;
}
-
}
/**
Added: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Fingerprinter.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Fingerprinter.java
(rev 0)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Fingerprinter.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2012 University of California, San Francisco
+
+ 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.model;
+
+import org.openscience.cdk.fingerprint.EStateFingerprinter;
+import org.openscience.cdk.fingerprint.ExtendedFingerprinter;
+import org.openscience.cdk.fingerprint.GraphOnlyFingerprinter;
+import org.openscience.cdk.fingerprint.HybridizationFingerprinter;
+import org.openscience.cdk.fingerprint.IFingerprinter;
+import org.openscience.cdk.fingerprint.KlekotaRothFingerprinter;
+import org.openscience.cdk.fingerprint.MACCSFingerprinter;
+import org.openscience.cdk.fingerprint.PubchemFingerprinter;
+import org.openscience.cdk.fingerprint.SubstructureFingerprinter;
+
+public enum Fingerprinter {
+ CDK("CDK", new org.openscience.cdk.fingerprint.Fingerprinter()),
+ ESTATE("E-State", new EStateFingerprinter()),
+ EXTENDED("Extended CDK", new ExtendedFingerprinter()),
+ GRAPHONLY("Graph Only", new GraphOnlyFingerprinter()),
+ HYBRIDIZATION("Hybridization", new HybridizationFingerprinter()),
+ KLEKOTAROTH("Klekota & Roth", new KlekotaRothFingerprinter()),
+ MACCS("MACCS", new MACCSFingerprinter()),
+ PUBCHEM("Pubchem", new PubchemFingerprinter()),
+ SUBSTRUCTURE("Substructure bitset", new SubstructureFingerprinter());
+
+ private String name;
+ private IFingerprinter fingerprinter;
+ private Fingerprinter(String str, IFingerprinter fp) { name=str;
fingerprinter = fp;}
+ public String toString() { return name; }
+ public String getName() { return name; }
+ public IFingerprinter getFingerprinter() { return fingerprinter; }
+}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/AbstractCompoundTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/AbstractCompoundTask.java
2012-10-09 20:38:04 UTC (rev 30640)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/AbstractCompoundTask.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -187,18 +187,6 @@
return cList;
}
- /**
- * Returns all of the Compounds for a single graph object (Node or
Edge) based on the designated
- * attribute of the specific type
- *
- * @param go the graph object we're looking at
- * @param attr the attribute that contains the compound descriptor
- * @param compundString the compound descriptor
- * @param type the type of the attribute (smiles or inchi)
- * @param noStructures if 'true', the structures are fetched in the
background
- * @return the list of compounds. If the compounds have not already
been created, they are created
- * as a byproduct of this method.
- */
protected List<Compound> getCompounds(GraphObject go, String attr,
String compoundString, AttriType
type,
boolean noStructures) {
@@ -234,6 +222,10 @@
objectCount++;
}
+ protected void setStatus(String status) {
+ if (monitor != null) monitor.setStatus(status);
+ }
+
private boolean done() {
if (canceled) return true;
if ((maxCompounds != 0) && (compoundCount >= maxCompounds))
return true;
Added:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateCompoundsTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateCompoundsTask.java
(rev 0)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateCompoundsTask.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -0,0 +1,98 @@
+/*
+ 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.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import giny.model.GraphObject;
+import giny.view.EdgeView;
+import giny.view.NodeView;
+
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.task.Task;
+
+import chemViz.model.Compound;
+import chemViz.model.Compound.AttriType;
+import chemViz.ui.ChemInfoSettingsDialog;
+import chemViz.ui.CompoundPopup;
+
+
+/**
+ * The CreateCompoundsTask fetches all of the compounds defined by the
+ * object passed in its constructor and provides some methods to allow
+ * the caller to fetch the compounds when the task is complete.
+ */
+public class CreateCompoundsTask extends AbstractCompoundTask {
+ List<GraphObject> objectList;
+ ChemInfoSettingsDialog dialog;
+ String type;
+ CyAttributes attributes;
+ List<Compound> compoundList;
+
+ /**
+ * Creates the task.
+ *
+ */
+ public CreateCompoundsTask(GraphObject object, CyAttributes attributes,
ChemInfoSettingsDialog dialog) {
+ this.objectList = new ArrayList();
+ objectList.add(object);
+ if (object instanceof CyNode)
+ type = "node";
+ else
+ type = "edge";
+ this.dialog = dialog;
+ this.canceled = false;
+ this.attributes = attributes;
+ }
+
+ public String getTitle() {
+ return "Creating Compounds";
+ }
+
+ /**
+ * Runs the task -- this will get all of the compounds, fetching the
images (if necessary) and creates the popup.
+ */
+ public void run() {
+ compoundList = getCompounds(objectList, attributes,
+
dialog.getCompoundAttributes(type,AttriType.smiles),
+
dialog.getCompoundAttributes(type,AttriType.inchi));
+ }
+
+ public List<Compound>getCompoundList() { return compoundList; }
+}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
2012-10-09 20:38:04 UTC (rev 30640)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -66,7 +66,7 @@
* between each of them, storing the results in attributes or by creating edges
* in a new network.
*/
-public class TanimotoScorerTask implements Task {
+public class TanimotoScorerTask extends AbstractCompoundTask {
List<GraphObject> selection;
ChemInfoSettingsDialog settingsDialog;
TaskMonitor monitor;
@@ -86,14 +86,6 @@
this.createNewNetwork = newNetwork;
}
- public void halt() {
- canceled = true;
- };
-
- public void setTaskMonitor(TaskMonitor monitor) {
- this.monitor = monitor;
- }
-
public String getTitle() {
return "Creating Scores Table";
}
@@ -114,8 +106,11 @@
if (settingsDialog != null)
tcCutoff = settingsDialog.getTcCutoff();
- setPercentComplete(0);
+ objectCount = 0;
+ totalObjects = selection.size();
+ updateMonitor();
+
if (createNewNetwork) {
// Create a new network if we're supposed to
newNet = Cytoscape.createNetwork(selection, new
ArrayList(), origNetwork.getTitle()+" copy",
@@ -124,16 +119,14 @@
vs =
Cytoscape.getVisualMappingManager().getVisualStyle();
}
- double count = 0;
- int selectionCount = selection.size();
- for (int index1 = 0; index1 < selectionCount; index1++) {
+ for (int index1 = 0; index1 < totalObjects; index1++) {
CyNode node1 = (CyNode)selection.get(index1);
if (canceled) break;
setStatus("Calculating tanimoto coefficients for
"+node1.getIdentifier());
// System.out.println("Calculating tanimoto
coefficients for "+node1.getIdentifier());
- List<Compound> cList1 = Compound.getCompounds(node1,
attributes,
-
settingsDialog.getCompoundAttributes("node",AttriType.smiles),
-
settingsDialog.getCompoundAttributes("node",AttriType.inchi), true);
+ List<Compound> cList1 = getCompounds(node1, attributes,
+
settingsDialog.getCompoundAttributes("node",AttriType.smiles),
+
settingsDialog.getCompoundAttributes("node",AttriType.inchi), true);
if (cList1 == null || cList1.size() == 0)
continue;
@@ -144,9 +137,9 @@
if (node2 == node1 && cList1.size() <= 1)
continue;
- List<Compound> cList2 =
Compound.getCompounds(node2, attributes,
-
settingsDialog.getCompoundAttributes("node",AttriType.smiles),
-
settingsDialog.getCompoundAttributes("node",AttriType.inchi), true);
+ List<Compound> cList2 = getCompounds(node2,
attributes,
+
settingsDialog.getCompoundAttributes("node",AttriType.smiles),
+
settingsDialog.getCompoundAttributes("node",AttriType.inchi),
true);
if (cList2 == null || cList2.size() == 0)
continue;
@@ -203,8 +196,8 @@
newv.setXPosition(orig.getXPosition());
newv.setYPosition(orig.getYPosition());
}
- count++;
- setPercentComplete((count/selection.size())*100);
+ objectCount++;
+ updateMonitor();
}
if (createNewNetwork) {
@@ -214,27 +207,4 @@
}
}
-
- public JTaskConfig getDefaultTaskConfig() {
- JTaskConfig result = new JTaskConfig();
-
- result.displayCancelButton(true);
- result.displayCloseButton(false);
- result.displayStatus(true);
- result.displayTimeElapsed(false);
- result.setAutoDispose(true);
- result.setModal(false);
- result.setOwner(Cytoscape.getDesktop());
-
- return result;
- }
-
- private void setStatus(String status) {
- if (monitor != null) monitor.setStatus(status);
- }
-
- private void setPercentComplete(double pct) {
- if (monitor != null) monitor.setPercentCompleted((int)pct);
- }
-
}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
2012-10-09 20:38:04 UTC (rev 30640)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
2012-10-09 22:10:58 UTC (rev 30641)
@@ -35,8 +35,10 @@
package chemViz.ui;
+import chemViz.model.Compound;
import chemViz.model.Compound.AttriType;
import chemViz.model.ChemInfoProperties;
+import chemViz.model.Fingerprinter;
import cytoscape.Cytoscape;
import cytoscape.CyEdge;
@@ -97,6 +99,10 @@
DepictionPositions.BOTTOMCENTER, DepictionPositions.BOTTOMLEFT,
DepictionPositions.BOTTOMRIGHT,DepictionPositions.MIDDLERIGHT,
DepictionPositions.MIDDLELEFT};
+ private static final Fingerprinter fingerprintList[] =
{Fingerprinter.CDK, Fingerprinter.ESTATE, Fingerprinter.EXTENDED,
+
Fingerprinter.GRAPHONLY, Fingerprinter.HYBRIDIZATION,
+
Fingerprinter.KLEKOTAROTH, Fingerprinter.MACCS,
+
Fingerprinter.PUBCHEM, Fingerprinter.SUBSTRUCTURE};
private static List<String> smilesAttributes = null;
private static List<String> inCHIAttributes = null;
private static List<String> possibleAttributes = null;
@@ -106,6 +112,7 @@
private double tcCutoff = 0.25;
private boolean showHyd = false;
private int labelPositionIndex = 0;
+ private int fingerPrinterIndex = 0; // By default, CDK
private int nodeStructureSize = 100;
private String labelAttribute = "ID";
@@ -197,6 +204,15 @@
inCHIAttributes = getListFromTunable((Object
[])t.getLowerBound(), (String)t.getValue());
}
+ t = properties.get("fingerprints");
+ if ((t != null) && (t.valueChanged() || force)) {
+ int fpIndex = ((Integer)t.getValue()).intValue();
+ if (fpIndex != fingerPrinterIndex) {
+ fingerPrinterIndex = fpIndex;
+
Compound.setFingerprinter(fingerprintList[fingerPrinterIndex]);
+ }
+ }
+
t = properties.get("maxCompounds");
if ((t != null) && (t.valueChanged() || force)) {
maxCompounds = ((Integer) t.getValue()).intValue();
@@ -310,6 +326,10 @@
return positionList[labelPositionIndex].labelPosition();
}
+ public Fingerprinter getFingerprinter() {
+ return fingerprintList[fingerPrinterIndex];
+ }
+
public String getLabelAttribute() {
return labelAttribute;
}
@@ -351,7 +371,7 @@
}
private void initializeProperties() {
- Tunable t = new Tunable("group1","", Tunable.GROUP, new
Integer(2));
+ Tunable t = new Tunable("group1","", Tunable.GROUP, new
Integer(3));
properties.add(t);
properties.add(new Tunable("maxCompunds",
@@ -362,6 +382,10 @@
"Minimum tanimoto value to consider for edge
creation",
Tunable.DOUBLE, new Double(0.25)));
+ properties.add( new Tunable("fingerPrinter",
+ "Fingerprint algorithm to use",
+ Tunable.LIST, new Integer(fingerPrinterIndex),
+ (Object)fingerprintList, null, 0));
/*
t = new Tunable("showHyd",
"Show hydrogens explicitly"
@@ -396,7 +420,7 @@
Tunable.LIST, inCHIDefaults,
(Object)possibleAttributes.toArray(),
inCHIDefaults, Tunable.MULTISELECT));
- properties.add(new Tunable("presentationGroup2", "Depiction
options", Tunable.GROUP, new Integer(3)));
+ properties.add(new Tunable("presentationGroup3", "Depiction
options", Tunable.GROUP, new Integer(3)));
properties.add(new Tunable("nodeStructureSize",
"Size of 2D node depiction as a % of node size",
--
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.