Changes in [1877:2a17616eb737:1876:98f567fbb6f9] in orange-bioinformatics


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/obiGeneSets.py

    r1877 r1873  
    2323 
    2424from Orange.bio.geneset import GeneSet, GeneSets, GenesetRegException 
    25  
    26 class NoGenesetsException(Exception): pass 
    2725 
    2826def goGeneSets(org): 
     
    362360 
    363361def load_local(hierarchy, organism): 
    364     return load_fn(hierarchy, organism, list_local,  
    365         lambda h,o: os.path.join(local_path(), filename(h, o))) 
     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 
    366370 
    367371def load_serverfiles(hierarchy, organism): 
    368     return load_fn(hierarchy, organism, list_serverfiles,  
    369         lambda h,o: orngServerFiles.localpath_download(sfdomain, filename(h, o))) 
    370  
    371 def load_fn(hierarchy, organism, fnlist, fnget): 
    372     files = map(lambda x: x[:2], fnlist()) 
     372    files = map(lambda x: x[:2], list_serverfiles()) 
    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) 
    380375    for (h, o) in [ files[i] for i in hierd[(hierarchy, organism)]]: 
    381         fname = fnget(h, o) 
     376        fname = orngServerFiles.localpath_download(sfdomain, 
     377            filename(h, o)) 
    382378        out.update(pickle.load(open(fname, 'r'))) 
    383379    return out 
     
    386382    """ First try to load from the local registred folder. If the file 
    387383    is not available, load it from the server files. """ 
    388     try: 
    389         return load_local(hierarchy, organism) 
    390     except NoGenesetsException: 
    391         return load_serverfiles(hierarchy, organism) 
     384    ret = load_local(hierarchy, organism) 
     385    if len(ret) == 0: 
     386        ret.update(load_serverfiles(hierarchy, organism)) 
     387    return ret 
    392388 
    393389def collections(*args): 
  • orangecontrib/bio/widgets/OWSetEnrichment.py

    r1877 r1874  
    2727 
    2828REPLACES = ["_bioinformatics.widgets.OWSetEnrichment.OWSetEnrichment"] 
    29  
    30  
    31 def gsname(geneset): 
    32     return geneset.name if geneset.name else geneset.id 
    3329 
    3430 
     
    264260#            print self.speciesIndex 
    265261 
    266             self.setHierarchy(*self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
     262            self.setHierarchy(self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
    267263 
    268264            self.loadedGenematcher = "None" 
     
    285281            collect(collection[t_id], hierarchy) 
    286282 
    287         return (taxid, collection[taxid]), (None, collection[None]) 
    288  
    289     def setHierarchy(self, hierarchy, hierarchy_noorg): 
     283        #add genesets without species identifiers 
     284        collection[taxid].update(collection[None]) 
     285        return collection[taxid] 
     286 
     287    def setHierarchy(self, hierarchy): 
    290288        self.groupsWidgetItems = {} 
    291         def fill(col, parent, full=(), org=""): 
     289        def fill(col, parent, full=()): 
    292290            for key, value in sorted(col.items()): 
    293291                full_cat = full + (key,) 
     
    300298                item.setExpanded(True) 
    301299                item.category = full_cat 
    302                 item.organism = org 
    303300                self.groupsWidgetItems[full_cat] = item 
    304                 fill(value, item, full_cat, org=org) 
    305  
    306         fill(hierarchy[1], self.groupsWidget, org=hierarchy[0]) 
    307         fill(hierarchy_noorg[1], self.groupsWidget, org=hierarchy_noorg[0]) 
     301                fill(value, item, full_cat) 
     302 
     303        fill(hierarchy, self.groupsWidget) 
    308304 
    309305#    def updateCategoryCounts(self): 
     
    312308 
    313309    def selectedCategories(self): 
    314         return [(key, org) for (key, org), check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
     310        taxid = self.taxid_list[self.speciesIndex] 
     311        return [(key, taxid) for key, check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
    315312 
    316313    def getHierarchyCheckState(self): 
     
    319316            name = str(item.data(0, Qt.DisplayRole).toString()) 
    320317            full_cat = full + (name,) 
    321             result = [((full_cat, item.organism), checked)] 
     318            result = [(full_cat, checked)] 
    322319            for i in range(item.childCount()): 
    323320                result.extend(collect(item.child(i), full_cat)) 
     
    329326 
    330327    def subsetSelectionChanged(self, item, column): 
    331         #FIXME this should also recompute FDR 
    332328        self.categoriesCheckState = self.getHierarchyCheckState() 
     329 
    333330        categories = self.selectedCategories() 
    334331        if not set(categories) <= set(self.currentAnnotatedCategories): 
     
    478475        for i, (geneset, (cmapped, rmapped, p_val, enrichment)) in enumerate(results): 
    479476            if len(cmapped) > 0: 
    480                 item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), gsname(geneset)]) 
     477                item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), geneset.name]) 
    481478                item.setData(2, Qt.DisplayRole, QVariant(countFmt % (len(cmapped), 100.0*len(cmapped)/countAll))) 
    482479                item.setData(2, Qt.ToolTipRole, QVariant(len(cmapped))) # For filtering 
     
    502499 
    503500        replace = lambda s:s.replace(",", " ").replace("(", " ").replace(")", " ") 
    504         self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[gsname(geneset)] + replace(gsname(geneset)).split() for geneset, (c, _, _, _) in results if c], set()))) 
     501        self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[geneset.name] + replace(geneset.name).split() for geneset, (c, _, _, _) in results if c], set()))) 
    505502        self.filterCompleter.setModel(completerModel) 
    506503 
     
    525522            item_cat = str(item.data(0, Qt.EditRole).toString()) 
    526523            count, pval = _toPyObject(item.data(2, Qt.ToolTipRole)), _toPyObject(item.data(4, 42)) 
    527             geneset = gsname(item.geneset).lower() 
     524            geneset = item.geneset.name.lower() 
    528525            hidden = item_cat not in categories or (self.useMinCountFilter and count < self.minClusterCount) or \ 
    529526                     (self.useMaxPValFilter and pval > self.maxPValue) or filterString not in geneset 
  • setup.py

    r1877 r1873  
    1616DOCUMENTATION_NAME = 'Orange Bioinformatics' 
    1717 
    18 VERSION = '2.5a10' 
     18VERSION = '2.5a9' 
    1919 
    2020DESCRIPTION = 'Orange Bioinformatics add-on for Orange data mining software package.' 
Note: See TracChangeset for help on using the changeset viewer.