model.provenance¶
The record of what was derived from a model.
sbmlsim writes models which are derived from the model of a problem: the
model with the compiled networks of a hybrid problem
(sbmlsim.sciml.compiler.compile_network) and the model with the observables
which are formulas (sbmlsim.fit.petab_v2.observables.add_observables). A fit
simulates the derived model, an export writes the model the problem was
defined with. The derived model therefore carries what was added to it, as an
element of the annotation of the model in the namespace NAMESPACE:
<derived xmlns="https://github.com/matthiaskoenig/sbmlsim/derived" source="lv.xml">
<created>net1__layer1__weight__0_0 net1__output0__0</created>
<target id="gamma" constant="true"/>
</derived>
created lists the parameters which were added, with their rules, and
target lists the parameters of the source which got a rule, with the value
of constant they had. strip_derivation undoes both, which gives the source
model. A derivation of a derived model extends the record, so the source is
always the model the problem was defined with.
The element is added to the annotation of the model in place: libsbml checks
an annotation it is given as a whole against the metaid of the model, and
the RDF annotation of a model of the wild does not always have one.
Derivation
dataclass
¶
What was added to a model.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
str
|
name of the file of the model the derivation started from. |
created |
tuple[str, ...]
|
ids of the parameters which were added, in the order they were added; a rule of such a parameter was added with it. |
targets |
tuple[tuple[str, bool], ...]
|
the parameters of the source which got a rule, as pairs of
the id and whether it was constant before, in the order they got
it; |
derivation_of
¶
Read the record of a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
the model. |
required |
Returns:
| Type | Description |
|---|---|
Derivation | None
|
The derivation, |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the record is not valid. |
record_derivation
¶
Write the record of a derivation into a model.
A record the model has is extended: the source stays, the created ids and the targets are added. A target which the earlier record created is a created id and not a target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
the derived model. |
required |
source
|
Path
|
the file of the model the derivation started from. |
required |
created
|
Iterable[str]
|
ids of the parameters which were added. |
required |
targets
|
Mapping[str, bool]
|
id of a parameter which got a rule -> whether it was constant. |
required |
Returns:
| Type | Description |
|---|---|
Derivation
|
The record which was written. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the record cannot be written. |
strip_derivation
¶
Undo the derivation of a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml_path
|
Path
|
the derived model. |
required |
Returns:
| Type | Description |
|---|---|
SBMLDocument
|
The document of the source model, i.e. the model without the |
Derivation
|
parameters and rules which were added and without the record, and |
tuple[SBMLDocument, Derivation]
|
the record. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model cannot be read, is not derived, a created parameter or a target is not in it, the rule of a target is not the one of the network, or the model refers to a created parameter outside of the parts the derivation wrote, i.e. it was changed by hand after the derivation. |