# configuration

Options to run MacSyFinder can be specified in a Configuration file. The API described below handles all configuration options for MacSyFinder.

The `macsypy.config.MacsyDefaults` hold the default values for macsyfinder whereas the `macsypy.config.Config` hold the values for a macsyfinder run.

## configuration API reference

## MacsyDefaults

class `macsypy.config.``MacsyDefaults`(**kwargs)

  Handle all default values for macsyfinder. the default values must be defined here, NOT in argument parser nor in config the argument parser or config must use a MacsyDefaults object

  `__init__`(**kwargs)
    Parameters

      kwargs – allow to overwrite a default value. It mainly used in unit tests

    To define a new default value just add an attribute with the default value

  `__weakref__`

    list of weak references to the object (if defined)

## Config

class `macsypy.config.``Config`(defaults, parsed_args)

  Handle configuration values for macsyfinder. This values come from default and ar superseded by the configuration files, then the command line settings.

  `__init__`(defaults, parsed_args)

    Store macsyfinder configuration options and propose an interface to access to them.

    The config object is populated in several steps, the rules of precedence are

    system wide conf < user home conf < model conf < (project conf | previous run) < command line

    system wide conf = etc/macsyfinder/macsyfinder.conf user home conf = ~/.macsyfinder/macsyfinder.conf model conf = model_conf.xml at the root of the model package project conf = macsyfinder.conf where the analysis is run previous run = macsyfinder.conf in previous run results dir command line = the options set on the command line

    Parameters

      - defaults (a `MacsyDefaults` object) –

      - parsed_args (a `argspace.Namescape` object) – the command line arguments parsed

  `__weakref__`

    list of weak references to the object (if defined)

  `_config_file_2_dict`(file)

    Parse a configuration file in ini format in dictionnary

    Parameters

      file (str) – path to the configuration file

    Returns

      the parsed options

    Return type

      dict

  `_set_command_line_config`(parsed_args)
    Parameters

      parsed_args (`argparse.Namespace` object.) – the argument set on the command line

  `_set_db_type`(value)

    set value for ‘db_type’ option

    Parameters

      value (str) – the value for db_type, allowed values are : ‘ordered_replicon’, ‘gembase’, ‘unordered’

    Raises

      ValueError – if value is not allowed

  `_set_default_config`()

    set the value comming from MacsyDefaults

  `_set_inter_gene_max_space`(value)

    set value for ‘inter_gene_max_space’ option

    Parameters

      value (str) – the string parse representing the model fully qualified name and it’s associated value and so on the model_fqn is a string, the associated value must be cast in int

    Raises

      ValueError – if value is not well formed

  `_set_log_level`(value)
    Parameters

      value –

    Returns

  `_set_max_nb_genes`(value)

    set value for ‘max_nb_genes’ option

    Parameters

      value (str) – the string parse representing the model fully qualified name and it’s associated value and so on the model_fqn is a string, the associated value must be cast in int

    Raises

      ValueError – if value is not well formed

  `_set_min_genes_required`(value)

    set value for ‘min_genes_required’ option

    Parameters

      value (str) – the string parse representing the model fully qualified name and it’s associated value and so on the model_fqn is a string, the associated value must be cast in int

    Raises

      ValueError – if value is not well formed

  `_set_min_mandatory_genes_required`(value)

    set value for ‘min_mandatory_genes_required’ option

    Parameters

      value (str) – the string parse representing the model fully qualified name and it’s associated value and so on the model_fqn is a string, the associated value must be cast in int

    Raises

      ValueError – if value is not well formed

  `_set_model_config`(model_conf_path)

    Set the options from the model package model_conf.xml file

    Parameters

      model_conf_path (str) – The path to the model_conf.xml file

  `_set_models`(value)
    Parameters

      value –

      The models to search as return by the command line parsing or the configuration files

      if value come from command_line

        [‘model1’, ‘def1’, ‘def2’, ‘def3’]

      if value come from config file

        [‘set_1’, ‘T9SS T3SS T4SS_typeI’)] [(model_family, [def_name1, …]), … ]

  `_set_models_dir`(path)
    Parameters

      path (str) – the path to the models (definitions + profiles) are stored.

  `_set_multi_loci`(value)
    Parameters

      value (str) – the models fqn list separated by comma of multi loc models

  `_set_options`(options)

    set key, value in the general config

    Parameters

      options (a dictionary with option name as keys and values as values) – the options to specify in general config

  `_set_previous_run_config`(prev_config_path)

    Set the options specified by the user on the command line via –previous-run

    Parameters

      prev_config_path –

  `_set_project_config_file`(config_path)

    Set the options from the macsyfinder.conf present in the current directory

    Parameters

      config_path (str) – the path to the configuration file

  `_set_replicon_topology`(value)

    set the default replicon topology

    Parameters

      value (str) – ‘circular’ or ‘linear’

  `_set_sequence_db`(path)
    Parameters

      path (str) – set the path to the sequence file (in fasta format) to analysed

  `_set_system_models_dir`(value)
    Parameters

      value (list of string or a single string) – the path of the models dir set by the system (vs set by the user)

    Returns

  `_set_system_wide_config`(config_path)

    set the options from the system wide configuration file

    Parameters

      config_path (str) –

  `_set_topology_file`(path)

    test if the path exists and set it in config

    Parameters

      path (str) – the path to the topology file

  `_set_user_config_file`(config_path)

    Set the options specified by the user on the command line via the –cfg-file option

    Parameters

      config_path (str) – The path to the configuration path

  `_set_user_wide_config`(config_path)

    Set the options from the ~/.macsyfinder/macsyfinder.conf file

    Parameters

      config_path (str) – The path to the ~/.macsyfinder/macsyfinder.conf

  `_str_2_tuple`(value)

    transform a string with syntax {model_fqn int} in list of tuple

    Parameters

      value (str) – the string to parse

    Returns

    Return type

      [(model_fqn, int), ..]

  `hit_weights`()
    Returns

      the options used in scoring systems (mandatory_weight, accessory_weight, itself_weight, exchangeable_weight, out_of_cluster_weight)

    Return type

      dict

  `hmmer_dir`()
    Returns

      The name of the directory containing the hmmsearch results (output, error, parsing)

  `inter_gene_max_space`(model_fqn)
    Parameters

      model_fqn (str) – the model fully qualifed name

    Returns

      the gene_max_space for the model_fqn or None if it’s does not specify

    Return type

      int or None

  `log_level`()
    Returns

      the verbosity output level

    Return type

      int

  `max_nb_genes`(model_fqn)
    Parameters

      model_fqn (str) – the model fully qualifed name

    Returns

      the max_nb_genes for the model_fqn or None if it’s does not specify

    Return type

      int or None

  `min_genes_required`(model_fqn)
    Parameters

      model_fqn (str) – the model fully qualifed name

    Returns

      the min_genes_required for the model_fqn or None if it’s does not specify

    Return type

      int or None

  `min_mandatory_genes_required`(model_fqn)
    Parameters

      model_fqn (str) – the model fully qualifed name

    Returns

      the min_mandatory_genes_required for the model_fqn or None if it’s does not specify

    Return type

      int or None

  `models_dir`()
    Returns

      list of models dir path

    Return type

      list of str

  `multi_loci`(model_fqn)
    Parameters

      model_fqn (str) – the model fully qualified name

    Returns

      True if the model is multi loci, False otherwise

    Return type

      bool

  `out_dir`()
    Returns

      the path to the directory where the results are stored

  `save`(path_or_buf=None)

    save itself in a file in ini format.

    Note

    the undefined options (set to None) are omitted

    Parameters

      path_or_buf (str or file like object) – where to serialize itself.

  `working_dir`()

    alias to `config.Config.out_dir()`

## NoneConfig

class `macsypy.config.``NoneConfig`

  Minimalist Config object just use in some special case wher config is require by api but not used for instance in `macsypy.package.Package`

  `__weakref__`

    list of weak references to the object (if defined)