config module

class mavis.config.CustomHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]

Bases: argparse.ArgumentDefaultsHelpFormatter

subclass the default help formatter to stop default printing for required arguments

class mavis.config.LibraryConfig(library, protocol, disease_status, bam_file=None, inputs=None, read_length=None, median_fragment_size=None, stdev_fragment_size=None, strand_specific=False, strand_determining_read=2, **kwargs)[source]

Bases: mavis.constants.MavisNamespace

holds library specific configuration information

static build(library, protocol, bam_file, inputs, annotations=None, log=<function devnull>, distribution_fraction=0.98, sample_cap=3000, sample_bin_size=1000, sample_size=500, **kwargs)[source]

Builds a library config section and gathers the bam stats

flatten()[source]
is_trans()[source]
classmethod parse_args(*args)[source]
class mavis.config.MavisConfig(**kwargs)[source]

Bases: object

has_transcriptome()[source]
static read(filepath)[source]

reads the configuration settings from the configuration file

Parameters:filepath (str) – path to the input configuration file
Returns:list of Namespace: namespace arguments for each library
Return type:class
class mavis.config.RangeAppendAction(nmin=1, nmax=None, **kwargs)[source]

Bases: argparse.Action

allows an argument to accept a range of arguments

mavis.config.add_semi_optional_argument(argname, success_parser, failure_parser, help_msg='', metavar=None)[source]

for an argument tries to get the argument default from the environment variable

mavis.config.augment_parser(arguments, parser, semi_opt_parser=None, required=None)[source]

Adds options to the argument parser. Separate function to facilitate the pipeline steps all having a similar look/feel

mavis.config.cast_if_not_none(value, cast_type)[source]

cast a value to a given type unless it is None

Example

>>> cast_if_not_none('1', int)
1
>>> cast_if_not_none(None, int)
None
>>> cast_if_not_none('null', int)
None
>>> cast_if_not_none('', int)
None
>>> cast_if_not_none('none', int)
None
mavis.config.generate_config(parser, required, optional, log=<function devnull>)[source]
Parameters:
  • parser (argparse.ArgumentParser) – the main parser
  • required – the argparse required arguments group
  • optional – the argparse optional arguments group
mavis.config.get_metavar(arg_type)[source]

For a given argument type, returns the string to be used for the metavar argument in add_argument

Example

>>> get_metavar(bool)
'{True,False}'
mavis.config.validate_section(section, namespace, use_defaults=False)[source]

given a dictionary of values, returns a new dict with the values casted to their appropriate type or set to a default if the value was not given

mavis.config.write_config(filename, include_defaults=False, libraries=[], conversions={}, log=<function devnull>)[source]
Parameters:
  • filename (str) – path to the output file
  • include_defaults (bool) – True if default parameters should be written to the config, False otherwise
  • libraries (list of LibraryConfig) – library configuration sections
  • conversions (dict of list by str) – conversion commands by alias name
  • log (function) – function to pass output logging to