1. biolab
  2. Untitled project
  3. orange-bioinformatics

Commits

tomazc  committed e54c812

minor bug fixes
progressbar is smoother

  • Participants
  • Parent commits 2876f28
  • Branches default

Comments (0)

Files changed (1)

File GOlib.py

View file
 ## used: for cluster and reference frequencies of GO terms
 ##
 def populateGO(geneList, Lann, Lgo, LonlyGOIDs=None, progressBar = None, progressStart = 0.0, progressPart = 100.0):
-    if LonlyGOIDs and len(LonlyGOIDs) == 0:
+    if (LonlyGOIDs <> None and len(LonlyGOIDs) == 0) or (geneList <> None and len(geneList) == 0):
         return {}, {}, {}
 
     genesGOIDdirect = {}
         ## go over only the GOIDs in list
         for daGOID in LonlyGOIDs:
             if progressBar:
+                pcn += 1.0
                 progressBar(progressStart + progressPart * pcn / len(LonlyGOIDs))
-                pcn += 1.0
             geneAnn = Lann['GOID2gene'].get(daGOID, None)
             if not(geneAnn): continue
 
+            ppcn = 0.0
             for (daGene, daNOT, daEvidence, daAspect, daDB_Object_Type) in geneAnn:
+                if progressBar:
+                    ppcn += 1
+                    progressBar(progressStart + (pcn + ppcn / len(geneAnn)) * (progressPart/len(LonlyGOIDs)))
                 if daAspect <> Lgo['aspect']: continue ## skip annotations different from the loaded GO aspect
                 if daGene not in geneList:
                     continue
                     tmpl = genesGOIDboth.get(GOID, [])
                     if (daGene, daEvidence) not in tmpl:
                         genesGOIDboth[GOID] = tmpl + [(daGene, daEvidence)]
-
     else:
         ## go over all genes and find the apropriate GOIDs
         for gene in geneList: ## go over genes
             if progressBar:
+                pcn += 1.0
                 progressBar(progressStart + progressPart * pcn / len(geneList))
-                pcn += 1.0
 
             geneAnn = Lann['gene2GOID'].get(gene, None)
             if not(geneAnn): continue
 
+            ppcn = 0.0
             for (daGOID, daNOT, daEvidence, daAspect, daDB_Object_Type) in geneAnn:
+                if progressBar:
+                    ppcn += 1
+                    progressBar(progressStart + (pcn + (ppcn / len(geneAnn))) * (progressPart / len(geneList)))
                 if daAspect <> Lgo['aspect']: continue ## skip annotations different from the loaded GO aspect
     ##            if daNOT <> '': continue ## should we skip those annotations that tell when a gene is not part of a specific GO term?