Commits

Marko Toplak committed 2f952a7 Merge

Merged changes from Vid's branch.

  • Participants
  • Parent commits df95834, f1e7390

Comments (0)

Files changed (10)

File _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())    

File _bioinformatics/obiGeneSets.py

 
     return GeneSets(genesets)
 
+def cytobandGeneSets():
+    """
+    Create cytoband gene sets from Stanford Microarray Database
+    """
+    import urllib2
+
+    url = "http://www-stat.stanford.edu/~tibs/GSA/cytobands-stanford.gmt"
+    stream = urllib2.urlopen(url)
+    data = stream.read().splitlines()
+
+    genesets = []
+    for band in data:
+        b = band.split("\t")
+        genesets.append(GeneSet(id=b[0], name=b[1], genes=b[2:] if b[2:] else [], hierarchy=("Cytobands",), organism="9606", link=""))          
+
+    return GeneSets(genesets)
+
+def reactomePathwaysGeneSets():
+    """
+    Prepare human pathways gene sets from reactome pathways
+    """
+    import urllib
+    import io
+    from zipfile import ZipFile
+
+    url = urllib.urlopen("http://www.reactome.org/download/current/ReactomePathways.gmt.zip")
+    memfile = io.BytesIO(url.read())
+    with ZipFile(memfile, "r") as myzip:
+        f = myzip.open("ReactomePathways.gmt")
+        content = f.read().splitlines()      
+
+    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]
+    return GeneSets(genesets)
+
+
 def omimGeneSets():
     """
     Return gene sets from OMIM (Online Mendelian Inheritance in Man) diseses
                 print "organism not found", org
 
 if __name__ == "__main__":
+    print reactomePathwaysGeneSets()
+    exit()
     rsf = orngServerFiles.ServerFiles(username=sys.argv[1], password=sys.argv[2])
     upload_genesets(rsf)
     pass

File _bioinformatics/obiOMIM.py

         self.name, self.id, self.mapping = [s.strip() if s else s for s in match.groups()[:3]]
         if match.group("m2"):
             self.mapping += " " + match.group("m2").strip()
-        
+                                                                                
 class OMIM(object):
     VERSION = 1
     DEFAULT_DATABASE_PATH = Orange.utils.serverfiles.localpath("OMIM")
     def __init__(self, local_database_path=None):
         self.local_database_path = local_database_path if local_database_path is not None else self.DEFAULT_DATABASE_PATH
-        
+  
         if self.local_database_path == self.DEFAULT_DATABASE_PATH:
             filename = Orange.utils.serverfiles.localpath_download("OMIM", "morbidmap")
         else:
         stream = urllib2.urlopen("ftp://ftp.ncbi.nih.gov/repository/OMIM/ARCHIVE/morbidmap")
         shutil.copyfileobj(stream, file, length=10)
         file.close()
-        
+
     @classmethod
     def get_instance(cls):
         if not hasattr(cls, "_shared_dict"):
         file = open(filename, "rb")
         lines = file.read().splitlines()
         self._disease_dict = dict([(disease(line), line) for line in lines if line])
-        
+    
     def diseases(self):
         return self._disease_dict.keys()
     
             for gene in genes:
                 d[gene].add(disease)
         return d
-    
+
 def diseases():
     """ Return all disease objects
     """
     return OMIM.get_instance().diseases()
-        
+
 def genes():
     """ Return a set of all genes referenced in OMIM 
     """
     """ Return a dictionary {gene: set(disease_objects for gene), ...}
     """
     return OMIM.get_instance().gene_diseases()
+

File _bioinformatics/widgets/OWSetEnrichment.py

         if not self.treeWidget():
             return id(self) < id(other)
         column = self.treeWidget().sortColumn()
-        lhs = _toPyObject(self.data(column, Qt.DisplayRole))
-        rhs = _toPyObject(other.data(column, Qt.DisplayRole))
+        if column == 4:
+            lhs = _toPyObject(self.data(column, 42))
+            rhs = _toPyObject(other.data(column, 42))
+        else:
+            lhs = _toPyObject(self.data(column, Qt.DisplayRole))
+            rhs = _toPyObject(other.data(column, Qt.DisplayRole))
         return lhs < rhs
 
 def name_or_none(id):
 
         dsp, dspcb = OWGUI.doubleSpin(hWidget, self,
                         "maxPValue", 0.0, 1.0, 0.0001,
-                        label="P-Value (FDR corrected)",
-                        tooltip="Maximum (FDR corrected) P-Value",
+                        label="FDR adjusted P-Value",
+                        tooltip="Maximum (FDR adjusted) P-Value",
                         callback=self.filterAnnotationsChartView,
                         callbackOnReturn=True,
                         checked="useMaxPValFilter",
                 item.setData(2, Qt.DisplayRole, QVariant(countFmt % (len(cmapped), 100.0*len(cmapped)/countAll)))
                 item.setData(2, Qt.ToolTipRole, QVariant(len(cmapped))) # For filtering
                 item.setData(3, Qt.DisplayRole, QVariant(refFmt % (len(rmapped), 100.0*len(rmapped)/len(referenceGenes))))
-                item.setData(4, Qt.DisplayRole, QVariant("%0.2e"% p_val))
+                if p_val > 0.001:
+                    item.setData(4, Qt.DisplayRole, QVariant("%0.6f" % p_val))
+                else:
+                    item.setData(4, Qt.DisplayRole, QVariant("%0.2e" % p_val))
                 item.setData(4, 42, QVariant(p_val))
                 #stoplec 4 - zelim sort po p_val
                 item.setData(4, Qt.ToolTipRole, QVariant("%0.10f" % p_val))

File docs/rst/index.rst

 
    reference/kegg.rst
    reference/ontology.rst
+   reference/dictybase.rst
 
 Installation
 ------------

File docs/rst/reference/dictybase.rst

+================================
+dictyBase Mutants (:mod:`obiDictyMutants`)
+================================
+
+This module presents data on `Mutant phenotypes 
+<http://dictybase.org/Downloads/>`_ from the dictyBase.
+
+.. automodule:: Orange.bio.obiDictyMutants
+   :members:
+   :member-order: bysource
+

File server_update/updateCytobands.py

+##interval:7
+from common import *
+
+"""
+Orange server upload for Cytoband gene sets
+"""
+from Orange.bio.obiGeneSets import cytobandGeneSets, register
+
+cytoband_sets_split = cytobandGeneSets().split_by_hierarchy()
+for band_sets in cytoband_sets_split:
+    register(band_sets, sf_server)

File server_update/updateDictyBase.py

File contents unchanged.

File server_update/updateOMIM.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+
 from common import *
 from Orange.bio import obiOMIM
 
 sf_server.upload("OMIM", "morbidmap", filename, title="Online Mendelian Inheritance in Man (OMIM)",
                    tags=["genes", "diseases", "human", "OMIM" "#version:%i" % obiOMIM.OMIM.VERSION])
 sf_server.unprotect("OMIM", "morbidmap")
+
+
+"""
+Orange server upload for OMIM morbidmap gene sets
+"""
+from Orange.bio.obiGeneSets import omimGeneSets, register
+
+omim_sets_split = omimGeneSets().split_by_hierarchy()
+for omim_sets in omim_sets_split:
+    register(omim_sets, sf_server)
+

File server_update/updateReactomePathways.py

+##interval:7
+from common import *
+
+"""
+Orange server upload for Cytoband gene sets
+"""
+from Orange.bio.obiGeneSets import reactomePathwaysGeneSets, register
+
+reactome_sets_split = reactomePathwaysGeneSets().split_by_hierarchy()
+for pathway_sets in reactome_sets_split:
+    register(pathway_sets, sf_server)