Changeset 1780:5cc362d703bb in orange-bioinformatics


Ignore:
Timestamp:
05/10/13 10:46:01 (12 months ago)
Author:
Flashpoint <vid.flashpoint@…>
Branch:
default
Message:

DictyMutants geneset working

Location:
_bioinformatics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiDictyMutants.py

    r1778 r1780  
    1313        mutant = mutant_line.split("\t") 
    1414        self.name = mutant[0] 
    15         self.descriptor = set(mutant[1].split("/")) 
     15        self.descriptor = mutant[1] 
    1616        self.genes = mutant[2].split(" | ") 
    1717        self.phenotypes = mutant[3].split(" | ") 
     
    9999    def mutant_genes(self, mutant): 
    100100        return self._mutants[mutant].genes 
     101     
     102    def mutant_phenotypes(self, mutant): 
     103        return self._mutants[mutant].phenotypes 
    101104 
    102105    def gene_mutants(self): 
    103         d = defaultdict(set) 
     106        dgm = defaultdict(set) 
    104107        for mutant, genes in [(mutant, self.mutant_genes(mutant)) for mutant in self.mutants()]: 
    105108            for gene in genes: 
    106                 d[gene].add(mutant) 
    107         return d 
     109                dgm[gene].add(mutant) 
     110        return dgm 
     111 
     112    def phenotype_mutants(self): 
     113        dpm = defaultdict(set) 
     114        for mutant, phenotypes in [(mutant, self.mutant_phenotypes(mutant)) for mutant in self.mutants()]: 
     115            for phenotype in phenotypes: 
     116                dpm[phenotype].add(mutant) 
     117        return dpm 
     118 
    108119 
    109120def mutants(): 
     
    122133    return DictyMutants.get_instance().mutant_genes(mutant) 
    123134 
     135def mutant_phenotypes(mutant):    
     136    """ Return a set of all phenotypes referenced ba a mutant in dictybase 
     137    """ 
     138    return DictyMutants.get_instance().mutant_phenotypes(mutant) 
     139 
    124140def gene_mutants(): 
    125141    """ Return a dictionary {gene: set(mutant_objects for mutant), ...} 
     
    127143    return DictyMutants.get_instance().gene_mutants() 
    128144 
     145def phenotype_mutants(): 
     146    """ Return a dictionary {phenotype: set(mutant_objects for mutant), ...} 
     147    """ 
     148    return DictyMutants.get_instance().phenotype_mutants() 
     149 
    129150if  __name__  == "__main__": 
    130     print(mutants())     
     151    print(phenotype_mutants())     
  • _bioinformatics/obiGeneSets.py

    r1778 r1780  
    6666    """ 
    6767    from . import obiDictyMutants 
    68     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 
    69                         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)) \ 
     68    link_fmt = "http://dictybase.org/db/cgi-bin/dictyBase/SC/scsearch.pl?searchdb=strains&search_term=%s&column=all&B1=Submit"  
     69    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 
     70                        link=(link_fmt % mutant.name if mutant.name else None)) \ 
    7071                        for mutant in obiDictyMutants.mutants()] 
     72    genesets.extend([GeneSet(id=mutant.name, name=mutant.descriptor, genes=obiDictyMutants.mutant_phenotypes(mutant), hierarchy=("Dictybase", "phenotype_mutants"), organism="352472", 
     73                        link=(link_fmt % mutant.name if mutant.name else None)) \ 
     74                        for mutant in obiDictyMutants.mutants()]) 
     75 
    7176    return GeneSets(genesets) 
    7277 
Note: See TracChangeset for help on using the changeset viewer.