Changeset 1550:9226929348de in orange-bioinformatics


Ignore:
Timestamp:
02/03/12 15:14:31 (2 years ago)
Author:
ales_erjavec
Branch:
default
Message:

Removed unneeded imports, fixed some errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiKEGG2/__init__.py

    r1545 r1550  
    1212from __future__ import absolute_import 
    1313 
    14 import urllib2 
    1514 
    1615import os, sys 
    17 from functools import wraps, partial 
    1816from collections import defaultdict 
    1917 
    20 import re 
    2118from datetime import datetime 
    2219 
     
    124121     
    125122    def get_genes_by_pathway(self, pathway_id): 
    126         return Pathway(pathway_id).genes() 
     123        return KEGGPathway(pathway_id).genes() 
    127124     
    128125    def get_enzymes_by_pathway(self, pathway_id): 
    129         return Pathway(pathway_id).enzymes() 
     126        return KEGGPathway(pathway_id).enzymes() 
    130127     
    131128    def get_compounds_by_pathway(self, pathway_id): 
    132         return Pathway(pathway_id).compounds() 
     129        return KEGGPathway(pathway_id).compounds() 
    133130     
    134131    def get_pathways_by_genes(self, gene_ids): 
     
    235232    genome = KEGGGenome() 
    236233    res = genome.search(taxid) 
     234    print taxid, res 
    237235    for r in res: 
    238236        e = genome[r] 
    239         if e.taxid == taxid: 
     237         
     238        if e.taxid in [taxid,  genome.TAXID_MAP.get(taxid, taxid)]: 
    240239            return e.org_code() 
    241240         
     
    259258class MatcherAliasesKEGG(obiGene.MatcherAliasesPickled): 
    260259    DOMAIN = "KEGG" 
     260    VERSION = "v3.0" 
    261261    def create_aliases(self): 
    262         files = set(serverfiles.listfiles(self.DOMAIN)) 
    263         ids_filename = "gene_matcher_kegg_ids_" + self.organism + ".pickle" 
     262        import cPickle 
     263        files = set(serverfiles.ServerFiles().listfiles(self.DOMAIN)) 
     264        ids_filename = "kegg_gene_id_aliases_" + self.organism + ".pickle" 
    264265        if ids_filename in files: 
    265266            filename = serverfiles.localpath_download(self.DOMAIN, ids_filename) 
    266             import cPickle 
     267             
    267268            aliases = cPickle.load(open(filename, "rb")) 
    268269        else: 
     
    274275            for key, entry in genes.iteritems(): 
    275276                aliases.append(set([key]) | set(entry.alt_names)) 
     277            filename = serverfiles.localpath_download(self.DOMAIN, ids_filename) 
     278            cPickle.dump(aliases, open(filename, "wb")) 
     279             
    276280        return aliases 
    277281     
     
    279283        return "kegg3_" + self.organism 
    280284     
     285    def aliases_path(self): 
     286        ids_filename = "kegg_gene_id_aliases_" + self.organism + ".pickle" 
     287        return serverfiles.localpath(self.DOMAIN, ids_filename) 
     288     
    281289    def create_aliases_version(self): 
    282290        files = set(serverfiles.listfiles(self.DOMAIN)) 
    283         ids_filename = "gene_matcher_kegg_ids_" + self.organism + ".pickle" 
     291        ids_filename = "kegg_gene_id_aliases_" + self.organism + ".pickle" 
    284292        if ids_filename in files: 
    285293            version = serverfiles.info(self.DOMAIN, ids_filename)["datetime"] 
     
    294302        sf = serverfiles.ServerFiles() 
    295303        files = set(sf.listfiles(self.DOMAIN)) 
    296         ids_filename = "gene_matcher_kegg_ids_" + self.organism + ".pickle" 
     304        ids_filename = "kegg_gene_id_aliases_" + self.organism + ".pickle" 
    297305        if ids_filename in files: 
    298306            serverfiles.update(self.DOMAIN, ids_filename) 
Note: See TracChangeset for help on using the changeset viewer.