Skip to content

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

Merged
edkerk merged 8 commits into
developfrom
fix/10-yaml-booleans
Oct 21, 2026
Merged

edkerk merged 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.

replaceMets bug

  • replaceMets called contractModel on the whole model, so it also merged unrelated metabolites that happened to share a name or id. The call is now restricted to the metabolite that is left, and skipped when nothing is left to contract.
  • Three new tests in tManipulation: by name and by id leave unrelated duplicates alone, and by name still contracts the new duplicate. Without the fix replaceMetsByNameLeavesUnrelatedDuplicatesAlone fails; with it all pass.

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

Run in MATLAB R2024b with GLPK on head 875e45b (cluster batch 2026-10-21, results in CompMetEng/raven-gecko-parity, branch hpc-results/2026-10-21, folder follow-up/pr11/): tTasks 7/7, tIO 24/24, tManipulation 85/85, tINIT 31/31, tSyntax 1/1, none failed or incomplete. The scenarios remove_low_score_genes_smallyeast, replace_metabolite_toy, task_checking_smallyeast, task_list_parsing and yaml_roundtrip_smallyeast MATCH against Python seeds 0, 1 and 2.

Not checked: other MATLAB versions and solvers (Gurobi, SCIP).

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.
@edkerk edkerk changed the title fix: quote YAML 1.1 booleans, and align task lists, gene pruning and YAML floats with raven-toolbox fix: quote YAML 1.1 booleans, fix replaceMets, and align task lists, gene pruning and YAML floats with raven-toolbox Oct 21, 2026
edkerk added a commit to CompMetEng/raven-gecko-parity that referenced this pull request Oct 21, 2026
New scenarios: remove_low_score_genes_ties_smallyeast, task_list_edge_cases and
yaml_float_digits_smallyeast. The task-list scenarios compare an empty CHANGED
bound as NaN. Ledger notes for replaceMets, removeLowScoreGenes, parseTaskList,
checkTasks, writeYAMLmodel, exportForGit and isDnfGrRule now say what
CompMetEng/RAVEN#11 and CompMetEng/raven-toolbox#181 change.
@edkerk
edkerk merged commit beadbc0 into develop Oct 21, 2026
4 checks passed
@edkerk
edkerk deleted the fix/10-yaml-booleans branch October 21, 2026 22:34
edkerk added a commit to CompMetEng/raven-gecko-parity that referenced this pull request Oct 21, 2026
…otes for the parity decisions (#139)

* fix: name the solver of min_nr_fluxes_toy instead of requesting scip

The MATLAB side called setRavenSolver('scip'), which RAVEN supports on Linux only if SCIP was compiled by hand, so the scenario ended in ERROR (no result from matlab) in every nightly. It now takes matlab_solver and python_solver from scenario.yml (gurobi, as in task_checking_smallyeast) and restores the previous RAVEN solver afterwards.

* doc: record the differences confirmed on MATLAB in the ledger notes

The first MATLAB batch on a cluster (RAVEN 79a7d8c, 2026-10-21) confirmed differences between RAVEN and raven-toolbox that the notes did not state or stated wrongly: replaceMets (a RAVEN bug, not replicated exactly), removeLowScoreGenes (the tie-break is alphabetical, not random), parseTaskList, checkTasks, writeYAMLmodel, exportForGit and isDnfGrRule. Only the notes of these seven rows change.

* Add scenarios for the parity decisions and update the ledger notes

New scenarios: remove_low_score_genes_ties_smallyeast, task_list_edge_cases and
yaml_float_digits_smallyeast. The task-list scenarios compare an empty CHANGED
bound as NaN. Ledger notes for replaceMets, removeLowScoreGenes, parseTaskList,
checkTasks, writeYAMLmodel, exportForGit and isDnfGrRule now say what
CompMetEng/RAVEN#11 and CompMetEng/raven-toolbox#181 change.
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