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)[source]

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) None[source]
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: MacsyDefaults, parsed_args: Namespace)[source]

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

__init__(defaults: MacsyDefaults, parsed_args: Namespace) None[source]

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

  • parsed_args – the command line arguments parsed

__weakref__

list of weak references to the object (if defined)

_config_file_2_dict(file: str) dict[slice(<class 'str'>, typing.Any, None)][source]

Parse a configuration file in ini format in dictionnary

Parameters:

file – path to the configuration file

Returns:

the parsed options

_set_command_line_config(parsed_args: Namespace) None[source]
Parameters:

parsed_args – the argument set on the command line

_set_db_type(value: Literal['gembase', 'ordered_replicon', 'unordered']) None[source]

set value for ‘db_type’ option

Parameters:

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

Raises:

ValueError – if value is not allowed

_set_default_config() None[source]

set the value comming from MacsyDefaults

_set_inter_gene_max_space(value: str) None[source]

set value for ‘inter_gene_max_space’ option

Parameters:

value – 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: str) None[source]
Parameters:

value

_set_max_nb_genes(value: str | Iterable[tuple[str, int]]) None[source]

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: str) None[source]

set value for ‘min_genes_required’ option

Parameters:

value – 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: str | Iterable[tuple[str, int]]) None[source]

set value for ‘min_mandatory_genes_required’ option

Parameters:

value – 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: str) None[source]

Set the options from the model package model_conf.xml file

Parameters:

model_conf_path – The path to the model_conf.xml file

_set_models(value: str | list[str, list[str]]) None[source]
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: str) None[source]
Parameters:

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

_set_multi_loci(value: str) None[source]
Parameters:

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

_set_no_cut_ga(value) None[source]
Parameters:

value

Returns:

Return type:

_set_options(options: dict[slice(<class 'str'>, typing.Any, None)]) None[source]

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: str) None[source]

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

Parameters:

prev_config_path

_set_project_config_file(config_path: str) None[source]

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

Parameters:

config_path – the path to the configuration file

_set_replicon_topology(value: Literal['linear', 'ciircular']) None[source]

set the default replicon topology

Parameters:

value – ‘circular’ or ‘linear’

_set_sequence_db(path: str) None[source]
Parameters:

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

_set_system_models_dir(value)[source]
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: str) None[source]

set the options from the system-wide configuration file

Parameters:

config_path

_set_topology_file(path: str) None[source]

test if the path exists and set it in config

Parameters:

path – the path to the topology file

_set_user_config_file(config_path: str) None[source]

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

Parameters:

config_path – The path to the configuration path

_set_user_wide_config(config_path: str) None[source]

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

Parameters:

config_path – The path to the ~/.macsyfinder/macsyfinder.conf

_str_2_tuple(value: str) list[tuple[str, str]][source]

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

Parameters:

value (str) – the string to parse

Returns:

[(model_fqn, value as str), …]

hit_weights() dict[slice(<class 'str'>, <class 'float'>, None)][source]
Returns:

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

Return type:

dict

hmmer_dir() str[source]
Returns:

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

inter_gene_max_space(model_fqn: str) int | None[source]
Parameters:

model_fqn – the model fully qualifed name

Returns:

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

log_level() int[source]
Returns:

the verbosity output level

Return type:

int

max_nb_genes(model_fqn: str) int | None[source]
Parameters:

model_fqn – the model fully qualifed name

Returns:

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

min_genes_required(model_fqn: str) int | None[source]
Parameters:

model_fqn – the model fully qualifed name

Returns:

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

min_mandatory_genes_required(model_fqn: str) int | None[source]
Parameters:

model_fqn – the model fully qualifed name

Returns:

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

models_dir() str | None[source]
Returns:

list of models dir path

Return type:

list of str

multi_loci(model_fqn: str) bool[source]
Parameters:

model_fqn (str) – the model fully qualified name

Returns:

True if the model is multi loci, False otherwise

Return type:

bool

out_dir() str[source]
Returns:

the path to the directory where the results are stored

save(path_or_buf: str | TextIO | None = None) None[source]

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() str[source]

alias to config.Config.out_dir()

NoneConfig

class macsypy.config.NoneConfig[source]

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

__weakref__

list of weak references to the object (if defined)