Commits

Aleš Erjavec committed 6109759

Added 'Clear cache' button, small fixes to progress reporting.

  • Participants
  • Parent commits efd5ac5

Comments (0)

Files changed (1)

File widgets/OWKEGGPathwayBrowser.py

                                 callback=self.OrganismSelectionCallback, 
                                 addSpace=True,
                                 debuggingEnabled=0)
-#        OWGUI.button(box, self, "Update Pathways", callback=self.UpdateToLatestPathways)
-        
-#        cb.setMaximumWidth(200)
         
         self.signalManager.freeze(self).push()
         
                        box="Image",
                        callback=self.UpdatePathwayViewTransform)
         
+        box = OWGUI.widgetBox(self.controlArea, "Cache Control")
+        
+        OWGUI.button(box, self, "Clear cache", 
+                     callback=self.ClearCache,
+                     tooltip="Clear all locally cached KEGG data.")
+        
         OWGUI.separator(self.controlArea)
 
         box = OWGUI.widgetBox(self.controlArea, "Selection")
         allRefPathways = obiKEGG.pathways("map")
 #        self.progressBarFinished()
         items = []
+        self.progressBarInit()
         kegg_pathways = obiKEGG.KEGGPathways()
-        kegg_pathways.pre_cache(self.pathways.keys())
-        
+        kegg_pathways.pre_cache(self.pathways.keys(),
+                                progress_callback=self.progressBarSet)
+        self.progressBarFinished()
         if self.showOrthology:
             self.koOrthology = obiKEGG.KEGGBrite("ko00001")
             self.listView.setRootIsDecorated(True)
             orngServerFiles.update(obiGeneSets.sfdomain, "index.pck")
             kegg_gs_collections = list(obiGeneSets.collections((("KEGG", "pathways"), taxid)))
         
-#        print self.genes
-#        print taxid
-#        print kegg_gs_collections
         if USE_THREADING:
             result = {}
             def callable(*args, **kwargs):
                                                 reference),
                                           kwargs={"callback": 
                                                   threading_queued_invoke(self,
-                                                  lambda value:pb.advance())}
+                                                  lambda value:self.progressBarSet(value))}
                                           )
                 
                 thread.start()
                 self.pathways = result["result"]
             else:
                 raise Exception('Could not get enriched pathways')
+            
+            
         else:
             self.pathways = org.get_enriched_pathways(self.genes, reference,
-                                                      callback=lambda value: pb.advance())
+                                                      callback=lambda value: self.progressBarSet(value))
         
         self.org = org
         if not self.pathways:
             self.send("Selected Examples", None)
             self.send("Unselected Examples", None)
         
+    def ClearCache(self):
+        from obiKEGG2 import caching
+        try:
+            caching.clear_cache()
+        except Exception, ex:
+            QMessageBox.warning(self, "Cache clear", 
+                ex.args[0])
+            
+        
     def keyPressEvent(self, key):
         if key.key()==Qt.Key_Control:
             self.ctrlPressed=True
 
     @pyqtSignature("queuedInvoke(PyQt_PyObject)")
     def queuedInvoke(self, func):
-#        print "queued invoke of", func
         func()
         
     def progressBarSet(self, value):