Render multi-bond first partner as flat !N!N, not !N![N]#80
Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Open
Render multi-bond first partner as flat !N!N, not !N![N]#80wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
!N!N, not !N![N]#80wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
Conversation
`BondsXML.resolve_xml` had an off-by-one-character bug: when the SAME
site is the first partner of two or more bonds (the `hub(x!1!2)` shape),
the second-and-later bond IDs were appended to `self.bonds_dict` as a
one-element LIST `[ibond + 1]` instead of as the int `ibond + 1`. The
second partner's branch already appended the int correctly, so the bug
only surfaced for sites that appeared as `bond_partner_1` in multiple
bonds.
`Component.__str__` then ran `f"!{bond}"` over the flat bonds list,
which turned `[2]` into `![2]`. BNG2.pl reads `![N]` as a compartment
specifier in pattern syntax and aborts with `Invalid syntax at ![2]`
when it re-loads the regenerated BNGL.
Fix: append the int (parity with the second-partner branch).
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.
Summary
`BondsXML.resolve_xml` has an off-by-one-character bug: when the SAME site is the first partner of two or more bonds (the `hub(x!1!2)` shape), the second-and-later bond IDs are appended to `self.bonds_dict` as a one-element LIST `[ibond + 1]` instead of as the int `ibond + 1`. The second partner's branch already appends the int correctly, so the bug only surfaces for sites that appear as `bond_partner_1` in multiple bonds.
`Component.str` then runs `f"!{bond}"` over the flat bonds list, which turns `[2]` into `![2]`. BNG2.pl reads `![N]` as a compartment specifier in pattern syntax and aborts with `Invalid syntax at ![2]` when it re-loads the regenerated BNGL.
Fix
Append the int (parity with the second-partner branch).
Test plan