snakemake.common package
Subpackages
Submodules
snakemake.common.argparse module
- class snakemake.common.argparse.ArgumentDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]
Bases:
HelpFormatterHelp message formatter which adds default values to argument help.
Like argparse.ArgumentDefaultsHelpFormatter, but doesn’t print None/dataclasses._MISSING_TYPE/etc.
- class snakemake.common.argparse.ArgumentGroup(container, title=None, description=None, **kwargs)[source]
Bases:
_ArgumentGroup- add_argument(*args, parse_func=None, **kwargs)[source]
This method supports the same args as ArgumentParser.add_argument(..) as well as the additional args below.
- Parameters:
env_var – If set, the value of this environment variable will override any config file or default values for this arg (but can itself be overridden on the commandline). Also, if auto_env_var_prefix is set in the constructor, this env var name will be used instead of the automatic name.
is_config_file_arg – If True, this arg is treated as a config file path This provides an alternative way to specify config files in place of the ArgumentParser(fromfile_prefix_chars=..) mechanism. Default: False
is_write_out_config_file_arg – If True, this arg will be treated as a config file path, and, when it is specified, will cause configargparse to write all current commandline args to this file as config options and then exit. Default: False
- Returns:
the new argparse action
- Return type:
argparse.Action
- class snakemake.common.argparse.ArgumentParser(*args, **kwargs)[source]
Bases:
ArgumentParser- add_argument(*args, parse_func=None, **kwargs)[source]
This method supports the same args as ArgumentParser.add_argument(..) as well as the additional args below.
- Parameters:
env_var – If set, the value of this environment variable will override any config file or default values for this arg (but can itself be overridden on the commandline). Also, if auto_env_var_prefix is set in the constructor, this env var name will be used instead of the automatic name.
is_config_file_arg – If True, this arg is treated as a config file path This provides an alternative way to specify config files in place of the ArgumentParser(fromfile_prefix_chars=..) mechanism. Default: False
is_write_out_config_file_arg – If True, this arg will be treated as a config file path, and, when it is specified, will cause configargparse to write all current commandline args to this file as config options and then exit. Default: False
- Returns:
the new argparse action
- Return type:
argparse.Action
- add_argument_group(*args, **kwargs)[source]
- snakemake.common.argparse.register_parser_action(parse_func, kwargs)[source]
snakemake.common.configfile module
- snakemake.common.configfile.load_configfile(configpath)[source]
Loads a JSON or YAML configfile as a dict, then checks that it’s a dict.
snakemake.common.git module
- snakemake.common.git.get_git_root(path)[source]
- Parameters:
path – (str) Path a to a directory/file that is located inside the repo
- Returns:
path to the root folder for git repo
- snakemake.common.git.get_git_root_parent_directory(path, input_path)[source]
This function will recursively go through parent directories until a git repository is found or until no parent directories are left, in which case an error will be raised. This is needed when providing a path to a file/folder that is located on a branch/tag not currently checked out.
- Parameters:
path – (str) Path a to a directory that is located inside the repo
input_path – (str) origin path, used when raising WorkflowError
- Returns:
path to the root folder for git repo
- snakemake.common.git.git_content(git_file)[source]
This function will extract a file from a git repository, one located on the filesystem. The expected format is git+file:///path/to/your/repo/path_to_file@version
- Parameters:
env_file (str) – consist of path to repo, @, version, and file information Ex: git+file:///home/smeds/snakemake-wrappers/bio/fastqc/wrapper.py@0.19.3
- Returns:
file content or None if the expected format isn’t meet
- snakemake.common.git.split_git_path(path)[source]
snakemake.common.tbdstring module
- class snakemake.common.tbdstring.TBDString(_=None)[source]
Bases:
str
snakemake.common.typing module
snakemake.common.workdir_handler module
Module contents
- class snakemake.common.Gather[source]
Bases:
objectA namespace for gather to allow items to be accessed via dot notation.
- class snakemake.common.Rules[source]
Bases:
objectA namespace for rules so that they can be accessed via dot notation.
- class snakemake.common.Scatter[source]
Bases:
objectA namespace for scatter to allow items to be accessed via dot notation.
- snakemake.common.async_run(coroutine)[source]
Attaches to running event loop or creates a new one to execute a coroutine. .. seealso:
https://github.com/snakemake/snakemake/issues/1105 https://stackoverflow.com/a/65696398
- snakemake.common.bytesto(bytes, to, bsize=1024)[source]
convert bytes to megabytes. bytes to mb: bytesto(bytes, ‘m’) bytes to gb: bytesto(bytes, ‘g’ etc. From https://gist.github.com/shawnbutts/3906915
- snakemake.common.copy_permission_safe(src, dst)[source]
Copy a file to a given destination.
If destination exists, it is removed first in order to avoid permission issues when the destination permissions are tried to be applied to an already existing destination.
- snakemake.common.dict_to_key_value_args(some_dict, quote_str=True, repr_obj=False)[source]
- snakemake.common.expand_vars_and_user(value)[source]
- snakemake.common.get_appdirs()[source]
- snakemake.common.get_container_image()[source]
- snakemake.common.get_file_hash(filename, algorithm='sha256')[source]
find the SHA256 hash string of a file. We use this so that the user can choose to cache working directories in storage.
- snakemake.common.get_function_params(func)[source]
- snakemake.common.get_input_function_aux_params(func, candidate_params)[source]
- snakemake.common.get_last_stable_version()[source]
- snakemake.common.get_report_id(path)[source]
- Return type:
str
- snakemake.common.get_snakemake_searchpaths()[source]
- snakemake.common.get_uuid(name)[source]
- snakemake.common.group_into_chunks(n, iterable)[source]
Group iterable into chunks of size at most n.
- snakemake.common.is_local_file(path_or_uri)[source]
- snakemake.common.is_namedtuple_instance(x)[source]
- snakemake.common.log_location(msg)[source]
- snakemake.common.mb_to_mib(mb)[source]
- snakemake.common.num_if_possible(s)[source]
Convert string to number if possible, otherwise return string.
- snakemake.common.overwrite_function_params(func, params)[source]
Force function params to be the given list. Useful for functions that use *args to get all parameters in dynamically created cases like in snakemake.ioutils.subpath.subpath.
- snakemake.common.parse_key_value_arg(arg, errmsg, strip_quotes=True)[source]
- snakemake.common.parse_uri(path_or_uri)[source]
- snakemake.common.set_env(**environ)[source]
Temporarily set the process environment variables.
>>> with set_env(PLUGINS_DIR='test/plugins'): ... "PLUGINS_DIR" in os.environ True>>> "PLUGINS_DIR" in os.environ False- Parameters:
environ (Dict[str, unicode]) – Environment variables to set
- snakemake.common.smart_join(base, path, abspath=False)[source]
- snakemake.common.strip_prefix(text, prefix)[source]
- snakemake.common.unique_justseen(iterable, key=None)[source]
List unique elements, preserving order. Remember only the element just seen.
From https://docs.python.org/3/library/itertools.html#itertools-recipes