#9866 - Additional elements appear when inserting a file saved in mol format the expand monomers package#10138
#9866 - Additional elements appear when inserting a file saved in mol format the expand monomers package#10138Lianamirru wants to merge 5 commits into
Conversation
0694acb to
7049278
Compare
| new Pile(selection.images), | ||
| new Pile(selection[MULTITAIL_ARROW_KEY]), | ||
| bondIdMap, | ||
| true, |
There was a problem hiding this comment.
The bare true as the 11th positional arg to Struct.clone(...) is opaque — a reader has to jump to struct.ts:192 to learn it means "clone attachment points." The sibling change in this same PR (ketSerializer.ts:967) introduces const needCloneAttachmentPoints = true; precisely to self-document the call. Mirroring that pattern here would keep the two new call sites consistent:
| true, | |
| bondIdMap, | |
| true /* needCloneAttachmentPoints */, |
| const isAbsFlag = | ||
| Array.from(this.molecule!.frags.values()).some((fr) => | ||
| fr ? fr.enhancedStereoFlag === StereoFlag.Abs : false, | ||
| ) || | ||
| Array.from(this.molecule!.atoms.values()).some( | ||
| (atom) => atom.stereoLabel === StereoLabel.Abs, | ||
| ); |
There was a problem hiding this comment.
A one-liner explaining why a per-atom StereoLabel.Abs must also raise the chiral header flag would help — this is exactly the bug being fixed, and without context a future maintainer is likely to "simplify" it back. Something like // Atoms can carry an Abs stereo label even when no fragment is flagged as Abs (e.g., after copy/paste); both paths must raise the chiral flag. above the assignment would suffice.
Minor: Array.from(map.values()).some(...) materialises both maps before short-circuiting. For typical molecules this is negligible, but a small forEach/for…of helper would avoid the throwaway arrays if you're already touching this block.
|
Targeted bug-fix PR — the two correctness changes (cloning attachment points so leaving-group hydrogens get dropped, and raising the chiral header flag for per-atom Two small things noted inline. One broader follow-up worth flagging separately:
|
9b698cd to
8bb9181
Compare
How the feature works? / How did you fix the issue?
(Screenshots, videos, or GIFs, if applicable)
Check list
#1234 – issue name