API documentation

Convert YAML to SBML

Translate ODEs in the YAML format into SBML.

yaml2sbml.yaml2sbml.main()[source]

Command-Line Interface.

yaml2sbml.yaml2sbml.yaml2sbml(yaml_dir, sbml_dir, observables_as_assignments=False)[source]

Parse a YAML file with the specification of ODEs and write it to SBML.

SBML is written within this function. If observables_as_assignments=True, observables will be translated into parameter assignments of the form observable_<observable_id>.

Parameters
  • yaml_dir (str) – directory to the YAML file with the ODEs specification

  • sbml_dir (str) – directory to the SBML file to be written out

  • observables_as_assignments (bool) – indicates whether there should be parameter assignments of the form observable_<observable_id>.

Validate YAML file

yaml2sbml.validate_yaml(yaml_dir)[source]

Validate the syntax of the YAML file.

Parameters

yaml_dir (str) – path to YAML file to be validated

Returns

jsonschema.validate

Convert YAML to PEtab

yaml2sbml.yaml2petab(yaml_dir, output_dir, sbml_name, petab_yaml_name=None, measurement_table_name=None)[source]

Translate a YAML model into a PEtab model.

Takes a YAML file with the ODE specification, parses it, converts it into SBML format, and writes the SBML file. Further it translates the given information into PEtab tables.

If a petab_yaml_name is given, a YAML file is created, that organizes the PEtab problem. If additionally a measurement_table_file_name is specified, this file name is written into the created YAML file.

Parameters
  • yaml_dir (str) – path to the YAML file with the ODEs specification

  • output_dir (str) – path the output file(s) are be written out

  • sbml_name (str) – name of SBML model

  • petab_yaml_name (Optional[str]) – name of YAML organizing the PEtab problem.

  • measurement_table_name (Optional[str]) – Name of measurement table

Validate PEtab tables

yaml2sbml.validate_petab_tables(sbml_dir, output_dir)[source]

Validate the PEtab tables via petab.lint.

Throws an error if the PEtab tables do not follow the PEtab format standard.

Parameters
  • sbml_dir (str) – directory of the sbml

  • output_dir (str) – output directory for petab files

Raises

Errors are raised by lint, if PEtab files are invalid...

Model editor

class yaml2sbml.YamlModel[source]

Functionality to set up, edit, load and write yaml models.

add_assignment(assignment_id, formula, overwrite=False)[source]

Add assignment.

Overwrite an existing assignment with the same id, if overwrite==True.

Parameters
  • assignment_id (str) – str, function id

  • formula (str) – str, right hand side of assignment definition.

  • overwrite (bool) – bool, indicates if an existing assignment should be overwritten

add_condition(condition_id, condition_dict, overwrite=False, condition_name=None)[source]

Add condition condition_id.

Conditions are not represented inside an SBML and only play a role when generating a PEtab problem (see PEtabs condition table).

Overwrite an existing condition with the same id, if overwrite==True.

Parameters
  • condition_id (str) – str, condition id

  • condition_dict (dict) – dict, of the form {<parameter or state id>: <value>}. Corresponds to entries in the PEtab condition table. See details there.

  • overwrite (bool) – bool, indicates if an existing condition should be overwritten

  • condition_name (Optional[str]) – Condition name. Optional.

add_function(function_id, arguments, formula, overwrite=False)[source]

Add function.

Overwrite an existing function with the same id, if overwrite==True.

Parameters
  • function_id (str) – str, function id

  • arguments (str) – str, arguments, separated by a comma

  • formula (str) – str, right hand side of the function definition

  • overwrite (bool) – bool, indicates if an existing function should be overwritten

add_observable(observable_id, observable_formula, noise_formula, overwrite=False, observable_name=None, observable_transformation=None, noise_distribution=None)[source]

Add observable.

Observables are not represented inside an SBML and only play a role when generating a PEtab problem see PEtabs observable table).

Overwrite an existing observable with the same id, if overwrite==True.

Parameters
  • observable_id (str) – str, observable id

  • observable_formula (str) – str, formula of the observable function

  • noise_formula (str) – str, formula of the noise

  • overwrite (bool) – bool, indicates if an existing observable should be overwritten

  • observable_name (Optional[str]) – Observable name. Optional.

  • observable_transformation (Optional[str]) – Observable transformation (‘lin’/’log’/’log10’). Optional

add_ode(state_id, right_hand_side, initial_value, overwrite=False)[source]

Add state/ODE.

Overwrite an existing state/ODE with the same id, if overwrite==True.

Parameters
  • state_id (str) – str, state id

  • right_hand_side (Union[float, str]) – str or float, right hand side of the ODE.

  • initial_value (Union[float, str]) – str or float, initial value of the ODE at t=0

  • overwrite (bool) – bool, indicates if an existing state/ODE should be overwritten

add_parameter(parameter_id, overwrite=False, nominal_value=None, parameter_name=None, parameter_scale=None, lower_bound=None, upper_bound=None, estimate=None)[source]

Add a parameter.

Overwrite an existing parameter with the same id, if overwrite==True.

Parameters
  • parameter_id (str) – str, parameter id

  • overwrite (bool) – bool, indicates if an existing state/ODE should be overwritten

  • nominal_value (Optional[float]) – float, nominal value of the parameter.

  • parameter_name (Optional[str]) – str, name of parameter in PEtab parameter table, optional.

  • parameter_scale (Optional[str]) – str. scale of parameter in PEtab parameter table, optional.

  • lower_bound (Optional[float]) – float, lower bound of parameter in PEtab parameter table, optional.

  • upper_bound (Optional[float]) – float, upper bound of parameter in PEtab parameter table, optional.

  • estimate (Optional[int]) – int, estimate flag of parameter in PEtab parameter table, optional.

delete_assignment(assignment_id)[source]

Delete an assignment.

Raise a ValueError, if assignment does not exist.

delete_condition(condition_id)[source]

Delete a condition.

Raise a ValueError, if condition does not exist.

delete_function(function_id)[source]

Delete a function.

Raise a ValueError, if function does not exist.

delete_observable(observable_id)[source]

Delete an observable.

Raise a ValueError, if observable does not exist.

delete_ode(state_id)[source]

Delete a state + ODE.

Raise a ValueError, if state does not exist.

delete_parameter(parameter_id)[source]

Delete a parameter.

Raise a ValueError, if parameter does not exist.

delete_time()[source]

Delete time variable.

get_assignment_by_id(assignment_id)[source]

Return dict for corresponding assignment.

Raise a ValueError, if the assignment does not exist.

get_assignment_ids()[source]

Return a list with all assignment ids.

get_condition_by_id(condition_id)[source]

Return dict for corresponding condition.

Raise a ValueError, if the condition does not exist.

get_condition_ids()[source]

Return a list with all conditions ids.

get_function_by_id(function_id)[source]

Return dict for corresponding function.

Raise a ValueError, if the function does not exist.

get_function_ids()[source]

Return a list with all function ids.

get_observable_by_id(observable_id)[source]

Return dict for corresponding observable.

Raise a ValueError, if the observable does not exist.

get_observable_ids()[source]

Return a list with all observable ids.

get_ode_by_id(state_id)[source]

Return dict for corresponding ODE/state.

Raise a ValueError, if the ODE/state does not exist.

get_ode_ids()[source]

Return a list with all state ids.

get_parameter_by_id(parameter_id)[source]

Return dict for corresponding parameter.

Raise a `ValueError, if the parameter does not exist.

get_parameter_ids()[source]

Return a list with all parameter ids.

get_time()[source]

Get time variable.

is_set_time()[source]

Check whether there is a time variable.

static load_from_yaml(yaml_dir)[source]

Create a model instance from a YAML file.

Parameters

yaml_dir (str) – directory to the YAML file, that should be imported

Returns

new model

Return type

cls

set_time(time_variable)[source]

Set time variable.

validate_model()[source]

Validate the YAML model.

Raises

ValidationError

write_to_petab(output_dir, model_name, petab_yaml_name=None, measurement_table_name=None)[source]

Write the YamlModel as a PEtab problem.

Equivalent to calling `yaml2petab on the file produced by the YAML output.

If a `petab_yaml_name is given, a YAML file is created, that organizes the petab problem. If additionally a `measurement_table_file_name is specified, this file name is written into the created YAML file.

Parameters
  • output_dir (str) – path the output file(s) are be written out

  • model_name (str) – name of SBML model

  • petab_yaml_name (Optional[str]) – name of the YAML organizing the PEtab problem.

  • measurement_table_name (Optional[str]) – Name of measurement table

write_to_sbml(sbml_dir, overwrite=False)[source]

Write the model as an SBML file to the directory given in sbml_dir.

Parameters
  • sbml_dir (str) – path/file, where the sbml should be written

  • overwrite (bool) – Indicates, whether an existing yaml should be overwritten

Raises
write_to_yaml(yaml_dir, overwrite=False)[source]

Write the model to a YAML file given as yaml_dir.

Parameters
  • yaml_dir (str) – path/file, where the YAML should be written

  • overwrite (bool) – Indicates, whether an existing YAML should be overwritten

Raises