|
25 | 25 | compartments, and seed species. |
26 | 26 |
|
27 | 27 | The block scanner is hardened against the BNGL grammar (BioNetGen ``Perl2/``; |
28 | | -see the reference in ``BNG_vscode_extension`` ``docs/bngl-grammar.md``): line |
29 | | -continuations (a trailing ``\\``), block aliases (``molecules``/``species``/ |
30 | | -``rules``), line labels (a numeric index ``1 L0 1`` or a named ``CD14: ...``), |
31 | | -and the seed-species ``$`` clamp marker are all honored. It is kept in sync |
32 | | -with PyBNF's sibling reader (``pybnf/petab/_bngl.py``, ADR-0026) -- the |
33 | | -grammar-hardening tests are the anchor that keeps the two from drifting. |
| 28 | +cross-checked against ``BNG_vscode_extension`` ``docs/bngl-grammar.md``): line |
| 29 | +continuations (a trailing ``\\``), the ``species`` block alias (``begin |
| 30 | +species`` = ``begin seed species``), line labels (a numeric index ``1 L0 1`` or |
| 31 | +a named ``CD14: ...``), and the seed-species ``$`` clamp marker are honored. It |
| 32 | +is kept in sync with PyBNF's sibling reader (``pybnf/petab/_bngl.py``, |
| 33 | +ADR-0026) -- the grammar-hardening tests are the anchor against drift. |
34 | 34 | """ |
35 | 35 |
|
36 | 36 | from __future__ import annotations |
|
53 | 53 | #: The three keywords that open an observable declaration line. |
54 | 54 | _OBS_KEYWORDS = frozenset({"Molecules", "Species", "Counter"}) |
55 | 55 |
|
56 | | -#: Short spellings BioNetGen accepts for a block's canonical (long) name -- |
57 | | -#: either spelling opens and closes the same block. Only the blocks this reader |
58 | | -#: enumerates need an entry. |
| 56 | +#: Short spellings BNG2.pl accepts for a block's canonical (long) name; either |
| 57 | +#: spelling opens and closes the same block. The grammar doc |
| 58 | +#: (``BNG_vscode_extension/docs/bngl-grammar.md``) also lists ``molecules`` and |
| 59 | +#: ``rules``, but BNG2.pl 2.9.3 -- the reference this reader targets -- rejects |
| 60 | +#: both ("Could not process block type"), so honoring them would accept models |
| 61 | +#: BNG2.pl refuses. Only ``species`` (for ``seed species``, also BNG2.pl's own |
| 62 | +#: canonical output spelling) is real. |
59 | 63 | _BLOCK_ALIASES = { |
60 | | - "molecule types": ("molecules",), |
61 | 64 | "seed species": ("species",), |
62 | | - "reaction rules": ("rules",), |
63 | 65 | } |
64 | 66 |
|
65 | 67 |
|
@@ -157,10 +159,10 @@ def _logical_lines(text: str) -> list[str]: |
157 | 159 | def _block_lines(text: str, block_name: str) -> list[str]: |
158 | 160 | """The comment-stripped, non-blank lines inside ``begin``/``end``. |
159 | 161 |
|
160 | | - ``block_name`` is the canonical (long) spelling; any BioNetGen alias for it |
161 | | - (``molecules`` for ``molecule types``, ``species`` for ``seed species``, |
162 | | - ``rules`` for ``reaction rules``) opens and closes the same block. Lines |
163 | | - are logical lines -- continuations joined (see :func:`_logical_lines`). |
| 162 | + ``block_name`` is the canonical (long) spelling; a BNG2.pl-accepted alias |
| 163 | + for it (only ``species`` for ``seed species``; see :data:`_BLOCK_ALIASES`) |
| 164 | + opens and closes the same block. Lines are logical lines -- continuations |
| 165 | + joined (see :func:`_logical_lines`). |
164 | 166 | """ |
165 | 167 | names = "|".join( |
166 | 168 | re.escape(name) |
|
0 commit comments