cytosnake.utils package#

Submodules#

cytosnake.utils.config_utils module#

Module: config_utils.py

config_uitls.py serves as a utility module, that manages configuration files within the CytoSnake workflow framework. This module offers an array of functions that aids in loading, parsing, and dynamic modification of configuration files.

cytosnake.utils.config_utils.load_configs(config_path: str | Path) dict#

Returns a dictionary of given configurations

Parameters:

config_path (str | Path) – path to config file

Returns:

configuration dictionary

Return type:

dict

Raises:

FileNotFoundError – raised if provided config file paths is invalid

cytosnake.utils.config_utils.load_cytosnake_configs() dict#

Loads in CytoSnake’s general configuration

Returns:

CytoSnake configs

Return type:

dict

cytosnake.utils.config_utils.load_data_path_configs()#

Returns path pointing where the data folder is

Returns:

Path to data folder in project directory

Return type:

Path

cytosnake.utils.config_utils.load_general_configs() dict#

Loads cytosnake’s general configurations

Returns:#

dict

dictionary containing the cytosnake general configs

cytosnake.utils.config_utils.load_meta_path_configs() dict#

Loads the metadata path from .cytosnake/_paths.yaml file

Returns:

meta path contents from the _paths.yaml file

Return type:

dict

cytosnake.utils.config_utils.load_workflow_path(wf_name: str) Path#

Loads in configurations and returns path pointing to workflow

Parameters:

wf_name (str) – workflow name

Returns:

Path to workflow

Return type:

pathlib.PosixPath

Raises:

WorkFlowNotFound – Raised if the desired workflow is not found.

cytosnake.utils.config_utils.load_workflow_paths_config() dict#
cytosnake.utils.config_utils.update_config(config_file_path: str | Path, new_key: str, new_value: str | Any, update: bool | None = False) None#

This updates config level in the upper level.

Parameters:
  • key (str) – key to add into the config

  • value (str | Number) – Value to add to the given key.

  • update (bool) – Update value to existing key

Raises:
  • ValueError – raised if the key value cannot be converted into a string

  • TypeError – raised if there is a type error with any parameter

  • FileNotFoundError – raised if the config file is not found

  • KeyError – raised if given key exists within the config file

cytosnake.utils.cyto_paths module#

module: cyto_paths.py

This module will contain functions that handles cytosnake’s pathing

cytosnake.utils.cyto_paths.get_benchmarks_path() Path#

Get the path to the benchmarks directory.

This function retrieves the path to the ‘benchmarks’ directory within the project root directory. If the directory does not exist, it will be created.

Returns:

The path to the ‘benchmarks’ directory.

Return type:

pathlib.Path

cytosnake.utils.cyto_paths.get_config_dir_path() Path#

Returns path to configuration folder

Returns:

Path to config directory

Return type:

Path

cytosnake.utils.cyto_paths.get_config_fpaths() dict#

Obtains all file paths located in the configs folder as a dictionary.

Returns:

structured dictionary with directory name and file paths as key value pairs

Return type:

dict

cytosnake.utils.cyto_paths.get_cytosnake_config_path() Path#

Returns absolute path to CytoSnake’s general config file .

Returns:

path to cytosnake general config file

Return type:

pathlib.Path

cytosnake.utils.cyto_paths.get_cytosnake_package_path() Path#

Returns paths where the package is installed

Returns:

Returns absolute path of where the package is installed

Return type:

Path

Raises:

FileNotFoundError – Raised if CytoSnake Package is not found

cytosnake.utils.cyto_paths.get_meta_path() Path#

returns meta path configurational file path.

Returns:

Path object pointing to _paths.yaml config file

Return type:

Path

cytosnake.utils.cyto_paths.get_project_dirpaths(args: Namespace) dict#

returns a dictionary containing directory name and path as key value pairs.

Parameters:

args (Namespace) – Uses argparse’s Namespace object to add additional information into the data section in _path.yaml

Returns:

directory name and path as key value pairs.

Return type:

dict

cytosnake.utils.cyto_paths.get_project_root() Path#

Returns complete path where cytosnake performs the analysis. The function will check if .cytosnake folder exists, if not an error will be raised.

Returns:

Returns absolute path of the project folder

Return type:

Path

Raises:

FileNotFoundError – Raised with the current directory is not a project folder

cytosnake.utils.cyto_paths.get_results_dir_path() Path#

Returns path to results directory. This is where all the outputs generated from the workflow will be placed.

Returns:

absolute path to results directory

Return type:

pathlib.Path

cytosnake.utils.cyto_paths.get_workflow_fpaths() dict#

Obtains all file paths located in the workflows folder as a dictionary.

Returns:

Structured dictionary containing directory names and paths are key value pairs

Return type:

dict

Raises:

FileNotFoundError – Raised if the file workflows directory is not found

cytosnake.utils.cyto_paths.is_cytosnake_dir(dir_path: str | Path | None = None) bool#

Checks if the current directory has been set up for cytosnake. Searches for the .cytosnake file in current or specified directory.

Parameters:

dir_path (Optional[str | Path]) – Path to directory. If None, current directory will be used. [Default=None]

Returns:

True if directory has been initialized for cytosnake, else False

Return type:

bool

cytosnake.utils.cytosnake_setup module#

Module: cytosnake_setup.py

This modules sets up the current directory as a project directory. Project directories are dictated by the presence of .cytosnake, which contains meta data for cytosnake to use.

cytosnake.utils.cytosnake_setup.create_cytosnake_dir() None#

Sets up a .cytosnake folder that contains meta information that helps cytosnake’s cli functionality. This will include configurations that contains states, paths and settings.

Returns:

  • None – Generates a .cytosnake file in current directory

  • Raises

  • FileExistsError – Raised by pathlib.Path if `.cytosnake’ already exists

cytosnake.utils.cytosnake_setup.generate_meta_path_configs(args: Namespace) None#

constructs a _paths.yaml file that contains the necessary path information for file handling. this allows cytosnake to know which folders to look for when performing tasks.

Returns:

creates a _paths.yaml file in the .cytosnake project directory

Return type:

none

cytosnake.utils.cytosnake_setup.setup_cytosnake_env(args: Namespace) None#

main wrapper function that sets up current directory into a cytosnake project directory. this means that all the analysis being conducted within the current directory will allow

cytosnake.utils.cytosnake_setup.transport_project_files() None#

obtains the necessary files from software package and transport them into current working directory

cytosnake.utils.feature_utils module#

cytosnake.utils.feature_utils.infer_dp_features(dp_profile) list[str]#

Returns a list of Deep profiler features found within the single cell dataframe

Parameters:

dp_profile (pd.DataFrame) – dataframe features captured from deep profiler

Returns:

list of deep profiler features

Return type:

list[str]

Raises:

ValueError – Raised if no Deep profiler features are found within the given DataFrame

cytosnake.utils.file_utils module#

Module: file_utils.py

Contains functions that involves file manipulations like:
  • searching

  • transferring

  • creating symbolic links

  • creating and deleting files

Returns a list of all the files inside a directory

Parameters:

fpath (str | Path) – path to specific directory

Returns:

Returns a list of dir names and file paths as key value pairs

Return type:

dict

cytosnake.utils.file_utils.find_project_dir(steps: int | None = 10) Path | None#

Recursively searches for project directory`.cytosnake` directory. If the directory is not found, None is returned.

steps: Optional[int]

number of recursive steps for searching. [default=10]

Returns:

  • Path – returns path to project folder

  • None – if the path is unable to be found

Raises:

FileNotFoundError – When recursive steps are exceeded and is unable to find .cytosnake folder

Module contents#