KEGG¶
This module contains the methods to convert a KEGG RDF network into a BELGraph.
-
pathme.kegg.convert_to_bel.
kegg_to_bel
(path, hgnc_manager, chebi_manager, flatten=False)[source]¶ Convert KGML file to a BELGraph.
-
pathme.kegg.convert_to_bel.
kegg_to_pickles
(resource_files, resource_folder, hgnc_manager, chebi_manager, flatten=None, export_folder=None)[source]¶ Export WikiPathways to Pickles.
This module contains functions to parse KGML files.
-
pathme.kegg.kegg_xml_parser.
log
= <Logger pathme.kegg.kegg_xml_parser (WARNING)>[source]¶ Import XML
-
pathme.kegg.kegg_xml_parser.
import_xml_etree
(filename)[source]¶ Return XML tree from KGML file.
- Parameters
filename (str) – path to KGML file
- Returns
XML Tree
- Return type
-
pathme.kegg.kegg_xml_parser.
get_entity_nodes
(tree, hgnc_manager, chebi_manager)[source]¶ Find entry elements (KEGG pathway nodes) in XML.
- Parameters
tree (xml.etree.ElementTree.ElementTree) – XML tree
hgnc_manager (bio2bel_hgnc.Manager) – HGNC Manager
chebi_manager (bio2bel_chebi.Manager) – ChEBI Manager
- Returns
genes with corresponding metadata (entry_id: [kegg_id, HGNC, UniProt])
- Returns
compounds with corresponding metadata (entry_id: [compound_name, ChEBI])
- Returns
biological processes with corresponding metadata (entry_id: [kegg_id, map_name])
- Returns
orthologs with corresponding metadata (entry_id: [kegg_id, kegg_type])
- Return type
-
pathme.kegg.kegg_xml_parser.
get_complex_components
(tree, genes_dict, flattened=False)[source]¶ Get complex components to either construct complex or flatten relationships.
- Parameters
tree (xml.etree.ElementTree.ElementTree) – XML tree
genes_dict (dict) – dictionary of all genes in pathway
flattened (bool) – True to flatten all complex participants
- Returns
dictionary of complex IDs and component IDs (complex_id: [component_ids])
- Returns
flattened dictionary of complex IDs and component metadata (complex_ids: [metadata_dict])
- Return type
-
pathme.kegg.kegg_xml_parser.
get_xml_types
(tree)[source]¶ Find entity and interaction types in KEGG XML.
- Parameters
tree (xml.etree.ElementTree.ElementTree) – XML tree
- Returns
count of all entity, relation and reaction types present in XML
- Return type
-
pathme.kegg.kegg_xml_parser.
get_all_relationships
(tree)[source]¶ Find all relationships between 2 entities.
- Parameters
tree (xml.etree.ElementTree.ElementTree) – XML tree
- Returns
relationships list [(relation_entry1, relation_entry2, relation_subtype)]
- Return type
-
pathme.kegg.kegg_xml_parser.
get_all_reactions
(tree, compounds_dict)[source]¶ Get substrates and products with ChEBI or PubChem IDs participating in reactions.
- Parameters
tree (xml.etree.ElementTree.ElementTree) – XML tree
compounds_dict (dict) – dictionary of KEGG compound information
- Returns
dictionary with substrate ids (reaction_id: [substrate_ids])
- Returns
dictionary with product ids (reaction_id: [product_ids])
- Return type
-
pathme.kegg.kegg_xml_parser.
get_reaction_pathway_edges
(xml_tree, substrates_dict, products_dict)[source]¶ Get reaction edges.
- Parameters
xml_tree (xml.etree.ElementTree.ElementTree) – xml tree
substrates_dict (dict) – dictionary with substrate info
products_dict (dict) – dictionary with product info
- Returns
dictionary of reaction elements (reaction_id: [(substrate_id, product_id, reaction_type)])
- Return type
This module has utilities method for parsing and handling KEGG KGML files.
-
pathme.kegg.utils.
get_kegg_pathway_ids
(connection=None)[source]¶ Return a list of all pathway identifiers stored in the KEGG database.
-
pathme.kegg.utils.
download_kgml_files
(kegg_pathway_ids)[source]¶ Download KEGG KGML files by querying the KEGG API.
- Parameters
kegg_pathway_ids (list) – list of kegg ids
-
pathme.kegg.utils.
get_kegg_statistics
(path, hgnc_manager, chebi_manager, flatten=None)[source]¶ Parse a folder and get KEGG statistics.
- Parameters
graph – path
hgnc_manager (bio2bel_hgnc.Manager) – HGNC manager
chebi_manager (bio2bel_chebi.Manager) – ChEBI manager
path (str) – path to folder containing XML files
- Returns
KEGG KGML file and BEL graph statistics
- Return type
pandas.DataFrame