Skip to content

module utils

ZARP-cli utilities.

Global Variables

  • columns_zarp_path

function generate_id

generate_id(length: int = 6)  str

Generate random string.

Args:

  • length: Length of string to generate.

Returns: Random string of specified length, composed of uppercase ASCII characters and digits.


function list_get

list_get(_list: Sequence[Any], index: int, default: Any = None)  Any

Get an item from a list by index or return a default value.

Args:

  • _list: List from which to return item.
  • index: Index of item to return.
  • default: Default value to return if index is out of range.

function remove_none

remove_none(obj: Any)  Dict

Remove None values from a (nested) dictionary.

Args:

  • obj: Dictionary object to remove None values from.

Returns: Object with None values removed if obj is a dictionary, else obj is returned unmodified.


function resolve_paths

resolve_paths(
    df: DataFrame,
    anchor: Path = PosixPath('/home/runner/work/zarp-cli/zarp-cli'),
    path_columns: Sequence = ('fq1', 'fq2', 'gtf', 'genome')
)  DataFrame

Resolve relative sample paths against a defined anchor.

Absolute paths and non-string or path-like objects are not modified.

Args:

  • df: Pandas DataFrame object.
  • anchor: Path to resolve sample paths relative to.
  • columns: Tuple of column names to resolve.

Returns: Pandas DataFrame object.


function sanitize_strings

sanitize_strings(value: Union[float, int, str])  str

Sanitize strings.

Convert numeric values to strings, replace spaces with underscores, and convert to lowercase.

Args:

  • value: Value to sanitize.

Returns: Sanitized string.

Raises:

  • TypeError: If value is not a string, float, or integer.