Skip to content

Main - #25

Merged
breakthewall merged 5 commits into
stablefrom
main
Oct 21, 2026
Merged

Main#25
breakthewall merged 5 commits into
stablefrom
main

Conversation

@breakthewall

Copy link
Copy Markdown
Member

No description provided.

breakthewall and others added 5 commits October 21, 2026 10:58
rpReaction.build() (used when loading reactions back from an rpSBML
file) passed the raw MIRIAM annotation list straight through as
`miriam`, while every type hint, docstring and the ec-code dict access
in __init__ treat it as a Dict. So get_miriam() returned a list for
SBML-imported reactions but a dict for directly-constructed ones.

- rpSBML.convert_miriam_to_dict(): fix the regex to accept hyphens in
  the database segment (it silently dropped "ec-code" entries, since
  '-' isn't a word character) and dots/colons/hyphens in the reference
  segment (EC numbers like "1.2.3.-" were truncated to "1").
- rpReaction.build(): use convert_miriam_to_dict() to build a proper
  {"ec-code": [...], "uniprot": [...], ...} dict instead of passing
  the raw annotation list through.
- rpPathway.to_rpSBML(): the reaction cross-references written back
  out only ever included "ec-code", silently dropping any other miriam
  entry (e.g. "uniprot" from selenzy) on every write. Now all entries
  in get_miriam() are carried over, with ec_numbers kept as the
  authoritative "ec-code" source since it's populated regardless of
  how the reaction was constructed.

This was blocking adding UniProt IDs from selenzy_wrapper: they were
already present in existing rpSBML files but got reduced to a list
nobody could index into, and wouldn't have survived being written back
out even once get_miriam() was fixed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds explicit coverage for the miriam dict fix (373fad4): reading
ec-code + uniprot annotations off tests/data/lycopene.sbml as a proper
dict, and a write -> read round-trip confirming every miriam entry
(not just ec-code) survives to_rpSBML(). Verified both fail with
AttributeError: 'list' object has no attribute 'keys' against the
pre-fix code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses B006/B008 (mutable/function-call defaults), RUF012/RUF013
(implicit Optional, mutable class defaults), RUF015/RUF059 (iterable
allocation, unused unpacked vars), SIM102/103/114/118/201
(simplify-able conditionals), PLR1722 (sys.exit), BLE001, C403/405/408
and the two false-positive EXE001/EXE005 shebang hits (triggered by a
"#!!!!" comment, not an actual shebang) found by the lint CI job.

Loggers now default to a module-level singleton instead of calling
getLogger() in the signature, consistently across rpObject, rpCompound,
rpGraph, rpReaction, rpPathway, rpSBML and cobra_format.

Two of the mutable-default fixes are real bugs, not just style: both
rpPathway.to_rpSBML()'s local_cache and rpReaction.__init__'s
reactants/products/miriam were shared, process-lifetime dicts that get
written into in place elsewhere in the same call graph. Any caller
relying on the default (to_rpSBML() with no local_cache, several exist
across rpScore/rpThermo) would have silently accumulated species-ID
remappings across unrelated pathway conversions.

The three intentional blind `except Exception` catches (malformed/
missing XML annotations, non-literal eval() fallback) are annotated
with `# noqa: BLE001` plus a comment rather than narrowed, since the
precise exception types libsbml/eval() can raise here aren't reliably
documented.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI ran an unpinned `pip install ruff`, so lint results silently
depended on whichever ruff version happened to be latest at run time.
Declare the exact rule codes the CI run actually flagged (and we just
fixed) in pyproject.toml, so the active rule set no longer drifts with
ruff's own evolving defaults. N999 (invalid module name) is suppressed
per public-API module (rpSBML, rpPathway, rpReaction, rpCompound,
rpGraph, rpObject, inchikeyMIRIAM), since renaming any of them would
break every downstream consumer's `from rplibs import ...`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@breakthewall
breakthewall merged commit 6553d7b into stable Oct 21, 2026
8 checks passed
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