Skip to content

read_yaml_model reads empty enzymes maps and quotes inside values; fseof follows ecFSEOF - #185

Merged
edkerk merged 6 commits into
developfrom
fix/yaml-ec-readers-fseof
Oct 30, 2026
Merged

edkerk merged 6 commits into
developfrom
fix/yaml-ec-readers-fseof

Conversation

@edkerk

@edkerk edkerk commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

read_yaml_model reads the ecModel files that GECKO and RAVEN write, and fseof follows GECKO's ecFSEOF where it differs.

YAML reader. read_yaml_model reads the same files as RAVEN's readYAMLmodel, which is line based:

  • An ec reaction written as - enzymes: !!omap with nothing under the tag (GECKO and RAVEN write this for a reaction without enzymes) is read as a reaction with no enzymes. It raised AttributeError: 'ScalarNode' object has no attribute 'flow_style'. The tutorial light Human-GEM ecModel.yml has 52 such reactions and eciYali5-GEM has 29.
  • A double-quoted value with quotes inside, such as ""text"" or "a "b" c", is read as "text" and a "b" c: the outer pair of quotes is dropped and \\ and \" are unescaped. Older RAVEN (writeYAMLmodel with preserveQuotes) wrote a note that carried its own quotes this way, and eciYali5-GEM has three of them.
  • A single-quoted value with an apostrophe inside, such as 'it's', is read as it's.
  • The repairs run only when the strict parse fails, so files that parse as YAML are read unchanged. A comment after a repaired value is not handled.

fseof. fseof solves each level the way RAVEN's solveLP and GECKO's ecFSEOF do:

  • The pFBA step holds the objective at 0.999999 of its optimum at that level. It held the full value, and on the scipy solver the optimum is only accurate to HiGHS's feasibility tolerance, so the step was infeasible at the top level of ecYeastGEM and the scan returned 9 of 10 levels. It returns all 10, as on Gurobi and GLPK. A level at which the biomass maximisation is infeasible still ends the scan.
  • The top of the scan is max_fraction times the target flux in the pFBA solution that maximises the target, where it took the plain maximum (a difference of about 1e-6 relative).
  • Targets of equal score are listed in model order (a stable sort).
  • The new option equality=True fixes the target flux at each level, as ecFSEOF does. The default keeps the lower bound of RAVEN's FSEOF.

Used by CompMetEng/geckopy#72 and the comparison in CompMetEng/raven-gecko-parity#141.

An ec reaction without enzymes is written as '- enzymes: !!omap' with no
content; the reader now gives it no enzymes, as RAVEN's readYAMLmodel does.
A scalar written as ""text"" is repaired line by line only after the strict
parse fails, and reads as "text".
…value

The fallback after a failed strict parse now repairs any double-quoted
value with an unescaped interior quote, not only one that starts and
ends with a doubled quote. The outer pair is dropped and \\ and \" are
unescaped, as readYAMLmodel does.
… step

RAVEN's solveLP minimises the flux sum with the objective fixed at
0.999999 of the optimum it just found. fseof demanded the full value,
which the HiGHS solver of the scipy interface rejects at the top level of
ecYeastGEM because its optimum is accurate only to the feasibility
tolerance. All enforced levels are now returned on scipy, as on Gurobi
and GLPK.
The fallback after a failed strict parse now also repairs a single-quoted
value with an apostrophe that no second apostrophe pairs with, such as
'it's'. The outer pair is dropped and each '' is read as ', as
readYAMLmodel does.
…d can fix the target

The top of the scan is max_fraction of the target flux in the pFBA solution
that maximises the target, as RAVEN's FSEOF and GECKO's ecFSEOF do. Targets
of equal score keep model order. The new equality option fixes the target
flux at each level, as ecFSEOF does.
@edkerk
edkerk merged commit a98e2a1 into develop Oct 30, 2026
10 checks passed
@edkerk
edkerk deleted the fix/yaml-ec-readers-fseof branch October 30, 2026 10:21
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.

1 participant