Author: scooter
Date: 2013-02-19 15:59:01 -0800 (Tue, 19 Feb 2013)
New Revision: 31129

Modified:
   
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
   csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
   csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/SMARTSSearchTask.java
Log:
Add search structures command.  Looks like there's a threading problem with
the smiles parser...


Modified: 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
        2013-02-19 18:58:21 UTC (rev 31128)
+++ 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
        2013-02-19 23:59:01 UTC (rev 31129)
@@ -71,6 +71,7 @@
 import chemViz.tasks.CreateCompoundTableTask;
 import chemViz.tasks.CreateMCSSTask;
 import chemViz.tasks.CreateNodeGraphicsTask;
+import chemViz.tasks.SMARTSSearchTask;
 import chemViz.ui.ChemInfoSettingsDialog;
 
 enum Command {
@@ -98,6 +99,9 @@
        REMOVE("remove",
               "Remove 2D structures from nodes",
                                 "network|nodelist|node"),
+       SEARCHSTRUCTURES("search structures",
+                      "Search the designated structures using SMARTS",
+                      
"node|nodelist|edge|edgelist|smarts|smiles|inchi|columnlist"),
        SHOWSTRUCTURES("show structures",
                       "Popup the 2D structures for a node/edge or group of 
nodes/edges",
                       
"node|nodelist|edge|edgelist|labelattribute|smiles|inchi"),
@@ -145,6 +149,7 @@
        static final String NODELIST = "nodelist";
        static final String SELECTED = "selected";
        static final String SHOWRESULT = "showresult";
+       static final String SMARTS = "smarts";
        static final String SMILES = "smiles";
        static final String SMILESATTRIBUTE = "smilesattribute";
 
@@ -347,7 +352,7 @@
                        }
 
                        CreateMCSSTask mcssTask = new CreateMCSSTask(gObjList, 
attributes, dialog, false, createGroup);
-                       TaskManager.executeTask(mcssTask, 
mcssTask.getDefaultTaskConfig());
+                       TaskManager.executeTask(mcssTask, null);
 
                        try {
                                while(!mcssTask.isDone()) {
@@ -390,6 +395,34 @@
                        TaskManager.executeTask(cngTask, 
cngTask.getDefaultTaskConfig());
                        for (GraphObject obj: gObjList)
                                result.addMessage("Removed graphics from node 
'"+obj+"'");
+
+               // SEARCHSTRUCTURES("search structures",
+               //                "Search the designated structures using 
SMARTS",
+               //                
"node|nodelist|edge|edgelist|smarts|smiles|inchi|columnlist"),
+               } else if (Command.SEARCHSTRUCTURES.equals(command)) {
+                       if (gObjList == null) 
+                               throw new RuntimeException("chemviz 
"+command+": must specify node/edge or nodelist/edgelist");
+
+                       if (!args.containsKey(SMARTS))
+                               throw new RuntimeException("chemviz 
"+command+": must specify SMARTS string");
+
+                       String smarts = (String)args.get(SMARTS);
+
+                       List<Compound> compoundList = 
ValueUtils.getCompounds(gObjList, mstring, mtype, smilesAttrList, 
inchiAttrList);
+                       CyAttributes attributes = Cytoscape.getNodeAttributes();
+                       if (gObjList != null && (gObjList.get(0) instanceof 
CyEdge))
+                               attributes = Cytoscape.getEdgeAttributes();
+
+                       List<String> columnList = null;
+                       if (args.containsKey(COLUMNLIST)) {
+                               String[] columnSpecs = 
((String)args.get(COLUMNLIST)).split(",");
+                               columnList = Arrays.asList(columnSpecs);
+                       }
+
+                       SMARTSSearchTask searchTask = 
+                               new SMARTSSearchTask(smarts, gObjList, 
attributes, dialog, 0, columnList);
+                       TaskManager.executeTask(searchTask, 
searchTask.getDefaultTaskConfig());
+                       result.addMessage("Showing structures matching: 
"+smarts);
                
                //      SHOWSTRUCTURES("show structures",
                //                     "Popup the 2D structures for a node or 
group of nodes",

Modified: 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java  
2013-02-19 18:58:21 UTC (rev 31128)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java  
2013-02-19 23:59:01 UTC (rev 31129)
@@ -167,7 +167,8 @@
 
                List<IAtomContainer> mcssList = 
Collections.synchronizedList(new 
ArrayList<IAtomContainer>(compoundList.size()));
                for (Compound c: compoundList) {
-                       mcssList.add(c.getIAtomContainer());
+                       if (c.getIAtomContainer() != null)
+                               mcssList.add(c.getIAtomContainer());
                }
 
                int pass = 0;

Modified: 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/SMARTSSearchTask.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/SMARTSSearchTask.java    
    2013-02-19 18:58:21 UTC (rev 31128)
+++ 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/SMARTSSearchTask.java    
    2013-02-19 23:59:01 UTC (rev 31129)
@@ -118,6 +118,7 @@
                        try {
                                SMARTSQueryTool queryTool = new 
SMARTSQueryTool(searchString);
                                for (Compound compound: cList) {
+                                       if (compound.getIAtomContainer() == 
null) continue;
                                        boolean status = 
queryTool.matches(compound.getIAtomContainer());
                                        if (status && queryTool.countMatches() 
> 0)
                                                matches.add(compound);

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cytoscape-cvs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to