Changes in [1786:df95834ddac7:1799:2f952a765716] in orange-bioinformatics


Ignore:
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiDictyMutants.py

    r1781 r1792  
     1""" 
     2============================================================================== 
     3DictyMutants - An interface to Dictyostelium discoideum mutants from Dictybase 
     4============================================================================== 
     5 
     6:mod:`DictyMutants` is a python module for accessing Dictyostelium discoideum  
     7mutant collections from the `Dictybase <http://www.dictybase.org/>`_ website. 
     8 
     9The mutants are presented as `DictyMutant` objects with their respective name, 
     10strain descriptor, associated genes and associated phenotypes. 
     11 
     12>>> from Orange.bio.obiDictyMutants import * 
     13>>> # Create a set of all mutant objects 
     14>>> dicty_mutants = mutants()  
     15>>> # List a set of all genes referenced by a single mutant 
     16>>> print mutant_genes(dicty_mutants[0]) 
     17['cbfA'] 
     18>>> # List a set of all phenotypes referenced by a single mutant 
     19>>> print mutant_phenotypes(dicty_mutants[0]) 
     20['aberrant protein localization'] 
     21>>> # List all genes or all phenotypes referenced on Dictybase 
     22>>> print genes() 
     23>>> print phenotypes() 
     24>>> # Display a dictionary {phenotypes: set(mutant_objects)} 
     25>>> print phenotype_mutants() 
     26>>> # Display a dictionary {genes: set(mutant_objects)} 
     27>>> print gene_mutants() 
     28""" 
     29 
    130import os 
    231import urllib2 
     
    1544 
    1645class DictyMutant(object): 
    17  
    18     def __init__(self, mutant_line): 
    19         mutant = mutant_line.split("\t") 
     46    """ 
     47    A class representing a single Dictyostelium discoideum mutant  
     48    from Dictybase 
     49    
     50    :param mutant_entry: A single mutant entry from  
     51        dictybase's `all curated mutants file <http://dictybase.org/db/cgi-bin/dictyBase/download/download.pl?area=mutant_phenotypes&ID=all-mutants.txt>`_ (updated monthly) 
     52    :type mutant_entry: str 
     53 
     54    :ivar DictyMutant.name: dictyBase ID for a mutant 
     55    :ivar DictyMutant.descriptor: dictyBase strain descriptor of a mutant 
     56    :ivar DictyMutant.genes: all of the mutant's associated genes 
     57    :ivar DictyMutant.phenotypes: all of the mutant's associated phenotypes 
     58 
     59    """ 
     60    def __init__(self, mutant_entry): 
     61        mutant = mutant_entry.split("\t") 
    2062        self.name = mutant[0] 
    2163        self.descriptor = mutant[1] 
     
    2971  
    3072class DictyMutants(object): 
     73    """ 
     74    A class representing the collection of all Dictybase mutants as  
     75    a dictionary of `DictyMutant` objects 
     76     
     77    :param local_database_path: A user defined path for storing dicty mutants objects in a file. If `None` then a default database path is used. 
     78     
     79    """ 
     80     
    3181    VERSION=1 
    3282    DEFAULT_DATABASE_PATH = orngServerFiles.localpath("DictyMutants") #use a default local folder for storing the genesets 
     
    102152        return sorted(set(reduce(list.__add__, [self.mutant_genes(mutant) for mutant in self.mutants()], []))) 
    103153 
     154    def phenotypes(self): 
     155        return sorted(set(reduce(list.__add__, [self.mutant_phenotypes(mutant) for mutant in self.mutants()], []))) 
     156 
    104157    def mutant_genes(self, mutant): 
    105158        return self._mutants[mutant].genes 
     
    132185    return DictyMutants.get_instance().genes() 
    133186 
     187def phenotypes(): 
     188    """ Return a set of all phenotypes referenced in dictybase 
     189    """ 
     190    return DictyMutants.get_instance().phenotypes() 
     191 
    134192def mutant_genes(mutant): 
    135193    """ Return a set of all genes referenced by a mutant in dictybase 
     
    138196 
    139197def mutant_phenotypes(mutant):    
    140     """ Return a set of all phenotypes referenced ba a mutant in dictybase 
     198    """ Return a set of all phenotypes referenced by a mutant in dictybase 
    141199    """ 
    142200    return DictyMutants.get_instance().mutant_phenotypes(mutant) 
     
    156214 
    157215if  __name__  == "__main__": 
    158     print(phenotype_mutants())     
     216    dicty_mutants = mutants() 
     217    print mutant_phenotypes(dicty_mutants[0]) 
     218#    print(phenotypes())#_mutants())     
  • _bioinformatics/obiGeneSets.py

    r1782 r1798  
    7676 
    7777    return GeneSets(genesets) 
     78 
     79def cytobandGeneSets(): 
     80    """ 
     81    Create cytoband gene sets from Stanford Microarray Database 
     82    """ 
     83    import urllib2 
     84 
     85    url = "http://www-stat.stanford.edu/~tibs/GSA/cytobands-stanford.gmt" 
     86    stream = urllib2.urlopen(url) 
     87    data = stream.read().splitlines() 
     88 
     89    genesets = [] 
     90    for band in data: 
     91        b = band.split("\t") 
     92        genesets.append(GeneSet(id=b[0], name=b[1], genes=b[2:] if b[2:] else [], hierarchy=("Cytobands",), organism="9606", link=""))           
     93 
     94    return GeneSets(genesets) 
     95 
     96def reactomePathwaysGeneSets(): 
     97    """ 
     98    Prepare human pathways gene sets from reactome pathways 
     99    """ 
     100    import urllib 
     101    import io 
     102    from zipfile import ZipFile 
     103 
     104    url = urllib.urlopen("http://www.reactome.org/download/current/ReactomePathways.gmt.zip") 
     105    memfile = io.BytesIO(url.read()) 
     106    with ZipFile(memfile, "r") as myzip: 
     107        f = myzip.open("ReactomePathways.gmt") 
     108        content = f.read().splitlines()       
     109 
     110    genesets = [GeneSet(id=path.split("\t")[0], name=path.split("\t")[0], genes=path.split("\t")[2:] if path.split("\t")[2:] else [], hierarchy=("Reactome", "Pathways"), organism="9606", link="") for path in content] 
     111    return GeneSets(genesets) 
     112 
    78113 
    79114def omimGeneSets(): 
     
    379414 
    380415if __name__ == "__main__": 
     416    print reactomePathwaysGeneSets() 
     417    exit() 
    381418    rsf = orngServerFiles.ServerFiles(username=sys.argv[1], password=sys.argv[2]) 
    382419    upload_genesets(rsf) 
  • _bioinformatics/obiOMIM.py

    r1784 r1799  
    2020        if match.group("m2"): 
    2121            self.mapping += " " + match.group("m2").strip() 
    22          
     22                                                                                 
    2323class OMIM(object): 
    2424    VERSION = 1 
     
    2626    def __init__(self, local_database_path=None): 
    2727        self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH 
    28          
     28   
    2929        if self.local_database_path == self.DEFAULT_DATABASE_PATH: 
    3030            filename = Orange.utils.serverfiles.localpath_download("OMIM", "morbidmap") 
     
    4141        shutil.copyfileobj(stream, file, length=10) 
    4242        file.close() 
    43          
     43 
    4444    @classmethod 
    4545    def get_instance(cls): 
     
    5555        lines = file.read().splitlines() 
    5656        self._disease_dict = dict([(disease(line), line) for line in lines if line]) 
    57          
     57     
    5858    def diseases(self): 
    5959        return self._disease_dict.keys() 
     
    7171                d[gene].add(disease) 
    7272        return d 
    73      
     73 
    7474def diseases(): 
    7575    """ Return all disease objects 
    7676    """ 
    7777    return OMIM.get_instance().diseases() 
    78          
     78 
    7979def genes(): 
    8080    """ Return a set of all genes referenced in OMIM  
     
    9191    """ 
    9292    return OMIM.get_instance().gene_diseases() 
     93 
  • _bioinformatics/widgets/OWSetEnrichment.py

    r1761 r1794  
    4747            return id(self) < id(other) 
    4848        column = self.treeWidget().sortColumn() 
    49         lhs = _toPyObject(self.data(column, Qt.DisplayRole)) 
    50         rhs = _toPyObject(other.data(column, Qt.DisplayRole)) 
     49        if column == 4: 
     50            lhs = _toPyObject(self.data(column, 42)) 
     51            rhs = _toPyObject(other.data(column, 42)) 
     52        else: 
     53            lhs = _toPyObject(self.data(column, Qt.DisplayRole)) 
     54            rhs = _toPyObject(other.data(column, Qt.DisplayRole)) 
    5155        return lhs < rhs 
    5256 
     
    137141        dsp, dspcb = OWGUI.doubleSpin(hWidget, self, 
    138142                        "maxPValue", 0.0, 1.0, 0.0001, 
    139                         label="P-Value (FDR corrected)", 
    140                         tooltip="Maximum (FDR corrected) P-Value", 
     143                        label="FDR adjusted P-Value", 
     144                        tooltip="Maximum (FDR adjusted) P-Value", 
    141145                        callback=self.filterAnnotationsChartView, 
    142146                        callbackOnReturn=True, 
     
    459463                item.setData(2, Qt.ToolTipRole, QVariant(len(cmapped))) # For filtering 
    460464                item.setData(3, Qt.DisplayRole, QVariant(refFmt % (len(rmapped), 100.0*len(rmapped)/len(referenceGenes)))) 
    461                 item.setData(4, Qt.DisplayRole, QVariant("%0.2e"% p_val)) 
     465                if p_val > 0.001: 
     466                    item.setData(4, Qt.DisplayRole, QVariant("%0.6f" % p_val)) 
     467                else: 
     468                    item.setData(4, Qt.DisplayRole, QVariant("%0.2e" % p_val)) 
    462469                item.setData(4, 42, QVariant(p_val)) 
    463470                #stoplec 4 - zelim sort po p_val 
  • docs/rst/index.rst

    r1742 r1790  
    2727   reference/kegg.rst 
    2828   reference/ontology.rst 
     29   reference/dictybase.rst 
    2930 
    3031Installation 
  • server_update/updateOMIM.py

    r1721 r1794  
    11##!interval=7 
    22##!contact=ales.erjavec@fri.uni-lj.si 
     3 
    34 
    45from common import * 
     
    1920                   tags=["genes", "diseases", "human", "OMIM" "#version:%i" % obiOMIM.OMIM.VERSION]) 
    2021sf_server.unprotect("OMIM", "morbidmap") 
     22 
     23 
     24""" 
     25Orange server upload for OMIM morbidmap gene sets 
     26""" 
     27from Orange.bio.obiGeneSets import omimGeneSets, register 
     28 
     29omim_sets_split = omimGeneSets().split_by_hierarchy() 
     30for omim_sets in omim_sets_split: 
     31    register(omim_sets, sf_server) 
     32 
Note: See TracChangeset for help on using the changeset viewer.