HMDB Parsing
pdb.parse_hmdb_xml
Parses a large HMDB XML file efficiently using iterparse and extracts key metabolite data and associated protein/gene information into a DataFrame.
| Parameter | Type | Default | Description |
|---|---|---|---|
filename |
str | The path to the HMDB XML file (e.g., hmdb_metabolites.xml). | |
tag |
str | "metabolite" | The main element tag to parse. Should typically remain "metabolite". |
Returns
pd.DataFrame: A DataFrame containing metabolite information (e.g., accession, name, chebi_id) and lists of associated UniProt IDs and gene names (e.g., protein_associations_uniprot_id). Returns an empty DataFrame on failure.
Usage
hmdb_df = pdb.parse_hmdb_xml(filename="hmdb_metabolites.xml")
pdb.extract_hmdb_relations
Extracts the three major network relationship types (Gene-Compound, Gene-Gene, and Compound-Compound) from the initial HMDB metabolite DataFrame. Relations are based on UniProt ID (Gene) and ChEBI ID (Compound).
| Parameter | Type | Description |
|---|---|---|
hmdb_df |
pd.DataFrame | A DataFrame generated from pdb.parse_hmdb_xml. |
Returns
Tuple[pd.DataFrame,pd.DataFrame,pd.DataFrame]: A tuple containing:
-
gene_compound_df: Gene-Compound relations (columns: ’gene’ (UniProt ID), ’compound’ (ChEBI ID)). -
gene_relation_df: Gene-Gene relations (genes sharing a compound) (columns: ’gene1’,’gene2’). -
compound_relation_df: Compound-Compound relations (compounds sharing a gene) (columns: ’compound1’,’compound2’).
Usage
gc_df, gg_df, cc_df = pdb.extract_hmdb_relations(hmdb_df=hmdb_metabolites_df)