Skip to content

Reactome SBML Parsing

These functions deal with parsing detailed Reactome data provided in the SBML (Systems Biology Markup Language) XML format.

pdb.parse_reactome_sbml

Parses a single Reactome SBML XML file to extract core pathway components: compartments, species (genes/compounds), and reactions. (Note: Relies on unlisted internal helper functions like _parse_reactome_compartments and _parse_reactome_species).

Parameter Type Description
xml_file_path str Path to the Reactome SBML file (e.g., ’R-HSA-123456.sbml’).

Returns

Tuple[Optional[pd.DataFrame],Optional[pd.DataFrame],Optional[pd.DataFrame]]: A tuple containing:

  1. df_compartments: DataFrame of cellular compartments.

  2. df_species: DataFrame of species, including $\text{ID}$s ($\text{UniProt}, \text{ChEBI}$) and compartment info.

  3. df_reactions: DataFrame of reactions, including reactants, products, and modifiers IDs.

Usage

df_comp, df_spec, df_rxn = pdb.parse_reactome_sbml(
    xml_file_path="./reactome_sbml/R-HSA-123456.sbml"
)

pdb.extract_reactome_relations

Infers Gene-Compound, Gene-Gene, and Compound-Compound relationships from the structured species and reactions DataFrames generated by pdb.parse_reactome_sbml.

Parameter Type Description
df_species pd.DataFrame DataFrame of species (genes/compounds) data from SBML parsing.
df_reactions pd.DataFrame DataFrame of reaction data from SBML parsing.

Returns

Tuple[pd.DataFrame,pd.DataFrame,pd.DataFrame]: A tuple containing:

  1. gene_compound_df: Gene-Compound relations (gene (UniProt), compound (ChEBI), compartment info).

  2. gene_relation_df: Gene-Gene relations (co-reaction and shared compound).

  3. compound_relation_df: Compound-Compound relations (co-reaction and shared gene).

Usage

gc_df, gg_df, cc_df = pdb.extract_reactome_relations(
    df_species=df_spec, 
    df_reactions=df_rxn
)

pdb.process_all_reactome_pathways

Iterates through all SBML files for a given species in a directory, parses each one, extracts relationships using pdb.extract_reactome_relations, and aggregates the results into three final, deduplicated relation DataFrames.

Parameter Type Default Description
species_code str None The Reactome species code (e.g., ’HSA’ for human). Required to filter files.
pathway_dir str None The directory containing the Reactome SBML files.

Returns

Tuple[pd.DataFrame,pd.DataFrame,pd.DataFrame]: A tuple containing the final, aggregated, and deduplicated DataFrames:

  1. all_gene_compound_df: All Gene-Compound relations.

  2. all_gene_relation_df: All Gene-Gene relations.

  3. all_compound_relation_df: All Compound-Compound relations.

Usage

final_gc, final_gg, final_cc = pdb.process_all_reactome_pathways(
    species_code="HSA", 
    pathway_dir="./reactome_sbml"
)