|
12 | 12 | from .. import v1, v2 |
13 | 13 | from ..v1 import Problem as ProblemV1 |
14 | 14 | from ..v1.yaml import get_path_prefix, load_yaml, validate, write_yaml |
15 | | -from ..v2.models import MODEL_TYPE_SBML |
16 | 15 | from ..versions import get_major_version |
| 16 | +from .models import MODEL_TYPE_SBML |
17 | 17 |
|
18 | 18 | __all__ = ["petab1to2"] |
19 | 19 |
|
@@ -67,13 +67,11 @@ def petab1to2(yaml_config: Path | str, output_dir: Path | str = None): |
67 | 67 | if v1.lint_problem(petab_problem): |
68 | 68 | raise ValueError("Provided PEtab problem does not pass linting.") |
69 | 69 |
|
| 70 | + output_dir = Path(output_dir) |
| 71 | + |
70 | 72 | # Update YAML file |
71 | 73 | new_yaml_config = _update_yaml(yaml_config) |
72 | 74 |
|
73 | | - # Write new YAML file |
74 | | - output_dir = Path(output_dir) |
75 | | - output_dir.mkdir(parents=True, exist_ok=True) |
76 | | - |
77 | 75 | # Update tables |
78 | 76 | # condition tables, observable tables, SBML files, parameter table: |
79 | 77 | # no changes - just copy |
@@ -179,10 +177,8 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str: |
179 | 177 | # add pre-eq condition id if not present or convert to string |
180 | 178 | # for simplicity |
181 | 179 | if v1.C.PREEQUILIBRATION_CONDITION_ID in measurement_df.columns: |
182 | | - measurement_df[ |
183 | | - v1.C.PREEQUILIBRATION_CONDITION_ID |
184 | | - ] = measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID].fillna( |
185 | | - "" |
| 180 | + measurement_df.fillna( |
| 181 | + {v1.C.PREEQUILIBRATION_CONDITION_ID: ""}, inplace=True |
186 | 182 | ) |
187 | 183 | else: |
188 | 184 | measurement_df[v1.C.PREEQUILIBRATION_CONDITION_ID] = "" |
@@ -223,6 +219,7 @@ def create_experiment_id(sim_cond_id: str, preeq_cond_id: str) -> str: |
223 | 219 | measurement_df, get_dest_path(measurement_file) |
224 | 220 | ) |
225 | 221 |
|
| 222 | + # Write new YAML file |
226 | 223 | new_yaml_file = output_dir / Path(yaml_file).name |
227 | 224 | write_yaml(new_yaml_config, new_yaml_file) |
228 | 225 |
|
|
0 commit comments