snaketool_utils

cli_utils.py

OrderedCommands

Bases: click.Group

This class will preserve the order of subcommands, which is useful when printing --help

copy_config(local_config, merge_config=None, system_config=None, log=None)

Copy a config file, optionally merging in new config values.

Parameters:
  • local_config (str) –

    Filepath of new config YAML for writing

  • merge_config (dict) –

    Config values for merging

  • system_config (str) –

    Filepath of original config YAML file for reading

  • log (str) –

    Filepath of log file for writing STDERR

echo_click(msg, log=None)

Print Error message to STDERR and copy to log file

Parameters:
  • msg (str) –

    Error message to print

  • log (srt) –

    Filepath to log file for writing

msg(err_message, log=None)

Format error message for printing

Parameters:
  • err_message (str) –

    Error message to print

  • log (str) –

    Filepath to log file for writing

msg_box(splash, errmsg=None, log=None)

Fancy formatting and multi-line error message for printing

Parameters:
  • splash (str) –

    Short splash message to appear in box

  • errmsg (str) –

    Long error message to print

  • log (str) –

    Filepath to log file for writing

read_config(file)

Read a config file to a dictionary

Parameters:
  • file (str) –

    Filepath to config YAML file for reading

Returns (dict): Config read from YAML file

recursive_merge_config(config, overwrite_config)

Recursively merge a dictionary.

This is required for updating/merging config dictionaries that are more than one level deep.

Parameters:
  • config (dict) –

    Config dictionary to overwrite (e.g. defaults)

  • overwrite_config (dict) –

    Config dictionary of new/updated values to add

run_snakemake(configfile=None, system_config=None, snakefile_path=None, merge_config=None, threads=1, use_conda=False, conda_prefix=None, snake_default=None, snake_args=[], profile=None, log=None, **kwargs)

Run a Snakefile!

Parameters:
  • configfile (str) –

    Filepath of config file to pass with --configfile

  • system_config (str) –

    Filepath of system config to copy if configfile not present

  • snakefile_path (str) –

    Filepath of Snakefile

  • merge_config (dict) –

    Config values to merge with your config file

  • threads (int) –

    Number of local threads to request

  • use_conda (bool) –

    Snakemake's --use-conda

  • conda_prefix (str) –

    Filepath for Snakemake's --conda-prefix

  • snake_default (list) –

    Snakemake args to pass to Snakemake

  • snake_args (list) –

    Additional args to pass to Snakemake

  • profile (str) –

    Name of Snakemake profile

  • log (str) –

    Log file for writing STDERR

  • **kwargs

Returns (int): Exit code

tuple_to_list(dictionary)

Convert click tuples to lists in (nested) dictionaries for safe dumping with pyyaml

Parameters:
  • dictionary (dict) –

    dictionary of config for Snakemake

Returns:
  • dictionary( dict ) –

    dictionary with tuples converted to lists

update_config(in_config=None, merge=None, output_config=None, log=None)

Update the default config with the new config values

Parameters:
  • in_config (str) –

    Filepath to YAML config file

  • merge (dict) –

    New values to merge into new config file

  • output_config (str) –

    Filepath to write new merged config YAML file

  • log (str) –

    Log file for writing STDERR

write_config(config, file, log=None)

Write the config dictionary to a YAML file

Parameters:
  • config (dict) –

    Dictionary of config values

  • file (str) –

    Filepath of config file for writing

  • log (str) –

    Filepath of log file for writing STDERR