Changeset 1792:89d57e897273 in orange-bioinformatics for _bioinformatics/obiDictyMutants.py


Ignore:
Timestamp:
05/14/13 13:33:33 (11 months ago)
Author:
Flashpoint <vid.flashpoint@…>
Branch:
default
Message:

Added a documentation entry for obiDictyMutants.py

File:
1 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())     
Note: See TracChangeset for help on using the changeset viewer.