Regex fixes for compound name parsing#13
Conversation
…a, require whitespace in regex to disambiguate between comment and part of compound name
|
Hey, I saw that the macos-latest check was failing for this PR - looking at the details it seems to be failing in the middle of setting up the conda environment, before the build and test stages. Is this just a case where you have to update the action, or is there something I'm missing that I should change? |
BRENDA's JSON still embeds legacy annotations inside reaction-string
values. Splitting reaction sides on a bare "+" dropped ion charges
(H+ -> H, NAD+ -> NAD), and |...| pipe comments and <ref> tags leaked
into compound names.
- add _clean_reaction_string(): strips |...| comments, {...} reversibility
and numeric <n,n> reference tags, preserving chemical notation such as
glycosidic "(1->4)" bonds and polymer subscripts ([...]n+m)
- split reaction sides on " + " so ionic charges and polymer "+" stay
attached to the compound name (fixes filter_by_substrate/product/compound
for ions, e.g. "NAD+")
- fold substrates_products pipe comments into `comment` instead of
discarding them
Re-addresses the parsing issues reported in #13 against the JSON parser
(ion-charge loss and |...| comment leakage). The parentheses issue (#12)
is already handled by the structured JSON `comment` field.
Co-authored-by: Clark Pohl <clarklettuce@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Hi @lasagen, thank you for these fixes and the detailed write-up! 🙏 Since you opened this, BRENDA switched from the flat text file to a structured JSON document (schema 2.0.0), so the parser was rewritten on and these regex changes no longer apply to the new code. But two of the three issues you found were still present in the JSON parser, and I've re-implemented your fixes there: Ion charges (H+, NAD+) were still dropped — fixed by splitting on " + " (your approach). |
Hello! Thank you so much for your work on BRENDApyrser. I was using it for a study and found a few issues.
substratesAndProductsto only split on "+" if there are spaces around it and leave +s in compound names.__extractDataFieldand__extractReactionMechanismInfo.extractDataLineInfoto only add something in parentheses to the meta field if it starts with whitespace.These worked for me, but there are definitely better ways to do them, so feel free to suggest changes. Thanks again!