Changeset 1877:2a17616eb737 in orange-bioinformatics


Ignore:
Timestamp:
10/09/13 11:56:52 (6 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Parents:
1876:98f567fbb6f9 (diff), 1862:49d9912ff84f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged biolab/orange-bioinformatics into default

Fixed conflicts in orangecontrib/bio/widgets/OWSetEnrichment.py

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/obiGeneSets.py

    r1873 r1877  
    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): 
  • orangecontrib/bio/widgets/OWSetEnrichment.py

    r1874 r1877  
    2727 
    2828REPLACES = ["_bioinformatics.widgets.OWSetEnrichment.OWSetEnrichment"] 
     29 
     30 
     31def gsname(geneset): 
     32    return geneset.name if geneset.name else geneset.id 
    2933 
    3034 
     
    260264#            print self.speciesIndex 
    261265 
    262             self.setHierarchy(self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
     266            self.setHierarchy(*self.getHierarchy(taxid=self.taxid_list[self.speciesIndex])) 
    263267 
    264268            self.loadedGenematcher = "None" 
     
    281285            collect(collection[t_id], hierarchy) 
    282286 
    283         #add genesets without species identifiers 
    284         collection[taxid].update(collection[None]) 
    285         return collection[taxid] 
    286  
    287     def setHierarchy(self, hierarchy): 
     287        return (taxid, collection[taxid]), (None, collection[None]) 
     288 
     289    def setHierarchy(self, hierarchy, hierarchy_noorg): 
    288290        self.groupsWidgetItems = {} 
    289         def fill(col, parent, full=()): 
     291        def fill(col, parent, full=(), org=""): 
    290292            for key, value in sorted(col.items()): 
    291293                full_cat = full + (key,) 
     
    298300                item.setExpanded(True) 
    299301                item.category = full_cat 
     302                item.organism = org 
    300303                self.groupsWidgetItems[full_cat] = item 
    301                 fill(value, item, full_cat) 
    302  
    303         fill(hierarchy, self.groupsWidget) 
     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]) 
    304308 
    305309#    def updateCategoryCounts(self): 
     
    308312 
    309313    def selectedCategories(self): 
    310         taxid = self.taxid_list[self.speciesIndex] 
    311         return [(key, taxid) for key, check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
     314        return [(key, org) for (key, org), check in self.getHierarchyCheckState().items() if check == Qt.Checked] 
    312315 
    313316    def getHierarchyCheckState(self): 
     
    316319            name = str(item.data(0, Qt.DisplayRole).toString()) 
    317320            full_cat = full + (name,) 
    318             result = [(full_cat, checked)] 
     321            result = [((full_cat, item.organism), checked)] 
    319322            for i in range(item.childCount()): 
    320323                result.extend(collect(item.child(i), full_cat)) 
     
    326329 
    327330    def subsetSelectionChanged(self, item, column): 
     331        #FIXME this should also recompute FDR 
    328332        self.categoriesCheckState = self.getHierarchyCheckState() 
    329  
    330333        categories = self.selectedCategories() 
    331334        if not set(categories) <= set(self.currentAnnotatedCategories): 
     
    475478        for i, (geneset, (cmapped, rmapped, p_val, enrichment)) in enumerate(results): 
    476479            if len(cmapped) > 0: 
    477                 item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), geneset.name]) 
     480                item = MyTreeWidgetItem(self.annotationsChartView, [" ".join(geneset.hierarchy), gsname(geneset)]) 
    478481                item.setData(2, Qt.DisplayRole, QVariant(countFmt % (len(cmapped), 100.0*len(cmapped)/countAll))) 
    479482                item.setData(2, Qt.ToolTipRole, QVariant(len(cmapped))) # For filtering 
     
    499502 
    500503        replace = lambda s:s.replace(",", " ").replace("(", " ").replace(")", " ") 
    501         self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[geneset.name] + replace(geneset.name).split() for geneset, (c, _, _, _) in results if c], set()))) 
     504        self._completerModel = completerModel = QStringListModel(sorted(reduce(set.union, [[gsname(geneset)] + replace(gsname(geneset)).split() for geneset, (c, _, _, _) in results if c], set()))) 
    502505        self.filterCompleter.setModel(completerModel) 
    503506 
     
    522525            item_cat = str(item.data(0, Qt.EditRole).toString()) 
    523526            count, pval = _toPyObject(item.data(2, Qt.ToolTipRole)), _toPyObject(item.data(4, 42)) 
    524             geneset = item.geneset.name.lower() 
     527            geneset = gsname(item.geneset).lower() 
    525528            hidden = item_cat not in categories or (self.useMinCountFilter and count < self.minClusterCount) or \ 
    526529                     (self.useMaxPValFilter and pval > self.maxPValue) or filterString not in geneset 
  • setup.py

    r1862 r1877  
    6060    exclude = ('*.tests', '*.tests.*', 'tests.*', 'tests'), 
    6161) 
    62   
     62 
    6363PACKAGE_DATA = { 
    6464} 
     65 
     66# Backwards compatibility stub. Should be removed by the 2.7 release. 
     67PY_MODULES = ["_bioinformatics"] 
    6568 
    6669SETUP_REQUIRES = ( 
     
    104107ENTRY_POINTS = { 
    105108    'orange.addons': ( 
    106         'bio = _bioinformatics', 
     109        'bio = orangecontrib.bio', 
    107110    ), 
    108111    'orange.widgets': ( 
    109         'Bioinformatics = _bioinformatics.widgets', 
     112        'Bioinformatics = orangecontrib.bio.widgets', 
    110113        # This should be unneeded, because module given should load (register) 
    111114        # all wanted widgets and prototypes should just have a flag, but for now ... 
    112         'Prototypes = _bioinformatics.widgets.prototypes', 
     115        'Prototypes = orangecontrib.bio.widgets.prototypes', 
    113116    ), 
    114117    'orange.canvas.help': ( 
    115         'intersphinx = _bioinformatics.widgets:intersphinx' 
     118        'intersphinx = orangecontrib.bio.widgets:intersphinx' 
    116119    ) 
    117120} 
     
    132135        packages = PACKAGES, 
    133136        package_data = PACKAGE_DATA, 
     137        py_modules = PY_MODULES, 
    134138        setup_requires = SETUP_REQUIRES, 
    135139        install_requires = INSTALL_REQUIRES, 
  • setup.py

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