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

source_path

clp_penalties

clp_constraints

clp_relations

dataset_groups

dataset

megacomplex

weights

Methods Summary

as_dict

Get the model as dictionary.

create_class

Create model class.

create_class_from_megacomplexes

Create model class for megacomplexes.

generate_parameters

Generate parameters for the model.

get_dataset_groups

Get the dataset groups.

get_issues

Get issues.

get_parameter_labels

Get all parameter labels.

iterate_all_items

Iterate the individual items.

iterate_items

Iterate items.

loader

Create a Model instance from the specs defined in a file.

markdown

Format the model as Markdown string.

valid

Check if the model is valid.

validate

Get a string listing all issues in the model and missing parameters if specified.

Methods Documentation

as_dict() dict[source]

Get the model as dictionary.

Return type:

dict

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.

Parameters:

attributes (dict[str, Attribute]) – The model attributes.

Return type:

type[Model]

classmethod create_class_from_megacomplexes(megacomplexes: Iterable[type[Megacomplex]]) type[Model][source]

Create model class for megacomplexes.

Parameters:

megacomplexes (list[type[Megacomplex]]) – The megacomplexes.

Return type:

type[Model]

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:

dict[str, DatasetGroup]

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]

get_parameter_labels() set[str][source]

Get all parameter labels.

Return type:

set[str]

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:

Model

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:

MarkdownStr

megacomplex: dict[str, Megacomplex]
source_path: str | None
valid(parameters: Parameters | None = None) bool[source]

Check if the model is valid.

Parameters:

parameters (Parameters | None) – The parameters.

Return type:

bool

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:

MarkdownStr

Raises:

ModelError – Raised if validation fails and raise_exception is true.

weights: list[Weight]