Flashpoint avatar Flashpoint committed 5cc362d

DictyMutants geneset working

Comments (0)

Files changed (2)

_bioinformatics/obiDictyMutants.py

     def __init__(self, mutant_line):
         mutant = mutant_line.split("\t")
         self.name = mutant[0]
-        self.descriptor = set(mutant[1].split("/"))
+        self.descriptor = mutant[1]
         self.genes = mutant[2].split(" | ")
         self.phenotypes = mutant[3].split(" | ")
         self.null = False
 
     def mutant_genes(self, mutant):
         return self._mutants[mutant].genes
+    
+    def mutant_phenotypes(self, mutant):
+        return self._mutants[mutant].phenotypes
 
     def gene_mutants(self):
-        d = defaultdict(set)
+        dgm = defaultdict(set)
         for mutant, genes in [(mutant, self.mutant_genes(mutant)) for mutant in self.mutants()]:
             for gene in genes:
-                d[gene].add(mutant)
-        return d
+                dgm[gene].add(mutant)
+        return dgm
+
+    def phenotype_mutants(self):
+        dpm = defaultdict(set)
+        for mutant, phenotypes in [(mutant, self.mutant_phenotypes(mutant)) for mutant in self.mutants()]:
+            for phenotype in phenotypes:
+                dpm[phenotype].add(mutant)
+        return dpm
+
 
 def mutants():
     """ Return all mutant objects
     """
     return DictyMutants.get_instance().mutant_genes(mutant)
 
+def mutant_phenotypes(mutant):   
+    """ Return a set of all phenotypes referenced ba a mutant in dictybase
+    """
+    return DictyMutants.get_instance().mutant_phenotypes(mutant)
+
 def gene_mutants():
     """ Return a dictionary {gene: set(mutant_objects for mutant), ...}
     """
     return DictyMutants.get_instance().gene_mutants()
 
+def phenotype_mutants():
+    """ Return a dictionary {phenotype: set(mutant_objects for mutant), ...}
+    """
+    return DictyMutants.get_instance().phenotype_mutants()
+
 if  __name__  == "__main__":
-    print(mutants())    
+    print(phenotype_mutants())    

_bioinformatics/obiGeneSets.py

     Return dicty mutant phenotype gene sets from Dictybase
     """
     from . import obiDictyMutants
-    genesets = [GeneSet(id=dicty_mutant.id, name=dicty_mutant.descriptor, genes=obiDictyMutants.mutant_genes(mutant), hierarchy=("Dictybase", "mutant_phenotypes"), organism="352472", # 352742 gathered from obiGO.py code_map -> Dicty identifier
-                        link=("http://dictybase.org/db/cgi-bin/dictyBase/SC/scsearch.pl?searchdb=strains&search_term=%s&column=all&B1=Submit" % mutant.id if mutant.id else None)) \
+    link_fmt = "http://dictybase.org/db/cgi-bin/dictyBase/SC/scsearch.pl?searchdb=strains&search_term=%s&column=all&B1=Submit" 
+    genesets = [GeneSet(id=mutant.name, name=mutant.descriptor, genes=obiDictyMutants.mutant_genes(mutant), hierarchy=("Dictybase", ), organism="352472", # 352472 gathered from obiGO.py code_map -> Dicty identifier
+                        link=(link_fmt % mutant.name if mutant.name else None)) \
                         for mutant in obiDictyMutants.mutants()]
+    genesets.extend([GeneSet(id=mutant.name, name=mutant.descriptor, genes=obiDictyMutants.mutant_phenotypes(mutant), hierarchy=("Dictybase", "phenotype_mutants"), organism="352472",
+                        link=(link_fmt % mutant.name if mutant.name else None)) \
+                        for mutant in obiDictyMutants.mutants()])
+
     return GeneSets(genesets)
 
 def omimGeneSets():
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.