Repository navigation
fix: read whole-number YAML charges as ints - #164
Merged
Merged
Conversation
writeYAMLmodel.m (RAVEN 3) and write_yaml_model write every number as a float, so charges arrive as -1.0. cobra's SBML writer passes the charge unchanged to libsbml's setCharge, which does not keep a float, so every charge was lost when such a model was written to SBML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
read_yaml_modelnow reads whole-number charges as ints.writeYAMLmodel.m(RAVEN 3) andwrite_yaml_modelwrite every number as a float, so a charge arrives as-1.0. cobra models charge as an int. Its SBML writer passes the value unchanged to libsbml'ssetCharge, which does not keep a float, so every metabolite charge was lost when a model read from a RAVEN 3-format YAML was written to SBML.This was found in Human-GEM's release checks (SysBioChalmers/Human-GEM#1123): reading the 2.1.0 YAML and writing it to SBML set all charges to 0.
_integer_chargesturns a float charge that is a whole number into an int when reading. Other charges (fractional ones, or none) are left as they are.charge: -1.0andcharge: 0.5gives an int-1, which survives an SBML round-trip;0.5is kept. The test fails without the fix.On Vera, the four YAML test files (50 tests) and
ruff check src testspass. In the full suite, onlytests/test_io_git.py::test_standard_gem_layoutfails, becauseopenpyxlis missing from that environment; it fails the same way without this change.