Repository navigation
fix(mpnn): honor parser overrides for AtomArray inputs - #389
Merged
AndrewKubaney merged 5 commits intoOct 16, 2026
Merged
AndrewKubaney merged 5 commits into
AndrewKubaney merged 5 commits into
Conversation
`MPNNInferenceInput.from_atom_array_and_dict()` parsed an AtomArray with the parser defaults and ignored `remove_ccds` / `remove_waters`, so a ligand whose label is the CCD code of another molecule (phenytoin labelled `PHT`) was rebuilt from that template. - Forward the parser fields the caller set to `parse_atom_array()` through a helper that `build_atom_array()` now shares; unset fields keep the parser defaults. - Add `add_missing_atoms` (JSON field and `--add_missing_atoms`, unset by default) so the atoms of an input can be kept as given. - Test that `add_missing_atoms=False` keeps all 19 phenytoin atoms, that the AtomArray defaults are unchanged, that both routes forward the overrides, and that an input without an assembly still needs `structure_path`.
AtomWorks 3 rejects a ligand whose atom names do not match its CCD template, so the defaults check can no longer carry the mislabelled phenytoin. - Check the defaults on glycerol and water only; the phenytoin case stays in the `add_missing_atoms=False` test. - Build the expected array with the CCD charges that `from_atom_array_and_dict()` now adds before parsing.
AndrewKubaney
approved these changes
Oct 16, 2026
AndrewKubaney
left a comment
Collaborator
There was a problem hiding this comment.
This looks good to me! Thanks for making this fix!
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.
An AtomArray passed to
MPNNInferenceInput.from_atom_array_and_dict()is parsed with the parser defaults:remove_ccdsandremove_watersin the input dict are ignored, and there is no way to switch offadd_missing_atoms. A ligand whose label is the CCD code of a different molecule then cannot be kept as given: its atom names do not match that template, the parse raises, and the input dict offers no way around it:The structure-path route already applies these overrides; only the AtomArray route dropped them, although
examples/all.ipynbalready passesremove_watersnext to an AtomArray (with the parser's default value, so nothing showed).parse_atom_array()through the helperbuild_atom_array()now shares, so the two routes cannot drift apart again. Fields left unset keep the parser defaults.add_missing_atoms(JSON field and--add_missing_atoms), unset by default, which still means the parser default on both routes.remove_ccdsorremove_waters, which were ignored. The defaults are untouched: they differ between the routes (remove_ccds=[]for a path, crystallization aids removed for an AtomArray), so the defaulted dict values are deliberately not forwarded.structure_path.Tested with nine new cases and the extended CLI case in
models/mpnn/tests/test_inference_utils.py(CPU, AtomWorks 3.0.1). Six fail onproduction: the PHT case, the two ignored fields, both forwarding checks, and the new field's validation and CLI flag. The checks that pin the unchanged behavior pass on both. All ofmodels/mpnn/testspasses (130), and the repo's pinnedruffandmypyreport nothing new.