Changeset 422:fe5c0da22f25 in orange-bioinformatics


Ignore:
Timestamp:
07/11/08 13:44:51 (6 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
29bf15a9fcdda0cdddca020b458dbdfa490cbf7c
Message:

-added some doc strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiKEGG.py

    r401 r422  
     1"""obiKEGG is an interface to Kyoto Encyclopedia of Genes and Genomes (http://www.genome.jp/kegg/) that allows easy access to KEGG pathway and genes data. 
     2 
     3""" 
    14import Image, ImageDraw, ImageMath 
    25import cStringIO 
     
    636639class KEGGOrganism(object): 
    637640    def __init__(self, org, update=False, local_database_path=None): 
     641         
    638642        self.org = org 
    639643        self.local_database_path = local_database_path or default_database_path 
     
    641645 
    642646    def list_pathways(self): 
     647        """Return a list of all organism specific pathways.""" 
    643648        return self.api.list_pathways(self.org) 
    644649     
    645650    def get_linked_pathways(self, pathway_id): 
     651        """Return a list of all organism specific pathways that pathway with pathway_id links to.""" 
    646652        return self.api.get_linked_pathways(pathway_id) 
    647653 
    648654    def get_genes_by_pathway(self, pathway_id): 
     655        """Return a list of all organism specific genes that are on the pathway with pathway_id.""" 
    649656        return self.api.get_genes_by_pathway(pathway_id) 
    650657 
    651     def get_enzymes_by_pathway(self, pathway_id):     
     658    def get_enzymes_by_pathway(self, pathway_id): 
     659        """Return a list of all organism specific enzymes that are on the pathway with pathway_id.""" 
    652660        return self.api.get_enzymes_by_pathway(pathway_id) 
    653661 
    654662    def get_compounds_by_pathway(self, pathway_id): 
     663        """Return a list of all organism specific compounds that are on the pathway with pathway_id.""" 
    655664        return self.api.get_enzymes_by_pathway(pathway_id) 
    656665 
    657666    def get_genes(self): 
     667        """Return a list of all organism genes.""" 
    658668        return self.api.get_genes_by_organism(self.org) 
    659669 
    660670    def get_pathways_by_genes(self, genes): 
     671        """Return a list of all organism specific pathways that contain all the genes.""" 
    661672        return self.api.get_pathways_by_genes(genes) 
    662673 
    663674    def get_enriched_pathways_by_genes(self, genes, reference=None, callback=None): 
     675        """Return a dictionary with enriched pathways ids as keys and (list_of_genes, p_value, num_of_reference_genes) tuples as items.""" 
    664676        allPathways = defaultdict(lambda :[[], 1.0, []]) 
    665677        tmp_callback = self.api.download_progress_callback 
     
    683695            entry[2].extend(reference.intersection(self.get_genes_by_pathway(p_id))) 
    684696            entry[1] = _p(float(len(entry[2]))/len(reference), len(entry[0]), len(genes)) 
    685         return dict([(pid, (genes, p, len(ref))) for pid, (genes, p, ref) in allPathways.items()]) #TODO: calculate p 
     697        return dict([(pid, (genes, p, len(ref))) for pid, (genes, p, ref) in allPathways.items()]) 
    686698 
    687699    def get_pathways_by_enzymes(self, enzymes): 
     700        """Return a list of all organism specific pathways that contain all the enzymes.""" 
    688701        return self.api.get_pathways_by_enzymes(enzymes) 
    689702 
    690703    def get_pathways_by_compounds(self, compounds): 
     704        """Return a list of all organism specific pathways that contain all the compounds.""" 
    691705        return self.api.get_pathways_by_compounds(compounds) 
    692706 
    693707    def get_enzymes_by_compound(self, compound_id): 
     708        """Return a list of all organism specific enzymes that are involved in a reaction with compound.""" 
    694709        return self.api.get_enzymes_by_compound(compound_id) 
    695710 
    696711    def get_compounds_by_enzyme(self, enzyme_id): 
     712        """Return a list of all compounds that are involved in a reaction with the enzyme.""" 
    697713        return self.api.get_compounds_by_enzyme(enzyme_id) 
    698714 
    699715    def get_genes_by_enzyme(self, enzyme_id): 
     716        """Return a list of all genes that are involved with the production of enzyme.""" 
    700717        return self.api.get_genes_by_enzyme(enzyme_id, self.org) 
    701718 
    702719    def get_enzymes_by_gene(self, gene_id): 
     720        """Return a list of all enzymes that are a product of gene.""" 
    703721        return self.api.get_enzymes_by_gene(gene_id) 
    704722 
    705723    def get_unique_gene_ids(self, genes, caseSensitive=True): 
     724        """Return a tuple with three elements. The first is a dictionary mapping from unique gene 
     725        ids to gene names in genes, the second is a list of conflicting gene names and the third is a list 
     726        of unknown genes. 
     727        """ 
    706728        return self.api.get_unique_gene_ids(self.org, genes, caseSensitive) 
    707729 
     
    716738 
    717739    def get_image(self): 
     740        """Return an PIL image of the pathway.""" 
    718741        return self.api.get_pathway_image(self.pathway_id) 
    719742 
    720743    def get_colored_image(self, objects): 
     744        """Return an PIL image of the pathway with marked objects.""" 
    721745        return self.api.get_colored_pathway_image(self.pathway_id, objects) 
    722746 
    723747    def get_bounding_box(self, object_id): 
     748        """Return a bounding box of the form (x1, y1, x2, y2) of object on the pathway image.""" 
    724749        return self.api.get_bounding_box(self.pathway_id, object_id) 
    725750 
    726751    def get_bounding_box_dict(self): 
     752        """Return a dictionary mapping all objects on the pathways to bounding boxes (x1, y1, x2, y2) on the pathway image.""" 
    727753        return self.api.get_bounding_box_dict(self.pathway_id) 
    728754 
    729755    def get_genes(self): 
     756        """Return all genes on the pathway.""" 
    730757        return self.api.get_genes_by_pathway(self.pathway_id) 
    731758 
    732759    def get_enzymes(self): 
     760        """Return all enzymes on the pathway.""" 
    733761        return self.api.get_enzymes_by_pathway(self.pathway_id) 
    734762 
    735763    def get_compounds(self): 
     764        """Return all compounds on the pathway.""" 
    736765        return self.api.get_compounds_by_pathway(self.pathway_id) 
    737766         
Note: See TracChangeset for help on using the changeset viewer.