registries¶
The registry manage the different location where macsyfinder can find models definitions and their associated profiles.
registries API reference¶
ModelRegistry¶
-
class
macsypy.registries.
ModelRegistry
[source]¶ scan canonical directories to register the different models available in global macsyfinder share data location (depending installation /usr/share/data/models) or can be overload with the location specify in the macsyfinder configuration (either in config file or command line)
-
__getitem__
(name)[source]¶ Parameters: name (string) – Returns: the model corresponding to name. Return type: ModelLocation
object.Raises: KeyError – if name does not match any ModelLocation registered.
-
__weakref__
¶ list of weak references to the object (if defined)
-
add
(model_loc)[source]¶ Parameters: model_loc ( ModelLocation
object) – the model location to add to the registry
-
models
()[source]¶ Returns: the list of models Return type: list of ModelLocation
object
-
ModelLocation¶
-
class
macsypy.registries.
ModelLocation
(path=None, profile_dir=None, def_dir=None, profile_suffix='.hmm', relative_path=False)[source]¶ Handle where are store Models. Models are organized in families and sub families. each family match to a ModelLocation. a ModelLocation contains the path toward the definitions and the paths to corresponding to the profiles.
-
__init__
(path=None, profile_dir=None, def_dir=None, profile_suffix='.hmm', relative_path=False)[source]¶ Parameters: - path (str) – if it’s an installed model, path is the absolute path to a model family. otherwise path is None, and profile_dir and def_dir must be specified.
- profile_dir (str) – the absolute path to the directory which contains the hmm profiles files.
- def_dir (str) – The absolute path to the directory which contains the models definitions (xml files) or submodels.
- profile_suffix (str) – the suffix of hmm files
- relative_path (bool) – True if you want to work with relative path, False to work with absolute path.
Raise: MacsypyError if path is set and profile_dir or def_dir is set
Raise: MacsypyError if profile_dir is set but not def_dir and vice versa
-
__weakref__
¶ list of weak references to the object (if defined)
-
_scan_definitions
(parent_def=None, def_path=None)[source]¶ Scan recursively the definitions tree on the file model and store them.
Parameters: - model_def (
DefinitionLocation
) – the current model definition to add new submodel location - def_path (string) – the absolute path to analyse
Returns: a definition location
Return type: DefinitionLocation
object- model_def (
-
_scan_profiles
(path, profile_suffix='.hmm', relative_path=False)[source]¶ Store all hmm profiles associated to the model
-
get_all_definitions
(root_def_name=None)[source]¶ Name root_def_name: The name of the root definition to get sub definitions. If root_def is None, return all definitions for this set of models Parameters: root_def_name – string Returns: the list of definitions or subdefinitions if root_def is specified for this model. Return type: list of macsypy.registries.DefinitionLocation
objectRaises: ValueError – if root_def_name does not match with any definitions
-
get_definition
(fqn)[source]¶ Parameters: fqn (string.) – the fully qualified name of the definition to retrieve. it’s complete path without extension. for instance for a file with path like this: models/TXSS/defintions/T3SS.xml the name is: TXSS/T3SS for models/CRISPR-Cas/definitions/typing/CAS.xml: the name is CRISPR-Cas/typing/CAS Returns: the definition corresponding to the given name. Return type: a DefinitionLocation
object.Raise: valueError if fqn does not match with any model definition.
-
get_definitions
()[source]¶ Returns: the list of the definitions of this modelLocation. It return the 1rst level only (not recursive). For recursive explorations see macsypy.registries.ModelLocation.get_all_definitions()
-
DefinitionLocation¶
-
class
macsypy.registries.
DefinitionLocation
(name=None, fqn=None, subdefinitions=None, path=None)[source]¶ Manage where definitions are stored. a Model is a xml definition and associated profiles. It has 3 attributes
name: the fully qualified definitions name like TXSS/T3SS or CRISPR-cas/Typing/Cas path: the absolute path to the definitions or set of definitions subdefinitions: the subdefintions if it exists
-
__init__
(name=None, fqn=None, subdefinitions=None, path=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
__weakref__
¶ list of weak references to the object (if defined)
-
add_subdefinition
(subdefinition)[source]¶ add new sub category of definitions to this definition
Parameters: subdefinition ( DefinitionLocation
object) – the new definition to add as subdefinition.
-
family_name
¶ Returns: the models family name which is the name of the package
-
split_def_name¶
-
macsypy.registries.
split_def_name
(fqn)[source]¶ Parameters: fqn (string) – the fully qualified de name of a DefinitionLocation object the follow the schema model_name/<def_name>*/def_name for instance CRISPR-Cas/typing/cas Returns: the list of components of the def path [‘CRISPR-Cas’, ‘typing’, ‘cas’] Return type: list of string
join_def_path¶
scan_models_dir¶
-
macsypy.registries.
scan_models_dir
(models_dir, profile_suffix='.hmm', relative_path=False)[source]¶ Parameters: - models_dir (str) – The path to the directory where are stored the models
- profile_suffix – the suffix of the hmm profiles
- relative_path – True if models_dir is relative false otherwise
Returns: the list of models in models_dir
Return type: