actio_python_utils.utils

Functions

cast_chromosome_to_int(chromosome)

Cast a chromosome string, optionally prefixed with chr, to an integer.

check_valid_output_directory(output_directory)

Check if the given directory is valid for outputting.

coalesce(*args)

Return the first argument that is not None

debug(func)

Wraps a function to output the function signature, run the function, output the return value, and return the return value.

extract_excel_sheet(fn, output_fn[, sheet, ...])

Extract a sheet from an Excel spreadsheet.

flatten_cfg(key[, d, sep])

Flatten a nested value in a dict

get_csv_fields(fn[, sep, sanitize, ...])

Get the column names from the first line of the specified file and optionally replaces an arbitrary sequence of strings to others

open_bz2(filename[, mode, buff, external])

Return a file handle to filename using pbzip2, bzip2, or b2 module

open_gz(filename[, mode, buff, external])

Return a file handle to filename using pigz, gzip, or gzip module

open_pipe(command[, mode, buff])

Runs a subprocess.Popen and either retains input or output

open_xz(filename[, mode, buff, external])

Return a file handle to filename using either xz or lzma module

rename_dict_keys(original_dict, renames)

Returns a new dict that's a copy of the supplied dict but with an arbitrary number of keys renamed

sync_to_s3(dir_name, s3_path)

Syncs a directory to specific S3 bucket/path.

timer(func)

Wraps a function to output the running time of function calls.

which(program)

type program:

str

zopen(filename[, mode, buff, external])

Open pipe, zipped, or unzipped file automagically

Classes

CustomCSVDialect()

DictToFunc(choices)

Class that after initializing with a dict can be called to map keys to values, e.g..

NumericValue([min_value, max_value, ...])

Creates a class that can be used as a function to verify that a passed argument is a numeric value of the correct type and in the expected range