Flashpoint avatar Flashpoint committed 89d57e8

Added a documentation entry for obiDictyMutants.py

Comments (0)

Files changed (1)

_bioinformatics/obiDictyMutants.py

+"""
+==============================================================================
+DictyMutants - An interface to Dictyostelium discoideum mutants from Dictybase
+==============================================================================
+
+:mod:`DictyMutants` is a python module for accessing Dictyostelium discoideum 
+mutant collections from the `Dictybase <http://www.dictybase.org/>`_ website.
+
+The mutants are presented as `DictyMutant` objects with their respective name,
+strain descriptor, associated genes and associated phenotypes.
+
+>>> from Orange.bio.obiDictyMutants import *
+>>> # Create a set of all mutant objects
+>>> dicty_mutants = mutants() 
+>>> # List a set of all genes referenced by a single mutant
+>>> print mutant_genes(dicty_mutants[0])
+['cbfA']
+>>> # List a set of all phenotypes referenced by a single mutant
+>>> print mutant_phenotypes(dicty_mutants[0])
+['aberrant protein localization']
+>>> # List all genes or all phenotypes referenced on Dictybase
+>>> print genes()
+>>> print phenotypes()
+>>> # Display a dictionary {phenotypes: set(mutant_objects)}
+>>> print phenotype_mutants()
+>>> # Display a dictionary {genes: set(mutant_objects)}
+>>> print gene_mutants()
+"""
+
 import os
 import urllib2
 import shutil
 tags = ["Dictyostelium discoideum", "mutant", "dictyBase", "phenotype"]
 
 class DictyMutant(object):
+    """
+    A class representing a single Dictyostelium discoideum mutant 
+    from Dictybase
+   
+    :param mutant_entry: A single mutant entry from 
+        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)
+    :type mutant_entry: str
 
-    def __init__(self, mutant_line):
-        mutant = mutant_line.split("\t")
+    :ivar DictyMutant.name: dictyBase ID for a mutant
+    :ivar DictyMutant.descriptor: dictyBase strain descriptor of a mutant
+    :ivar DictyMutant.genes: all of the mutant's associated genes
+    :ivar DictyMutant.phenotypes: all of the mutant's associated phenotypes
+
+    """
+    def __init__(self, mutant_entry):
+        mutant = mutant_entry.split("\t")
         self.name = mutant[0]
         self.descriptor = mutant[1]
         self.genes = mutant[2].split(" | ")
         self.other = False
  
 class DictyMutants(object):
+    """
+    A class representing the collection of all Dictybase mutants as 
+    a dictionary of `DictyMutant` objects
+    
+    :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.
+    
+    """
+    
     VERSION=1
     DEFAULT_DATABASE_PATH = orngServerFiles.localpath("DictyMutants") #use a default local folder for storing the genesets
     
     def genes(self):
         return sorted(set(reduce(list.__add__, [self.mutant_genes(mutant) for mutant in self.mutants()], [])))
 
+    def phenotypes(self):
+        return sorted(set(reduce(list.__add__, [self.mutant_phenotypes(mutant) for mutant in self.mutants()], [])))
+
     def mutant_genes(self, mutant):
         return self._mutants[mutant].genes
     
     """
     return DictyMutants.get_instance().genes()
 
+def phenotypes():
+    """ Return a set of all phenotypes referenced in dictybase
+    """
+    return DictyMutants.get_instance().phenotypes()
+
 def mutant_genes(mutant):
     """ Return a set of all genes referenced by a mutant in dictybase
     """
     return DictyMutants.get_instance().mutant_genes(mutant)
 
 def mutant_phenotypes(mutant):   
-    """ Return a set of all phenotypes referenced ba a mutant in dictybase
+    """ Return a set of all phenotypes referenced by a mutant in dictybase
     """
     return DictyMutants.get_instance().mutant_phenotypes(mutant)
 
     return DictyMutants.get_instance().pickle_data()
 
 if  __name__  == "__main__":
-    print(phenotype_mutants())    
+    dicty_mutants = mutants()
+    print mutant_phenotypes(dicty_mutants[0])
+#    print(phenotypes())#_mutants())    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.