Author: scooter
Date: 2012-12-18 13:26:07 -0800 (Tue, 18 Dec 2012)
New Revision: 31019

Modified:
   csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java
   
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
Log:
Fix bugs in tanimoto scoring


Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java        
2012-12-18 19:41:17 UTC (rev 31018)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/model/Compound.java        
2012-12-18 21:26:07 UTC (rev 31019)
@@ -491,6 +491,7 @@
                                }
                        } catch (Exception e) {
                                logger.warning("Error calculating fingerprint: 
"+e);
+                               e.printStackTrace();
                        }
                }
                return fingerPrint;
@@ -967,10 +968,10 @@
                                return null;
                        }
 
-                       iMolecule = new Molecule(intostruct.getAtomContainer());
+                       IMolecule molecule = new 
Molecule(intostruct.getAtomContainer());
                        // Use the molecule to create a SMILES string
                        SmilesGenerator sg = new SmilesGenerator();
-                       return sg.createSMILES(iMolecule);
+                       return sg.createSMILES(molecule);
                } catch (Exception e) {
                        logger.warning("Structure generation failed: " + 
e.getMessage(), e);
                        return null;

Modified: 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java
===================================================================
--- 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java  
    2012-12-18 19:41:17 UTC (rev 31018)
+++ 
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/TanimotoScorerTask.java  
    2012-12-18 21:26:07 UTC (rev 31019)
@@ -114,19 +114,33 @@
                if (settingsDialog != null)
                        tcCutoff = settingsDialog.getTcCutoff();
 
+               int nThreads = Runtime.getRuntime().availableProcessors()-1;
+               int maxThreads = settingsDialog.getMaxThreads();
+               if (maxThreads > 0)
+                       nThreads = maxThreads;
+
                objectCount = 0;
                totalObjects = selection.size();
                List<CyEdge> edgeList = Collections.synchronizedList(new 
ArrayList<CyEdge>());
 
-               updateMonitor();
+               if (nThreads == 1)
+                       updateMonitor();
 
+               // To avoid concurrancy issues, we need to split this up into 
two parts.  First,
+               // create the structures for all of our compounds
+               List<Compound> compounds = getCompounds(selection, 
Cytoscape.getNodeAttributes(), 
+                                                                               
                                                                                
          settingsDialog.getCompoundAttributes("node",AttriType.smiles),
+                                                                               
                                                                                
          settingsDialog.getCompoundAttributes("node",AttriType.inchi), 
maxThreads);
+
                List<CalculateTanimotoTask> taskList = new 
ArrayList<CalculateTanimotoTask>();
 
                for (int index1 = 0; index1 < totalObjects; index1++) {
                        CyNode node1 = (CyNode)selection.get(index1);
                        if (canceled) break;
-                       setStatus("Calculating tanimoto coefficients for 
"+node1.getIdentifier());
 
+                       if (nThreads == 1)
+                               setStatus("Calculating similarities for 
"+node1);
+
                        for (int index2 = 0; index2 < index1; index2++) {
                                if (canceled) break;
                                CyNode node2 = (CyNode)selection.get(index2);
@@ -134,14 +148,15 @@
                                if (node2 == node1)
                                        continue;
 
-                               taskList.add(new 
CalculateTanimotoTask(origNetwork, node1, node2, tcCutoff));
+                               CalculateTanimotoTask task = new 
CalculateTanimotoTask(origNetwork, node1, node2, tcCutoff);
+                               if (nThreads == 1) {
+                                       task.call();
+                               } else {
+                                       taskList.add(task);
+                               }
                        }
                }
 
-               int nThreads = Runtime.getRuntime().availableProcessors()-1;
-               int maxThreads = settingsDialog.getMaxThreads();
-               if (maxThreads > 0)
-                       nThreads = maxThreads;
 
                ExecutorService threadPool = 
Executors.newFixedThreadPool(nThreads);
 

-- 
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.

Reply via email to