Skip to content

Commit bc0f8fd

Browse files
authored
Update README overview table automatically (#205)
1 parent 3154d27 commit bc0f8fd

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Contributions to the collection are very welcome. For this, please create a new
55

66
## Overview
77

8+
<!-- START OVERVIEW TABLE -->
89
| PEtab Problem ID | Conditions | Estimated Parameters | Events | Preequilibration | Postequilibration | Measurements | Observables | Noise distribution(s) | Species | References | SBML4Humans |
910
|:---------------------------------------------------------------------------------------------|-------------:|-----------------------:|---------:|-------------------:|--------------------:|---------------:|--------------:|:------------------------|----------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1011
| [Alkan_SciSignal2018](Benchmark-Models/Alkan_SciSignal2018/) | 73 | 56 | 0 | 0 | 0 | 1733 | 12 | normal | 36 | [\[1\]](http://identifiers.org/doi/10.1126/scisignal.aat0229) | [\[1\]](https://sbml4humans.de/model_url?url=https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/Alkan_SciSignal2018/model_Alkan_SciSignal2018.xml) |
@@ -39,7 +40,7 @@ Contributions to the collection are very welcome. For this, please create a new
3940
| [Weber_BMC2015](Benchmark-Models/Weber_BMC2015/) | 2 | 36 | 0 | 1 | 0 | 135 | 8 | normal | 7 | [\[1\]](http://identifiers.org/doi/10.1186/s12918-015-0147-1) | [\[1\]](https://sbml4humans.de/model_url?url=https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/Weber_BMC2015/model_Weber_BMC2015.xml) |
4041
| [Zhao_QuantBiol2020](Benchmark-Models/Zhao_QuantBiol2020/) | 7 | 28 | 0 | 0 | 0 | 82 | 1 | normal | 5 | [\[1\]](http://identifiers.org/pubmed/32219006) | [\[1\]](https://sbml4humans.de/model_url?url=https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/Zhao_QuantBiol2020/SBML_Zhao_QuantBiol2020.xml) |
4142
| [Zheng_PNAS2012](Benchmark-Models/Zheng_PNAS2012/) | 1 | 46 | 0 | 1 | 0 | 60 | 15 | normal | 15 | [\[1\]](http://identifiers.org/doi/10.1073/pnas.1201240109) | [\[1\]](https://sbml4humans.de/model_url?url=https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/Zheng_PNAS2012/model_Zheng_PNAS2012.xml) |
42-
43+
<!-- END OVERVIEW TABLE -->
4344

4445
## License
4546

scripts/_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from pathlib import Path
22

33

4-
benchmark_path = Path(__file__).parent.parent / 'Benchmark-Models'
4+
benchmark_path = Path(__file__).resolve().parent.parent / 'Benchmark-Models'
55
petab_yamls = {
66
petab_path.name: benchmark_path / petab_path.name / (petab_path.name + '.yaml')
77
for petab_path in benchmark_path.glob('*')
88
if petab_path.name != '.DS_Store'
99
}
1010
petab_yamls = {k: petab_yamls[k] for k in sorted(petab_yamls)}
11+
12+
readme_md = Path(__file__).resolve().parent.parent / "README.md"

scripts/overview.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pandas as pd
1010
import petab
1111

12-
from _helpers import petab_yamls
12+
from _helpers import petab_yamls, readme_md
1313

1414

1515
markdown_columns = {
@@ -145,8 +145,12 @@ def get_overview_table() -> pd.DataFrame:
145145
return df
146146

147147

148+
start_overview_table = '\n<!-- START OVERVIEW TABLE -->\n'
149+
end_overview_table = '\n<!-- END OVERVIEW TABLE -->\n'
150+
148151
def main(
149-
markdown: bool = False,
152+
markdown: bool = False,
153+
update_readme: bool = False,
150154
):
151155
df = get_overview_table()
152156
pd.options.display.width = 0
@@ -163,7 +167,23 @@ def main(
163167
)
164168
df.index.rename(markdown_columns[index_column], inplace=True)
165169
df.rename(columns=markdown_columns, inplace=True)
166-
print(df.to_markdown())
170+
markdown_overview = df.to_markdown()
171+
if update_readme:
172+
with open(readme_md, "r") as f:
173+
readme_content = f.read()
174+
before_table = readme_content.split(start_overview_table)[0]
175+
after_table = readme_content.split(end_overview_table)[1]
176+
new_readme_content = (
177+
before_table
178+
+ start_overview_table
179+
+ markdown_overview
180+
+ end_overview_table
181+
+ after_table
182+
)
183+
with open(readme_md, "w") as f:
184+
f.write(new_readme_content)
185+
else:
186+
print(markdown_overview)
167187
else:
168188
print(df)
169189

@@ -172,6 +192,10 @@ def main(
172192
import sys
173193

174194
markdown = False
195+
update_readme = False
175196
if '--markdown' in sys.argv:
176197
markdown = True
177-
main(markdown)
198+
if '--update' in sys.argv:
199+
markdown = True
200+
update_readme = True
201+
main(markdown=markdown, update_readme=update_readme)

0 commit comments

Comments
 (0)