phenopacket_mapper.utils package

This submodule contains utility functions that are used throughout the package.

class phenopacket_mapper.utils.NotebookBuilder[source]

Bases: object

A class to build a Jupyter notebook programmatically.

add_markdown_cell(text)[source]

Adds a Markdown cell to the notebook.

Parameters:

text – The Markdown content to be added to the cell.

add_code_cell(code)[source]

Adds a code cell to the notebook.

Parameters:

code – The Python code to be added to the cell.

write_to_file(path: Path)[source]

Writes the notebook content to a file.

Parameters:

path – The name of the file where the notebook will be saved.

phenopacket_mapper.utils.loc_default(df: DataFrame, row_index: int, column_name: str, default: Any = '') Any[source]

Safely performs loc on a pd.DataFrame, returns default value if something goes wrong

Parameters:
  • df – the dataframe

  • row_index – index of the row

  • column_name – name of the column

  • default – default value to return if some error occurs

Returns:

Value at the row and column specified

phenopacket_mapper.utils.str_to_valid_id(s: str) str[source]

Converts a string to a valid id

This function converts a string to a valid id by replacing spaces with underscores and removing all other non-alphanumeric characters.

Parameters:

s – The string to convert to a valid id

Returns:

The valid id

phenopacket_mapper.utils.recursive_dict_call(d: Dict, keys: List, default=None)[source]

Subpackages

Submodules