Skip to content

Commit

Permalink
Merge branch 'develop' into fix_1422
Browse files Browse the repository at this point in the history
  • Loading branch information
paulstapor authored Mar 15, 2021
2 parents 1eaf0a8 + 37ef880 commit f76bccd
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 26 deletions.
47 changes: 33 additions & 14 deletions documentation/python_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,25 @@ the semantic
`SBML Test Suite <https://github.com/sbmlteam/sbml-test-suite/>`_
(`current status <https://github.com/AMICI-dev/AMICI/actions>`_).

The following SBML test tags are supported
The following SBML test suite tags are currently supported
(i.e., at least one test case with the respective test passes;
`tag descriptions <https://github.com/sbmlteam/sbml-test-suite/blob/master/docs/tags-documentation/all-tags.txt>`_):

**Component tags:**

* AssignmentRule
* Compartment
* CSymbolAvogadro
* CSymbolTime
* FunctionDefinition
* InitialAssignment
* Parameter
* RateRule
* Reaction
* Species

**Test tags:**

* 0D-Compartment
* Amount
* AssignedConstantStoichiometry
Expand Down Expand Up @@ -66,8 +81,6 @@ for details and progress):
- Events (currently Matlab-only) (`#757 <https://github.com/AMICI-dev/AMICI/issues/757>`_)
- Algebraic rules (`#760 <https://github.com/AMICI-dev/AMICI/issues/760>`_)

contributions are welcome.

However, the following features are unlikely to be supported:

- any SBML extensions
Expand Down Expand Up @@ -105,7 +118,7 @@ Importing plain ODEs

The AMICI Python interface does not currently support direct import of ODEs.
However, it is straightforward to encode them as RateRules in an SBML model.
The `yaml2sbml <https://github.com/martamatos/yaml2sbml>`_ package may come in
The `yaml2sbml <https://github.com/yaml2sbml-dev/yaml2sbml>`_ package may come in
handy, as it facilitates generating SBML models from a YAML-based specification
of an ODE model. Besides the SBML model it can also create
`PEtab <https://github.com/PEtab-dev/PEtab>`_ files.
Expand Down Expand Up @@ -140,21 +153,27 @@ OpenMP support for parallelized simulation for multiple experimental conditions
AMICI can be built with OpenMP support, which allows to parallelize model
simulations for multiple experimental conditions.

On Linux and OSX this is enabled by default. This can be verified using::
On Linux and OSX this is enabled by default. This can be verified using:

import amici
amici.compiledWithOpenMP()
.. code-block:: python
import amici
amici.compiledWithOpenMP()
If not already enabled by default, you can enable OpenMP support by setting
the environment variables ``AMICI_CXXFLAGS`` and ``AMICI_LDFLAGS`` to the
correct OpenMP flags of your compiler and linker, respectively. This has to be
done for both AMICI package installation *and* model compilation. When using
``gcc`` on Linux, this would be::
``gcc`` on Linux, this would be:

.. code-block:: bash
# on your shell:
AMICI_CXXFLAGS=-fopenmp AMICI_LDFLAGS=-fopenmp pip3 install amici
# on your shell:
AMICI_CXXFLAGS=-fopenmp AMICI_LDFLAGS=-fopenmp pip3 install amici
.. code-block:: python
# in python, before model compilation:
import os
os.environ['AMICI_CXXFLAGS'] = '-fopenmp'
os.environ['AMICI_LDFLAGS'] = '-fopenmp'
# in python, before model compilation:
import os
os.environ['AMICI_CXXFLAGS'] = '-fopenmp'
os.environ['AMICI_LDFLAGS'] = '-fopenmp'
18 changes: 13 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,21 @@ def pytest_sessionfinish(session, exitstatus):

def write_passed_tags(passed_ids, out=sys.stdout):
"""Write tags of passed SBML semantic test cases"""
passed_tags = set()
passed_component_tags = set()
passed_test_tags = set()

from testSBMLSuite import get_tags_for_test
for test_id in passed_ids:
passed_tags |= get_tags_for_test(test_id)

out.write("At least one test with the following tags has passed:\n")
out.write(' ' + '\n '.join(passed_tags))
cur_component_tags, cur_test_tags = get_tags_for_test(test_id)
passed_component_tags |= cur_component_tags
passed_test_tags |= cur_test_tags

out.write("\nAt least one test with the following component tags has "
"passed:\n")
out.write(' ' + '\n '.join(sorted(passed_component_tags)))
out.write("\n\nAt least one test with the following test tags has "
"passed:\n")
out.write(' ' + '\n '.join(sorted(passed_test_tags)))


def pytest_runtest_logreport(report: "TestReport") -> None:
Expand Down
27 changes: 20 additions & 7 deletions tests/testSBMLSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
import shutil
import sys
from typing import Tuple, Set

import amici
import libsbml as sbml
Expand Down Expand Up @@ -307,16 +308,28 @@ def format_test_id(test_id) -> str:
return test_str


def get_tags_for_test(test_id):
"""Get sbml test suite tags for the given test ID"""
def get_tags_for_test(test_id) -> Tuple[Set[str], Set[str]]:
"""Get sbml test suite tags for the given test ID
Returns:
Tuple of set of strings for componentTags and testTags
"""

current_test_path = os.path.join(TEST_PATH, test_id)
info_file = os.path.join(current_test_path, f'{test_id}-model.m')
with open(info_file) as f:
component_tags = set()
test_tags = set()
for line in f:
if line.startswith('testTags:'):
res = set(re.split(r'[ ,:]', line[len('testTags:'):].strip()))
res.discard('')
return res
print(f"No testTags found for test case {test_id}.")
return set()
test_tags = set(
re.split(r'[ ,:]', line[len('testTags:'):].strip()))
test_tags.discard('')
if line.startswith('componentTags:'):
component_tags = set(
re.split(r'[ ,:]', line[len('componentTags:'):].strip()))
component_tags.discard('')
if test_tags and component_tags:
return component_tags, test_tags
print(f"No componentTags or testTags found for test case {test_id}.")
return component_tags, test_tags

0 comments on commit f76bccd

Please sign in to comment.