Changeset 1860:504bc511801c in orange-bioinformatics


Ignore:
Timestamp:
10/08/13 16:44:31 (7 months ago)
Author:
markotoplak
Branch:
default
Message:

obiGeneSets.collections raises an exception if gene sets are not found. Temporarily disabled gene sets without species in Gene Set Enrichment widget.

Location:
_bioinformatics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiGeneSets.py

    r1836 r1860  
    2323 
    2424from Orange.bio.geneset import GeneSet, GeneSets, GenesetRegException 
     25 
     26class NoGenesetsException(Exception): pass 
    2527 
    2628def goGeneSets(org): 
     
    360362 
    361363def load_local(hierarchy, organism): 
    362     files = map(lambda x: x[:2], list_local()) 
    363     hierd = build_hierarchy_dict(files) 
    364  
    365     out = GeneSets() 
    366     for (h, o) in [ files[i] for i in hierd[(hierarchy, organism)]]: 
    367         fname = os.path.join(local_path(), filename(h, o)) 
    368         out.update(pickle.load(open(fname, 'r'))) 
    369     return out 
     364    return load_fn(hierarchy, organism, list_local,  
     365        lambda h,o: os.path.join(local_path(), filename(h, o))) 
    370366 
    371367def load_serverfiles(hierarchy, organism): 
    372     files = map(lambda x: x[:2], list_serverfiles()) 
     368    return load_fn(hierarchy, organism, list_serverfiles,  
     369        lambda h,o: orngServerFiles.localpath_download(sfdomain, filename(h, o))) 
     370 
     371def load_fn(hierarchy, organism, fnlist, fnget): 
     372    files = map(lambda x: x[:2], fnlist()) 
    373373    hierd = build_hierarchy_dict(files) 
    374374    out = GeneSets() 
     375    matches = hierd[(hierarchy, organism)] 
     376    if not matches: 
     377        exstr = "No gene sets for " + str(hierarchy) + \ 
     378                " (org " + str(organism) + ")" 
     379        raise NoGenesetsException(exstr) 
    375380    for (h, o) in [ files[i] for i in hierd[(hierarchy, organism)]]: 
    376         fname = orngServerFiles.localpath_download(sfdomain, 
    377             filename(h, o)) 
     381        fname = fnget(h, o) 
    378382        out.update(pickle.load(open(fname, 'r'))) 
    379383    return out 
     
    382386    """ First try to load from the local registred folder. If the file 
    383387    is not available, load it from the server files. """ 
    384     ret = load_local(hierarchy, organism) 
    385     if len(ret) == 0: 
    386         ret.update(load_serverfiles(hierarchy, organism)) 
    387     return ret 
     388    try: 
     389        return load_local(hierarchy, organism) 
     390    except NoGenesetsException: 
     391        return load_serverfiles(hierarchy, organism) 
    388392 
    389393def collections(*args): 
  • _bioinformatics/widgets/OWSetEnrichment.py

    r1827 r1860  
    266266                collect(col[hier[0]], hier[1:]) 
    267267 
     268        print "GS", self.genesets 
     269 
    268270        for hierarchy, t_id, _ in self.genesets: 
    269271            collect(collection[t_id], hierarchy) 
    270272 
    271         #add genesets without species identifiers 
    272         collection[taxid].update(collection[None]) 
     273        #TODO add genesets without species identifiers 
     274 
    273275        return collection[taxid] 
    274276 
     
    410412 
    411413        ## Load collections in a worker thread 
     414        print "CAT", categories 
    412415        call = self.asyncCall(obiGeneSets.collections, categories, name="Loading collections", blocking=True, thread=self.thread()) 
    413416        call.connect(call, SIGNAL("progressChanged(float)"), self.progressBarSet) 
Note: See TracChangeset for help on using the changeset viewer.