rxnDB.data.processor

Classes

RxnDBProcessor

Functions

main()

Module Contents

class rxnDB.data.processor.RxnDBProcessor[source]
df: pandas.DataFrame
allow_empty: bool = False
color_palette: str = 'Alphabet'
_original_df: pandas.DataFrame
_uid_to_reactant_abbrevs_lookup: dict[str, set[str]]
_uid_to_product_abbrevs_lookup: dict[str, set[str]]
_phase_name_to_abbrev_lookup: dict[str, set[str]]
_phase_group_to_abbrev_lookup: dict[str, set[str]]
_phase_formula_to_abbrev_lookup: dict[str, set[str]]
_phase_abbrev_to_name_lookup: dict[str, set[str]]
_phase_abbrev_to_group_lookup: dict[str, set[str]]
_phase_abbrev_to_formula_lookup: dict[str, set[str]]
_grouped_phases_by_mode: dict[str, dict[str, set[str]]]
_reaction_groups: dict[str, int]
_color_map: dict[str, str]
__post_init__() None[source]

Initialize the processor and validate the DataFrame.

_precompute_phase_info() None[source]

Pre-compute phase information for faster filtering.

filter_by_reactants_and_product_abbrevs(reactant_abbrevs: list[str], product_abbrevs: list[str], method: str = 'and') pandas.DataFrame[source]

Filter by reactant_abbrevs and/or product_abbrevs. - If both reactants and products are provided, returns reactions matching criteria (intersection or union). - If only reactants are provided, returns reactions matching ANY of the reactants (union). - If only products are provided, returns reactions matching ANY of the products (union). - If neither is provided, returns the original dataframe.

filter_by_reactant_abbrevs(phase_abbrevs: list[str]) pandas.DataFrame[source]

Filter dataframe by reactant phase_abbrevs (union logic).

filter_by_product_abbrevs(phase_abbrevs: list[str]) pandas.DataFrame[source]

Filter dataframe by product phase_abbrevs (union logic).

filter_by_ids(unique_ids: list[str]) pandas.DataFrame[source]

Filter dataframe by unique IDs.

filter_by_type(types: list[str]) pandas.DataFrame[source]

Filter by specific types of data.

filter_by_plot_type(plot_type: str) pandas.DataFrame[source]

Filter by specific plot type.

get_unique_ids_from_phase_abbrevs(phase_abbrevs: list[str], lookup: dict[str, set[str]]) set[str][source]

Get all unique IDs matching any phase in the list.

get_reactant_abbrevs_from_ids(unique_ids: list[str]) set[str][source]

Get unique reactants associated with a list of reaction IDs.

get_product_abbrevs_from_ids(unique_ids: list[str]) set[str][source]

Get unique products associated with a list of reaction IDs.

get_phase_abbrev_from_name(name: str) set[str][source]
get_phase_abbrev_from_group(group: str) set[str][source]
get_phase_abbrev_from_formula(formula: str) set[str][source]
get_phase_name_from_abbrev(abbrev: str) set[str][source]

Get the common name of a phase from its abbreviation.

get_phase_formula_from_abbrev(abbrev: str) set[str][source]

Get the chemical formula of a phase from its abbreviation.

get_phase_group_from_abbrev(abbrev: str) set[str][source]

Get the mineral group of a phase from its abbreviation.

get_phase_info_from_abbrev(abbrev: str) dict[str, str | set][source]

Get all information about a phase from its abbreviation.

get_all_phase_info() dict[str, str | set][source]

Get a dictionary of all phases with their complete information.

get_reactant_info_from_unique_id(unique_id: str) list[dict[str, str | set]][source]

Get information about all reactants for a specific reaction ID.

get_product_info_from_unique_id(unique_id: str) list[dict[str, str | set]][source]

Get information about all products for a specific reaction ID.

get_reaction_info_from_unique_id(unique_id: str) dict[str, list[dict[str, str | set]]][source]

Get comprehensive information about all phases in a reaction.

get_all_group_names() list[str][source]

Get all groups names.

get_all_grouped_phases(display_mode: str) dict[str, list[str]][source]

Get all checkbox group phases based on the display mode.

get_grouped_phases(group: str, components: list[str], display_mode: str) list[str][source]

Get individual checkbox group phases based on the display mode.

_extract_elements(formula: str) set[str][source]
get_all_chemical_components() set[str][source]
_build_reaction_groups(method: str = 'or')[source]

Group reactions based on shared reactant_abbrevs AND product_abbrevs. Assigns each unique ID to a group number.

_build_color_map()[source]

Build a color map for reaction groups. Assigns a color to each unique group number.

_get_color_palette() list[str][source]

Get a color palette based on the specified name.

_get_color_from_reaction(unique_id: str) str[source]

Get the color for a specific unique ID.

add_color_keys(filtered_df: pandas.DataFrame) pandas.DataFrame[source]

Add color information to a filtered dataframe.

static get_group_id(group_name: str) str[source]

Reformats group id for in compatible format for shiny UI IDs.

static convert_P_to_kbar(row)[source]
static convert_P_to_gigapascal(row)[source]
static convert_T_to_kelvin(row)[source]
static convert_T_to_celcius(row)[source]
property phases: list[str]

Get a list of unique phase names from reactants and products.

property data: pandas.DataFrame
rxnDB.data.processor.main()[source]