Changes in [1784:6a26e5172130:1796:a8618bd60eb7] in orange-bioinformatics


Ignore:
Files:
1 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 r1795  
    7474                        link="") \ 
    7575                        for phenotype, mutants in obiDictyMutants.phenotype_mutants().items()] 
     76 
     77    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=""))           
    7693 
    7794    return GeneSets(genesets) 
     
    379396 
    380397if __name__ == "__main__": 
     398    print cytobandGeneSets() 
     399    exit() 
    381400    rsf = orngServerFiles.ServerFiles(username=sys.argv[1], password=sys.argv[2]) 
    382401    upload_genesets(rsf) 
  • _bioinformatics/obiOMIM.py

    r1784 r1796  
    33import shutil 
    44import re 
    5 import Orange 
    65 
    76from collections import defaultdict 
     7 
     8from Orange.orng import orngServerFiles 
    89 
    910class disease(object): 
     
    1516        string = morbidmap_line.split("|", 1)[0] 
    1617        match = self.regex.match(string) 
    17 #        print string 
    18 #        print match.groups() 
     18        print string 
     19        print match.groups() 
    1920        self.name, self.id, self.mapping = [s.strip() if s else s for s in match.groups()[:3]] 
    2021        if match.group("m2"): 
     
    2324class OMIM(object): 
    2425    VERSION = 1 
    25     DEFAULT_DATABASE_PATH = Orange.utils.serverfiles.localpath("OMIM") 
     26    DEFAULT_DATABASE_PATH = orngServerFiles.localpath("OMIM") 
    2627    def __init__(self, local_database_path=None): 
    2728        self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH 
    2829         
    29         if self.local_database_path == self.DEFAULT_DATABASE_PATH: 
    30             filename = Orange.utils.serverfiles.localpath_download("OMIM", "morbidmap") 
    31         else: 
    32             filename = os.path.join(self.local_database_path, "morbidmap") 
    33  
     30        if not os.path.exists(self.local_database_path): 
     31            os.makedirs(self.local_database_path) 
     32             
     33        filename = os.path.join(self.local_database_path, "morbidmap") 
     34        print filename 
     35        if not os.path.exists(filename): 
     36            stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap") 
     37            with open(filename, "wb") as file: 
     38                shutil.copyfileobj(stream, file, length=10) 
     39             
     40             
    3441        self.load(filename) 
    3542     
    3643    @classmethod 
    3744    def download_from_NCBI(cls, file=None): 
    38         if isinstance(file, basestring): 
     45        data = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap").read() 
     46        if file is None: 
     47            if not os.path.exists(cls.DEFAULT_DATABASE_PATH): 
     48                os.mkdir(cls.DEFAULT_DATABASE_PATH) 
     49            file = open(os.path.join(cls.DEFAULT_DATABASE_PATH, "morbidmap"), "wb") 
     50        elif isinstance(file, basestring): 
    3951            file = open(file, "wb") 
    40         stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap") 
    41         shutil.copyfileobj(stream, file, length=10) 
     52        file.write(data) 
    4253        file.close() 
    4354         
     
    91102    """ 
    92103    return OMIM.get_instance().gene_diseases() 
     104 
     105if __name__ == "__main__": 
     106    print genes() 
  • _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.