Skip to content

Commit

Permalink
Update README overview table automatically (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath authored Apr 17, 2024
1 parent 3154d27 commit bc0f8fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Contributions to the collection are very welcome. For this, please create a new

## Overview

<!-- START OVERVIEW TABLE -->
| PEtab Problem ID | Conditions | Estimated Parameters | Events | Preequilibration | Postequilibration | Measurements | Observables | Noise distribution(s) | Species | References | SBML4Humans |
|:---------------------------------------------------------------------------------------------|-------------:|-----------------------:|---------:|-------------------:|--------------------:|---------------:|--------------:|:------------------------|----------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [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) |
Expand Down Expand Up @@ -39,7 +40,7 @@ Contributions to the collection are very welcome. For this, please create a new
| [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) |
| [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) |
| [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) |

<!-- END OVERVIEW TABLE -->

## License

Expand Down
4 changes: 3 additions & 1 deletion scripts/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from pathlib import Path


benchmark_path = Path(__file__).parent.parent / 'Benchmark-Models'
benchmark_path = Path(__file__).resolve().parent.parent / 'Benchmark-Models'
petab_yamls = {
petab_path.name: benchmark_path / petab_path.name / (petab_path.name + '.yaml')
for petab_path in benchmark_path.glob('*')
if petab_path.name != '.DS_Store'
}
petab_yamls = {k: petab_yamls[k] for k in sorted(petab_yamls)}

readme_md = Path(__file__).resolve().parent.parent / "README.md"
32 changes: 28 additions & 4 deletions scripts/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pandas as pd
import petab

from _helpers import petab_yamls
from _helpers import petab_yamls, readme_md


markdown_columns = {
Expand Down Expand Up @@ -145,8 +145,12 @@ def get_overview_table() -> pd.DataFrame:
return df


start_overview_table = '\n<!-- START OVERVIEW TABLE -->\n'
end_overview_table = '\n<!-- END OVERVIEW TABLE -->\n'

def main(
markdown: bool = False,
markdown: bool = False,
update_readme: bool = False,
):
df = get_overview_table()
pd.options.display.width = 0
Expand All @@ -163,7 +167,23 @@ def main(
)
df.index.rename(markdown_columns[index_column], inplace=True)
df.rename(columns=markdown_columns, inplace=True)
print(df.to_markdown())
markdown_overview = df.to_markdown()
if update_readme:
with open(readme_md, "r") as f:
readme_content = f.read()
before_table = readme_content.split(start_overview_table)[0]
after_table = readme_content.split(end_overview_table)[1]
new_readme_content = (
before_table
+ start_overview_table
+ markdown_overview
+ end_overview_table
+ after_table
)
with open(readme_md, "w") as f:
f.write(new_readme_content)
else:
print(markdown_overview)
else:
print(df)

Expand All @@ -172,6 +192,10 @@ def main(
import sys

markdown = False
update_readme = False
if '--markdown' in sys.argv:
markdown = True
main(markdown)
if '--update' in sys.argv:
markdown = True
update_readme = True
main(markdown=markdown, update_readme=update_readme)

0 comments on commit bc0f8fd

Please sign in to comment.