|
| 1 | +import subprocess |
1 | 2 | import tempfile |
2 | 3 | from pathlib import Path |
3 | 4 |
|
@@ -651,3 +652,43 @@ def test_generate_path(): |
651 | 652 | else: |
652 | 653 | assert gp(Path("foo"), "/bar") == "/bar/foo" |
653 | 654 | assert gp("/foo", "bar") == "/foo" |
| 655 | + |
| 656 | + |
| 657 | +def test_petablint_v2(tmpdir): |
| 658 | + """Test petablint on a v2 problem.""" |
| 659 | + problem = Problem() |
| 660 | + problem.model = SbmlModel.from_antimony(""" |
| 661 | + model conversion |
| 662 | + species A, B; |
| 663 | + A = 10; |
| 664 | + B = 0; |
| 665 | + k1 = 1; |
| 666 | + k2 = 0.5; |
| 667 | + R1: A -> B; k1 * A; |
| 668 | + R2: B -> A; k2 * B; |
| 669 | + end |
| 670 | + """) |
| 671 | + problem.add_observable("obs_A", "A", noise_formula="sd_A") |
| 672 | + problem.add_parameter( |
| 673 | + "k1", estimate=True, lb=1e-5, ub=1e5, nominal_value=1 |
| 674 | + ) |
| 675 | + problem.add_parameter( |
| 676 | + "k2", estimate=True, lb=1e-5, ub=1e5, nominal_value=0.5 |
| 677 | + ) |
| 678 | + problem.add_parameter( |
| 679 | + "sd_A", estimate=True, lb=0.01, ub=10, nominal_value=1 |
| 680 | + ) |
| 681 | + problem.add_measurement( |
| 682 | + "obs_A", time=10, measurement=2.5, experiment_id="" |
| 683 | + ) |
| 684 | + assert problem.validate() == [] |
| 685 | + |
| 686 | + problem.config = ProblemConfig(filepath="problem.yaml") |
| 687 | + problem.models[0].rel_path = "model.xml" |
| 688 | + problem.parameter_tables[0].rel_path = "parameters.tsv" |
| 689 | + problem.observable_tables[0].rel_path = "observables.tsv" |
| 690 | + problem.measurement_tables[0].rel_path = "measurements.tsv" |
| 691 | + problem.to_files(Path(tmpdir)) |
| 692 | + |
| 693 | + result = subprocess.run(["petablint", str(Path(tmpdir, "problem.yaml"))]) # noqa: S603,S607 |
| 694 | + assert result.returncode == 0 |
0 commit comments