Snakeparse API

API

API Classes

Contents:

class snakeparse.api.SnakeParse(args: typing.List[str] = [], config: typing.Union[_ForwardRef('SnakeParseConfig'), NoneType] = None, debug: bool = False, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)

The main entry point for command-line parsing for Snakemake.

Keyword Arguments:
 
  • args -- The list of command line arguments. (-) –
  • config -- Optionally a SnakeParse configuration object. (-) –
  • prog -- Optionally the name of the tool-chain to display in the usage. (-) –
  • file -- Optionally the file to write any error or help messages, defaults to sys.stdout. (-) –
class snakeparse.api.SnakeParseConfig(config_path: typing.Union[pathlib.Path, NoneType] = None, prog: str = None, snakemake: pathlib.Path = None, name_transform=None, parent_dir_is_group_name: bool = True, workflows: typing.Dict[str, _ForwardRef('SnakeParseWorkflow')] = OrderedDict(), groups: typing.Dict[str, str] = OrderedDict(), snakefile_globs: typing.Union[typing.List[str], NoneType] = [])

The class used to configure SnakeParse.

Keyword Arguments:
 
  • config_path -- The path to the SnakeParse configuration file, in JSON, (-) – YAML, or HOCON format. Details of its contents are described below.
  • prog -- The name of the tool-chain. (-) –
  • snakemake -- the optional path to the Snakemake executable. (-) –
  • name_transform -- An optional method to transform the basename of a (-) – workflow’s snakefile to the canonical name to use on the command line.
  • parent_dir_is_group_name -- True to use the parent directory of the (-) – workflow’s snakefile as the workflow’s group name. Only applied when searching directories for snakefiles, or when group name is not explicitly given.
  • workflows -- optionally, the list of workflows as (-) – SnakeParseWorkflow objects.
  • groups - optionally, one or more key-value pairs, with the key being (-) – the canonical workflow group name, and the value being a description for that group to display on the command line.
  • snakefile_globs -- optionally, or more glob strings specifying (-) – where snakefile files can be found.

NB: the values in the configuration file take precedence over the keyword arguments. In particular, the configuration file may override Worfklows given in the ‘workflows’ keyword argument.

Configuration paths (in HOCON paths):

  • snakemake – the optional path to the Snakemake executable.
  • prog – the optional name of the tool-chain.
  • name_transform – alias for a built-in method to produce the
    workflow’s name (see the similarly named keyword argument). Either ‘snake_to_camel’ or ‘camel_to_snake’ for converting from Snake case to Camel case, or vice versa.
  • parent_dir_is_group_name – optional; see the similarly named
    keyword argument.
  • workflows – optionally, a list of configuration objects, one per
    workflow specified. They object key should be the canonical workflow name to be displayed on the command line, with a dictionary of key value pairs specifying the wofklow configuration with the same names as SnakeParseWorkflow (snakefile, group, and description). Only the snakefile key-value pair is required.
  • groups - optional; see the similarly named keyword argument.
  • snakefile_globs – optional; see the similarly named keyword argument.
class snakeparse.api.SnakeParseWorkflow(name: str, snakefile: pathlib.Path, group: typing.Union[str, NoneType] = None, description: typing.Union[str, NoneType] = None)

A container class for basic meta information about a workflow to be included on the command line.

Keyword Arguments:
 
  • name -- The canonical name of the workflow displayed on the command (-) – line.
  • snakefile -- The path to the snakefile file. (-) –
  • group -- The name of the workflow group, used to group workflows on (-) – the command line.
  • description - A short description of the workflow, used when listing (-) – the workflows.
class snakeparse.api.SnakeParser(**kwargs)

The abstract base class for implementing the workflow specific argument parsing.

class snakeparse.api.SnakeArgumentParser(**kwargs)

The abstract base class to help argument parsers that use python’s argparse module. Keyword arguments will be passed to the argument parser’s constructor.

class snakeparse.api.SnakeParseException

The exception raised by classes in this module.