Skip to content

Commit

Permalink
resolves #397
Browse files Browse the repository at this point in the history
  • Loading branch information
MerktSimon committed Mar 20, 2020
1 parent 5632a11 commit 965e264
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 20 additions & 1 deletion petab/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import jsonschema
import yaml
from .C import * # noqa: F403
from . problem import get_default_condition_file_name, \
get_default_measurement_file_name, get_default_parameter_file_name, \
get_default_sbml_file_name


SCHEMA = os.path.join(os.path.abspath(os.path.dirname(__file__)),
Expand Down Expand Up @@ -159,4 +162,20 @@ def write_yaml(yaml_config: Dict[str, Any], filename: str) -> None:
"""

with open(filename, 'w') as outfile:
yaml.dump(yaml_config, outfile, default_flow_style=False)
yaml.dump(yaml_config, outfile, default_flow_style=False,
sort_keys=False)


def create_default_yaml(model_name):
yaml_dic = {"parameter_file": get_default_parameter_file_name(model_name),
"version": 1,
"problems": [{"condition_files": [
get_default_condition_file_name(model_name)],
"measurement_files": [
get_default_measurement_file_name(model_name)
],
"sbml_files": [get_default_sbml_file_name(
model_name)],
"observable_files": ['observables' +
model_name]}]}
write_yaml(yaml_dic, model_name + '.yaml')
6 changes: 5 additions & 1 deletion tests/test_yaml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test for petab.yaml"""

import pytest
from petab.yaml import validate
from petab.yaml import validate, create_default_yaml

from jsonschema.exceptions import ValidationError

Expand All @@ -18,3 +18,7 @@ def test_validate():
# should be well-formed
file_ = "doc/example/example_Fujita/Fujita.yaml"
validate(file_)


def test_create_default_yaml():
create_default_yaml('test')

0 comments on commit 965e264

Please sign in to comment.