lipinet package

Submodules

lipinet.databases module

lipinet.databases.clean(df, name_of_resource, verbose=False)

Some of the data sources need specialised cleaning to make them nicer to work with.

lipinet.databases.download_and_load_data(filename, url, file_format='csv', compressed=False, sep=',', encoding='utf-8', verbose=False)

Checks if the specified file exists locally. If not, downloads it from the provided URL. Supports loading compressed files and handling different formats.

Parameters: - filename (str): The name of the file to be saved within the data directory. - url (str): The URL to download the file from if it’s not found locally. - file_format (str): The format of the file (‘json’ or ‘csv’). Defaults to ‘csv’. - compressed (bool): If True, expects the downloaded file to be in gzip format. Defaults to False. - sep (str): Separator to use if loading CSV/TSV data. Defaults to ‘,’. - encoding (str): Encoding to use for reading files. Defaults to ‘utf-8’. - verbose (bool): If True, prints additional information during the process. Defaults to False.

Returns: - data (DataFrame, dict, or list): The loaded data from the file, in the format specified.

lipinet.databases.get_prior_knowledge(name_of_resource, verbose=False)

lipinet.parse_swisslipids module

A standalone module that loads and processes SwissLipids data into a df_nodes using lipinet.

This module provides a helper function parse_swisslipids_data that can be imported into notebooks or other scripts. A thin wrapper in the main() function allows command-line execution.

lipinet.parse_swisslipids.main()

Thin wrapper for command-line execution.

lipinet.parse_swisslipids.parse_swisslipids_data(verbose=False)

Core function to process SwissLipids data and return nodes and edges dataframes.

Parameters:

verbose (bool) – If True, prints detailed output. Defaults to False.

Returns:

A dictionary with keys ‘df_nodes’ and ‘df_edges’.

Return type:

dict

lipinet.utils module

lipinet.utils.check_for_split_characters(df, delimiter='|')
lipinet.utils.create_nodedf_from_edgedf(edge_df, props=['layer', 'id'], cols=['layer', 'node_id'])
lipinet.utils.split_and_expand_large(df, split_col, delimiter, expand_cols)

Splits a column by a delimiter and expands specified columns for large DataFrames, handling None/NaN values.

Parameters: df (pd.DataFrame): The original DataFrame. split_col (str): The name of the column to split. delimiter (str): The delimiter to split the column by. expand_cols (list): List of column names to be expanded with the split column.

Returns: pd.DataFrame: A new DataFrame with the split and expanded rows.

Module contents