Model
- class glotaran.model.model.Model(*, clp_penalties=_Nothing.NOTHING, clp_constraints=_Nothing.NOTHING, clp_relations=_Nothing.NOTHING, dataset_groups: dict[str, DatasetGroupModel | Any] = _Nothing.NOTHING, dataset: dict[str, DatasetModel], megacomplex=_Nothing.NOTHING, weights=_Nothing.NOTHING)[source]
Bases:
object
A model for global target analysis.
Method generated by attrs for class Model.
Attributes Summary
Methods Summary
Get the model as dictionary.
Create model class.
Create model class for megacomplexes.
Generate parameters for the model.
Get the dataset groups.
Get issues.
Get all parameter labels.
Iterate the individual items.
Iterate items.
Create a Model instance from the specs defined in a file.
Format the model as Markdown string.
Check if the model is valid.
Get a string listing all issues in the model and missing parameters if specified.
Methods Documentation
- clp_constraints: list[ClpConstraint]
- clp_penalties: list[ClpPenalty]
- clp_relations: list[ClpRelation]
- classmethod create_class(attributes: dict[str, Attribute]) type[Model] [source]
Create model class.
- classmethod create_class_from_megacomplexes(megacomplexes: Iterable[type[Megacomplex]]) type[Model] [source]
Create model class for megacomplexes.
- dataset: dict[str, DatasetModel]
- dataset_groups: dict[str, DatasetGroupModel]
- generate_parameters() Parameters [source]
Generate parameters for the model.
- Returns:
Parameters – The generated parameters.
.. # noqa (D414)
- get_dataset_groups() dict[str, DatasetGroup] [source]
Get the dataset groups.
- Return type:
- Raises:
ModelError – Raised if a dataset group is unknown.
- get_issues(*, parameters: Parameters | None = None) list[ItemIssue] [source]
Get issues.
- Parameters:
parameters (Parameters | None) – The parameters.
- Return type:
list[ItemIssue]
- iterate_all_items() Generator[Item, None, None] [source]
Iterate the individual items.
- Yields:
Item – The individual item.
- iterate_items() Generator[tuple[str, dict[str, Item] | list[Item]], None, None] [source]
Iterate items.
- Yields:
tuple[str, dict[str, Item] | list[Item]] – The name of the item and the individual items of the type.
- loader(format_name: str | None = None, **kwargs: Any) Model
Create a Model instance from the specs defined in a file.
- Parameters:
file_name (StrOrPath) – File containing the model specs.
format_name (str) – Format the file is in, if not provided it will be inferred from the file extension.
**kwargs (Any) – Additional keyword arguments passes to the
load_model
implementation of the project io plugin.
- Returns:
Model instance created from the file.
- Return type:
- markdown(parameters: Parameters | None = None, initial_parameters: Parameters | None = None, base_heading_level: int = 1) MarkdownStr [source]
Format the model as Markdown string.
Parameters will be included if specified.
- Parameters:
parameters (Parameters | None) – Parameter to include.
initial_parameters (Parameters | None) – Initial values for the parameters.
base_heading_level (int) –
Base heading level of the markdown sections.
E.g.:
If it is 1 the string will start with ‘# Model’.
If it is 3 the string will start with ‘### Model’.
- Return type:
- valid(parameters: Parameters | None = None) bool [source]
Check if the model is valid.
- Parameters:
parameters (Parameters | None) – The parameters.
- Return type:
- validate(parameters: Parameters | None = None, raise_exception: bool = False) MarkdownStr [source]
Get a string listing all issues in the model and missing parameters if specified.
- Parameters:
parameters (Parameters | None) – The parameters.
raise_exception (bool) – Whether to raise an exception on failed validation.
- Return type:
- Raises:
ModelError – Raised if validation fails and raise_exception is true.