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.

Parameters
  • path (str) – path to KGML file

  • hgnc_manager (bio2bel_hgnc.Manager) – HGNC manager

  • chebi_manager (bio2bel_chebi.Manager) – ChEBI manager

  • flatten (bool) – flat nodes

Return type

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.

Parameters
  • resource_files (iter[str]) – iterator with file names

  • resource_folder (str) – path folder

  • export_folder (Optional[str]) – export folder

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

xml.etree.ElementTree.ElementTree

pathme.kegg.kegg_xml_parser.get_entity_nodes(tree, hgnc_manager, chebi_manager)[source]

Find entry elements (KEGG pathway nodes) in XML.

Parameters
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

dict[str,str]

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
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

dict[str,list]

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

dict[str,int]

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

list[tuple]

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
Returns

dictionary with substrate ids (reaction_id: [substrate_ids])

Returns

dictionary with product ids (reaction_id: [product_ids])

Return type

dict[str,list]

pathme.kegg.kegg_xml_parser.get_reaction_pathway_edges(xml_tree, substrates_dict, products_dict)[source]

Get reaction edges.

Parameters
Returns

dictionary of reaction elements (reaction_id: [(substrate_id, product_id, reaction_type)])

Return type

dict[str,list]

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.

Parameters

connection (Optional[str]) – connection to the database

Returns

list of all kegg_pathway_ids

Return type

list

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