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 on installation /usr/share/data/models) or can be overloaded with the location specify in the macsyfinder configuration (either in config file or command line)
- __getitem__(name: str) ModelLocation [source]
- Parameters:
name –
- Returns:
the model corresponding to name.
- Raises:
KeyError – if name does not match any ModelLocation registered.
- __weakref__
list of weak references to the object (if defined)
- add(model_loc: ModelLocation) None [source]
- Parameters:
model_loc – the model location to add to the registry
- models() list[ModelLocation] [source]
- Returns:
the list of models
ModelLocation
- class macsypy.registries.ModelLocation(path: str | None = None, profile_suffix: str = '.hmm', relative_path: bool = False)[source]
Handle where are store Models. Models are organized in families and subfamilies. each family match to a ModelLocation. a ModelLocation contains the path toward the definitions and the paths to corresponding to the profiles.
- __eq__(other: ModelLocation) bool [source]
Return self==value.
- __gt__(other: ModelLocation) bool [source]
Return self>value.
- __hash__ = None
- __init__(path: str | None = None, profile_suffix: str = '.hmm', relative_path: bool = False) None [source]
- Parameters:
path – if it’s an installed model, path is the absolute path to a model family.
profile_suffix – the suffix of hmm files
relative_path – True if you want to work with relative path, False to work with absolute path.
- __lt__(other: ModelLocation) bool [source]
Return self<value.
- __weakref__
list of weak references to the object (if defined)
- _scan_definitions(parent_def: DefinitionLocation | None = None, def_path: str | None = None) DefinitionLocation [source]
Scan recursively the definitions tree on the file model and store them.
- Parameters:
parent_def – the current model definition to add new submodel location
def_path – the absolute path to analyse
- Returns:
a definition location
- _scan_profiles(path: str, profile_suffix: str = '.hmm', relative_path: bool = False) dict[slice(<class 'str'>, <class 'str'>, None)] [source]
Store all hmm profiles associated to the model
- Parameters:
path – the path to a directory containing hmm profiles
profile_suffix – the extension of hmm profile file
relative_path – True if the path is relative, False otherwise.
- Returns:
all profiles found in the path
- get_all_definitions(root_def_name: str | None = None) list[DefinitionLocation] [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
- Returns:
the list of definitions or subdefinitions if root_def is specified for this model.
- Raises:
ValueError – if root_def_name does not match with any definitions
- get_definition(fqn: str) DefinitionLocation [source]
- Parameters:
fqn – 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.
- Raise:
valueError if fqn does not match with any model definition.
- get_definitions() list[DefinitionLocation] [source]
- Returns:
the list of the definitions of this modelLocation. It returns the 1rst level only (not recursive). For recursive explorations see
macsypy.registries.ModelLocation.get_all_definitions()
- get_profile(name: str) str [source]
- Parameters:
name – the name of the profile to retrieve (without extension).
- Returns:
the absolute path of the hmm profile.
- Raise:
KeyError if name does not match with any profiles.
- get_profiles_names() list[str] [source]
- Returns:
The list of profiles name (without extension) for this model location
- property version: str
- Returns:
The version of the models
MetaDefLoc
DefinitionLocation
- class macsypy.registries.DefinitionLocation(name: str | None = None, fqn: str | None = None, subdefinitions: DefinitionLocation | None = None, path: str | None = 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 subdefinitions if it exists
- __eq__(other: DefinitionLocation) bool [source]
Return self==value.
- __gt__(other: DefinitionLocation) bool [source]
Return self>value.
- __init__(name: str | None = None, fqn: str | None = None, subdefinitions: DefinitionLocation | None = None, path: str | None = None) None [source]
- __lt__(other: DefinitionLocation) bool [source]
Return self<value.
- __weakref__
list of weak references to the object (if defined)
- add_subdefinition(subdefinition: DefinitionLocation) None [source]
add new sub category of definitions to this definition
- Parameters:
subdefinition – the new definition to add as subdefinition.
- all() list[DefinitionLocation] [source]
- Returns:
the definition and all recursively all subdefinitions
- property family_name: str
- Returns:
the models family name which is the name of the package
split_def_name
- macsypy.registries.split_def_name(fqn: str) list[str] [source]
- Parameters:
fqn – 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’]
join_def_path
scan_models_dir
- macsypy.registries.scan_models_dir(models_dir: str, profile_suffix: str = '.hmm', relative_path: bool = False) list[ModelLocation] [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: