Changeset 1931:e58b01520933 in orange-bioinformatics


Ignore:
Timestamp:
12/11/13 23:08:52 (4 months ago)
Author:
markotoplak
Branch:
default
Message:

obiKEGG: added pathway search by genes.

Location:
orangecontrib/bio/obiKEGG
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/obiKEGG/__init__.py

    r1873 r1931  
    248248 
    249249    def get_pathways_by_genes(self, gene_ids): 
    250         return self.api.get_pathways_by_genes(gene_ids) 
     250        """ Pathways that include all genes in gene_ids. """ 
     251        l = self.api.get_genes_pathway_organism(self.org_code) 
    251252        gene_ids = set(gene_ids) 
    252         pathways = [self.genes[id].pathway for id in gene_ids 
    253                     if self.genes[id].pathway] 
    254         pathways = reduce(set.union, pathways, set()) 
    255         return [id for id in pathways 
    256                 if gene_ids.issubset(KEGGPathway(id).genes())] 
     253        gtp = defaultdict(set) 
     254        for a,b in l: 
     255            gtp[a].add(b) 
     256        pathways = [ gtp[g] for g in gene_ids ] 
     257        pathways = reduce(set.intersection, pathways) 
     258        return sorted(pathways) 
    257259 
    258260    def get_pathways_by_enzymes(self, enzyme_ids): 
  • orangecontrib/bio/obiKEGG/api.py

    r1875 r1931  
    290290        return _link_targets(self.link("ko", ids=[pathway_id])) 
    291291 
     292    ############################################# 
     293    # Pathways and genes of a specific organism # 
     294    ############################################# 
     295 
     296    def get_genes_pathway_organism(self, organism): 
     297        l = self.link("pathway", organism) 
     298        return map(tuple, l) 
     299 
    292300    ##################### 
    293301    # Pathways by objects 
     
    630638    def get_kos_by_pathway(self, pathway_id): 
    631639        return KeggApi.get_kos_by_pathway(self, pathway_id) 
     640 
     641    @cached_method 
     642    def get_genes_pathway_organism(self, org): 
     643        return KeggApi.get_genes_pathway_organism(self, org) 
     644 
    632645 
    633646 
Note: See TracChangeset for help on using the changeset viewer.