Skip to content

fix: quote YAML 1.1 booleans, and align task lists, gene pruning and YAML floats with raven-toolbox - #11

Open
edkerk wants to merge 8 commits into
developfrom
fix/10-yaml-booleans
Open

edkerk wants to merge 8 commits into
developfrom
fix/10-yaml-booleans

Conversation

@edkerk

@edkerk edkerk commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10.

YAML booleans

  • src/io/writeYAMLmodel.m needsQuote: NO, yes, on and the other YAML 1.1 booleans (y, n, yes, no, on, off in any case) were written unquoted, so a YAML 1.1 loader such as PyYAML read nitric oxide's name: NO as False. They are quoted, as true and false already were. raven-toolbox quotes the same set since fix: four writer, task and gene-pruning problems from #178 raven-toolbox#179.
  • The pattern uses explicit character classes ([Yy][Ee][Ss]) instead of (?i), which in MATLAB would also make the numeric alternatives case-insensitive and quote values such as 0X1F that raven-toolbox leaves plain.

Parity decisions from the RAVEN vs raven-toolbox review

Each item has a test. The Python side is CompMetEng/raven-toolbox#181.

  • writeYAMLmodel: non-integers are written with the shortest digits that read back exactly (15 to 17 significant digits), so 1/3 is 0.3333333333333333 and not 0.333333333333333. Python writes the same.
  • removeLowScoreGenes: when all isozymes are negative and tied, the gene listed first in the rule is kept, not the alphabetically first one. Surviving genes keep rule order. The docstring no longer says the tie is random.
  • parseTaskList:
    • SHOULD FAIL and PRINT FLUX read 0, false and no (any case) as false.
    • Items in ; lists are trimmed and empty items dropped.
    • Headers are matched ignoring case and surrounding whitespace.
    • An empty CHANGED LB or CHANGED UB is NaN, meaning the bound is left unchanged. checkTasks and fitTasks skip NaN bounds. Before, an empty bound left the bound arrays shorter than the list of changed reactions.
  • checkTasks: warns when a task metabolite matches several model metabolites (only the first is constrained; raven-toolbox constrains all and warns too).

Checks

Not run in MATLAB. The new tests (tTasks, tINIT, tIO) need a MATLAB run before merging. Two places where a test, not the fix, could fail: the parseTaskList test depends on how textscan reads empty fields, and the float test sets lb(1) above zero on a reaction that may be marked reversible.

needsQuote now quotes y, n, yes, no, on and off in any case, which YAML 1.1 loaders such as PyYAML read as booleans.
This matches the quoting of write_yaml_model in raven-toolbox (CompMetEng/raven-toolbox#178).

#10
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Function test results

432 tests   425 ✅  1m 57s ⏱️
 24 suites    7 💤
  1 files      0 ❌

Results for commit 875e45b.

♻️ This comment has been updated with latest results.

@edkerk edkerk changed the title fix: quote YAML 1.1 booleans such as NO in writeYAMLmodel fix: quote YAML 1.1 booleans, and align task lists, gene pruning and YAML floats with raven-toolbox Oct 21, 2026
… that is left

By name, replaceMets deletes the replacement's row and keeps the renamed replaced metabolite. The ids it passed to the final contractModel call (repMetIds) were captured from the replacement only, so after the deletion none of them was found, repIdx was empty and contractModel(model,'mets',[]) checked every reaction. Duplicate reactions that do not involve the merged metabolite were merged as well.

repMetIds now also holds the id of the replaced metabolite, so the restriction follows whichever of the two rows survives, and an empty list no longer reaches contractModel. Tests: unrelated duplicate reactions survive a merge by name and by id, and the new duplicate is still contracted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

writeYAMLmodel: YAML 1.1 booleans such as NO are written unquoted

1 participant