Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PEtab 2.0 draft #554

Merged
merged 15 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/petab-extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

name: PEtab Extension
about: Suggest a new extension for PEtab core
title: ''
labels: file format
assignees: ''

---

**Name of the Extension**
Please make sure that the extension name matches the regular expression `^[a-zA-Z_][\w-]*$`.

**Which problem would you like to address?**
A clear and concise description of which use case you want to address and, if applicable, why the current specifications do not fulfill your requirements.

**Describe the solution you would like**
A clear and concise description of the changes you want to propose. Please describe any additional fields / files you would want to add, including allowed inputs and implications.

**Describe why this should not be implemented by changes to PEtab core**
A clear and concise description in what way the proposed changes introduce features that are orthogonal to the PEtab core specification.

**List the extension library that implements validation checks**
A link to the website or github repository that accompanies the proposed extension.

**List the toolboxes that support the proposed standard**
A link to the website or github repository that contains the software that implements support for the standard.
1 change: 1 addition & 0 deletions .rtd_pip_reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
urllib3==2.2.1
wheel==0.43.0
sphinx-reredirects==0.1.4
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ available at https://github.com/PEtab-dev/libpetab-python/.
* Update tutorial.rst (#512)
* Update how-to-cite (Closes #432) (#509)

## 0.2 series

### 0.2.0

* Specify how PEtab functionality can be expanded through extensions.
* YAML files are now required for the specification of PEtab problems
dweindl marked this conversation as resolved.
Show resolved Hide resolved

## 0.1 series

### 0.1.14
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ will have to:

1. Create a parameter table.

1. Create a yaml file that lists the model and all of the tables above.
dweindl marked this conversation as resolved.
Show resolved Hide resolved

If you are using Python, some handy functions of the
[PEtab library](https://github.com/PEtab-dev/libpetab-python/) can help
you with that. This includes also a PEtab validator called `petablint` which
Expand Down
73 changes: 62 additions & 11 deletions doc/_static/petab_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ description: PEtab parameter estimation problem config file schema
properties:

format_version:
type: integer
description: Version of the PEtab format (e.g. 1).
anyof:
- type: string
# (corresponding to PEP 440).
pattern: ^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$
- type: integer

description: Version of the PEtab format

parameter_file:
oneOf:
Expand All @@ -17,7 +22,6 @@ properties:
File name (absolute or relative) or URL to PEtab parameter table
containing parameters of all models listed in `problems`. A single
table may be split into multiple files and described as an array here.

problems:
type: array
description: |
Expand All @@ -34,13 +38,26 @@ properties:
files and optional visualization files.
properties:

sbml_files:
type: array
description: List of PEtab SBML files.

items:
type: string
description: PEtab SBML file name or URL.
model_files:
type: object
description: One or multiple models

# the model ID
patternProperties:
"^[a-zA-Z_]\\w*$":
type: object
properties:
location:
type: string
description: Model file name or URL
language:
type: string
description: |
Model language, e.g., 'sbml', 'cellml', 'bngl', 'pysb'
required:
- location
- language
additionalProperties: false

measurement_files:
type: array
Expand Down Expand Up @@ -74,12 +91,46 @@ properties:
type: string
description: PEtab visualization file name or URL.

mapping_files:
type: array
description: List of PEtab mapping files.

items:
type: string
description: PEtab mapping file name or URL.

required:
- sbml_files
- model_files
- observable_files
- measurement_files
- condition_files

extensions:
type: object
description: |
PEtab extensions being used.
patternProperties:
"^[a-zA-Z][\\-\\w]*$":

type: object
description: |
Information on a specific extension
properties:
version:
type: string
pattern: ^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$
required:
type: bool
description: |
Indicates whether the extension is required for the
mathematical interpretation of problem.
dweindl marked this conversation as resolved.
Show resolved Hide resolved
required:
- version
- required
additionalProperties: true

additionalProperties: false

required:
- format_version
- parameter_file
Expand Down
6 changes: 6 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'm2r2',
'sphinx.ext.autosummary',
'sphinx_markdown_tables',
'sphinx_reredirects',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -71,6 +72,11 @@
'.md': 'markdown',
}

# Redirects for moved files
redirects = {
"documentation_data_format": "v1/documentation_data_format.html",
}

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down
50 changes: 50 additions & 0 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,56 @@ Upon a new release, the PEtab editors ensure that
* the new version of the specifications is deposited at Zenodo
* the new release is announced on the PEtab mailing list

PEtab Extensions
----------------

An elaborate, monolithic format would make it difficult to understand and
implement support for PEtab, leading to a steep learning curve and discouraging
support in new toolboxes. To address this issue, the PEtab format is modular and
permits modifications through extensions that complement the core standard.
This modular specification evens the learning curve and provides toolbox
developers with more guidance on which features to implement to maximize
support for real world applications. Moreover, such modular extensions
facilitate and promote the use of specialized tools for specific, non-parameter
estimation tasks such as visualization.

Requirements for new extensions:

* Specifications in PEtab extensions take precedence over PEtab core, i.e., they
can ease or refine format restrictions imposed by PEtab core.
* PEtab extensions should extend PEtab core with new orthogonal features or
tasks, i.e., they should not make trivial changes to PEtab core.
* PEtab extensions must be named according to ^[a-zA-Z][\w\-]*$
dweindl marked this conversation as resolved.
Show resolved Hide resolved
* PEtab extensions must be versioned using semantic versioning.
* PEtab extensions required for interpretation of a problem specification must
be specified in the PEtab-YAML files
dweindl marked this conversation as resolved.
Show resolved Hide resolved
* There is at least one tool that supports the proposed extension
dweindl marked this conversation as resolved.
Show resolved Hide resolved
* The authors provide a library that provides test cases and implements
validation checks for the proposed format.
dweindl marked this conversation as resolved.
Show resolved Hide resolved

Developers are free to develop any PEtab extension. To become an official
PEtab extension, it needs to go through the following process.

#. The developers write a proposal describing the motivation and specification
of the extension, following the respective issue template provided in this
repository.
#. The proposal is submitted as an issue in this repository.
#. The technical specification and documentation of the extension is submitted
as a pull request in this repository that references the respective issue.
dweindl marked this conversation as resolved.
Show resolved Hide resolved

The PEtab editors jointly decide whether an extension meets the requirements
described here. In case of a positive evaluation, they announce a poll for the
acceptance as official extension to the PEtab forum. All members of the PEtab
community are eligible to vote. If at least 50% of the votes are in favor,
the extension is accepted and the respective pull requests with specifications,
documentation and test cases are merged. There is no quorum number of votes
Comment on lines +238 to +239
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there test cases for extensions here? This repo has no test cases, and earlier it is written that the extension should provided a library with test cases -- so that library would have already merged all PRs with test cases by now. A link to the library and test cases should be included in this repo though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there test cases for extensions here?

Probably not.

I think it still needs to be sorted out whether all test cases should go to https://github.com/PEtab-dev/petab_test_suite or to an extension-specific repository. Also for the specs --- here or separate repo. I would leave this as is for now.

for acceptance.

It is encouraged that extensions are informally discussed with the community
before initiating the process of becoming an official extension. Such
discussions can be conducted through the communication channels mentioned
above.

Versioning of the PEtab format
------------------------------

Expand Down
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:maxdepth: 3
:caption: Data format

Data format <documentation_data_format.rst>
PEtab v1 specs <v1/documentation_data_format.rst>
PEtab v2 draft <v2/documentation_data_format.rst>
tutorial

.. toctree::
Expand Down
13 changes: 13 additions & 0 deletions doc/src/Supported functions.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Function Comment Argument types Evaluates to
``pow(a, b)`` power function `b`-th power of `a` float, float float
``exp(x)`` exponential function pow(e, x);(`e` itself not a supported symbol,;but ``exp(1)`` can be used instead) float float
``sqrt(x)`` square root of ``x``;``pow(x, 0.5)`` float float
``log(a, b)``;``log(x)``;``ln(x)``;``log2(x)``;``log10(x)`` logarithm of ``a`` with base ``b``;``log(x, e)``;``log(x, e)``;``log(x, 2)``;``log(x, 10)``;(``log(0)`` is defined as ``-inf``);(NOTE: ``log`` without explicit;base is ``ln``, not ``log10``) float[, float] float
``sin``;``cos``;``tan``;``cot``;``sec``;``csc`` trigonometric functions float float
``arcsin``;``arccos``;``arctan``;``arccot``;``arcsec``;``arccsc`` inverse trigonometric functions float float
``sinh``;``cosh``;``tanh``;``coth``;``sech``;``csch`` hyperbolic functions float float
``arcsinh``;``arccosh``;``arctanh``;``arccoth``;``arcsech``;``arccsch`` inverse hyperbolic functions float float
``piecewise(``; ``true_value_1,``; ``condition_1,``; ``[true_value_2,``; ``condition_2,]``; ``[...]``; ``[true_value_n,``; ``condition_n,]``; ``otherwise``;``)`` The function value is;the ``true_value*`` for the;first ``true`` ``condition*``;or ``otherwise`` if all;conditions are ``false``. ``*value*``: all float or all bool;``condition*``: all bool float
``abs(x)`` absolute value;``piecewise(x, x>=0, -x)`` float float
``sign(x)`` sign of ``x``;``piecewise(1, x>=0, -1)`` float float
``min(a, b)``;``max(a, b)`` minimum / maximum of {``a``, ``b``};``piecewise(a, a<=b, b)``;``piecewise(a, a>=b, b)`` float, float float
93 changes: 93 additions & 0 deletions doc/src/update_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env python3

import pandas as pd
from pathlib import Path

doc_dir = Path(__file__).parent.parent
table_dir = Path(__file__).parent

MULTILINE_DELIMITER = ";"
tables = {
"Supported functions": {
"target": doc_dir / "documentation_data_format.rst",
"options": {
"header-rows": "1",
# "widths": "20 10 10 5",
},
},
}


def df_to_list_table(df, options, name):
columns = df.columns
table = f".. list-table:: {name}\n"
for option_id, option_value in options.items():
table += f" :{option_id}: {option_value}\n"
table += "\n"

first = True
for column in columns:
if first:
table += " * "
first = False
else:
table += " "
table += f"- | {column}\n"

for _, row in df.iterrows():
first = True
for column in columns:
cell = row[column]
if first:
table += " * "
first = False
else:
table += " "
table += "- "
if MULTILINE_DELIMITER in cell:
first_line = True
for line in cell.split(MULTILINE_DELIMITER):
if first_line:
table += "| "
first_line = False
else:
table += " | "
table += line
table += "\n"
else:
table += cell
table += "\n"

return table


def replace_text(filename, text, start, end):
with open(filename, "r") as f:
full_text0 = f.read()
before_start = full_text0.split(start)[0]
after_end = full_text0.split(end)[1]
full_text = (
before_start
+ start
+ text
+ end
+ after_end
)
with open(filename, "w") as f:
f.write(full_text)


DISCLAIMER = "(GENERATED, DO NOT EDIT, INSTEAD EDIT IN PEtab/doc/src)"


for table_id, table_data in tables.items():
target_file = table_data["target"]
options = table_data["options"]
df = pd.read_csv(table_dir/ f"{table_id}.tsv", sep="\t")
table = df_to_list_table(df, options=options, name=table_id)
replace_text(
filename=target_file,
text=table,
start=f"\n..\n START TABLE {table_id} {DISCLAIMER}\n",
end=f"\n..\n END TABLE {table_id}\n",
)
Loading