Commits

Aleš Erjavec committed 29a979e

Optimized Gsea widget organism list initialization.

Comments (0)

Files changed (1)

_bioinformatics/widgets/OWGsea.py

 
     def UpdateOrganismComboBox(self):
         try:
-            self.progressBarInit()
-            with orngServerFiles.DownloadProgress.setredirect(self.progressBarSet):
-                genome = obiKEGG.KEGGGenome()
-            self.progressBarFinished()
-            
-            self.allOrganismCodes = genome 
-    
+            genome = obiKEGG.KEGGGenome()
+
+            self.allOrganismCodes = genome
+
             essential = genome.essential_organisms()
-            
-            local = [name.split(".")[0].split("_")[-1] for name in orngServerFiles.listfiles("KEGG") if "kegg_genes" in name]
-            self.organismCodes = [(code, organism.definition) for code, organism in self.allOrganismCodes.items() if code in local or code in essential]
-            self.organismCodes.sort()
-            items = [desc for code, desc in self.organismCodes]
-            self.organismCodes = [obiKEGG.to_taxid(code) for code, desc in self.organismCodes]
-            
+
+            local = [name.split(".")[0].split("_")[-1]
+                     for name in orngServerFiles.listfiles("KEGG")
+                     if "kegg_genes" in name]
+
+            entry_keys = map(genome.org_code_to_entry_key,
+                             essential + local)
+
+            entries = genome.batch_get(entry_keys)
+
+            items = [entry.definition for entry in entries]
+
+            self.organismTaxids = [entry.taxid for entry in entries]
+
+            self.organismComboBox.clear()
             self.organismComboBox.addItems(items)
         finally:
             if self.signalManager:
         box = OWGUI.widgetBox(ca, 'Organism')
         #FROM KEGG WIDGET - organism selection
         self.allOrganismCodes = {}
-        self.organismCodes = []
+        self.organismTaxids = []
         self.organismComboBox = cb = OWGUI.comboBox(box, self, "organismIndex", items=[], debuggingEnabled=0) #changed
         cb.setMaximumWidth(200)
 
 
         collectionNames = [ self.geneSel[a] for a in self.gridSel ]
 
-        organism = self.organismCodes[self.organismIndex]
+        organism = self.organismTaxids[self.organismIndex]
 
         if self.gsgo:
             collectionNames.append((("GO",),organism))
         if data:
             taxid = data_hints.get_hint(data, "taxid", None)
             try:
-                code = obiKEGG.from_taxid(taxid)
-                self.organismIndex = self.organismCodes.index(code)
+                self.organismIndex = self.organismTaxids.index(taxid)
             except Exception, ex:
                 pass
-            
+
             if obiGsea.already_have_correlations(data):
 
                 #disable correlation type
     #d = orange.ExampleTable('/home/marko/ddd.tab')
     #d = orange.ExampleTable('tmp.tab')
     #d = orange.ExampleTable('../gene_three_lines_log.tab')
-    ow.setData(d)
+
+    QTimer.singleShot(1000, lambda : ow.setData(d))
 
     a.exec_()
     ow.saveSettings()