Commits

Anonymous committed 73ef4d9

error handling (file open)

Comments (0)

Files changed (2)

OWGOTermFinder.py

         allcn = len(self.RecentAnnotations)
         for f in self.RecentAnnotations:
             if f not in self.genesInAnnotationFile.keys():
-                loadedAnnotation = cPickle.load(open(f, 'r'))
-                self.genesInAnnotationFile[f] = loadedAnnotation['gene2GOID'].keys()
+                try:
+                    loadedAnnotation = cPickle.load(open(f, 'r'))
+                    self.genesInAnnotationFile[f] = loadedAnnotation['gene2GOID'].keys()
+                except:
+                    self.genesInAnnotationFile[f] = []
+                    continue
             genesInAnnotation = self.genesInAnnotationFile[f]
             for geneID in genesInAnnotation:
                 tmpl = self.geneID2annotationfile.get(geneID, [])
             self.BAnnotationIndx = bestAnnotation
             self.annotation, self.BAnnotationIndx = self.loadRemember(self.RecentAnnotations, self.annotationCombo, self.BAnnotationIndx)
             fn = self.RecentAnnotations[0] ## the loaded one is (becomes) always moved to 0 position
-            self.genesInAnnotationFile[fn] = self.annotation['gene2GOID'].keys() ## update, in case the file content changed
+            try:
+                self.genesInAnnotationFile[fn] = self.annotation['gene2GOID'].keys() ## update, in case the file content changed
+            except:
+                self.genesInAnnotationFile[fn] = []
 ##            self.annotationCombo.setCurrentItem(self.BAnnotationIndx)
 
         ## select the geneID, and rerun the GO term finding
                     lst.remove(fn)
                 lst.insert(0, fn) # add to beginning of list
                 self.setFilelist(filecombo, lst) # update combo
-                loadedData = cPickle.load(open(fn, 'r'))
+                try:
+                    loadedData = cPickle.load(open(fn, 'r'))
+                except:
+                    loadedData = None
                 indx = 0
         return loadedData, indx
 
         for f in self.RecentGenomeMaps:
             if f not in self.genesInGenomeMapFile.keys():
                 if DEBUG: print "loading", f
-                chromData = orange.ExampleTable(f, dontCheckStored=1)
-                geneIDs = [str(d['geneID']) for d in chromData] # all geneIDs in this file
-                self.genesInGenomeMapFile[f] = geneIDs # update with new data (in case file has changed)
+                try:
+                    chromData = orange.ExampleTable(f, dontCheckStored=1)
+                    geneIDs = [str(d['geneID']) for d in chromData] # all geneIDs in this file
+                    self.genesInGenomeMapFile[f] = geneIDs # update with new data (in case file has changed)
+                except:
+                    self.genesInGenomeMapFile[f] = [] # update with new data (in case file has changed)
             for geneID in self.genesInGenomeMapFile[f]:
                 tmpl = geneID2genomeMapfile.get(geneID, [])
                 if cn not in tmpl: