fix(evals): cif patching regression to allow protenix outputs to run on all evals, and remove hydrogens in RSCC parsing - #336
fix(evals): cif patching regression to allow protenix outputs to run on all evals, and remove hydrogens in RSCC parsing#336k-chrispens wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR updates CIF reference normalization and chain/residue remapping, disables missing-atom insertion in RSCC parsing, and expands synchronized checkout exclusions. ChangesCIF patching
RSCC parsing
Synchronization exclusions
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
843e977 to
de3d301
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses evaluation regressions related to mmCIF altloc/compositional heterogeneity handling, aiming to make reference structures stack cleanly and keep downstream patching/eval scripts consistent with current guidance behavior.
Changes:
- Add reference-structure canonicalization for mixed-altloc modified residues (e.g., CYS/CSO) so
map_altlocs_to_stack()can succeed when building evaluation reference ensembles. - Add regression tests covering mixed-altloc canonicalization behavior (including a real 6NI6 example).
- Update CIF patching + RSCC grid-search scripts to mirror the same CIF/parse handling assumptions used elsewhere.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/eval/test_structure_utils.py | Adds end-to-end + unit regression tests for mixed-altloc residue canonicalization/stacking. |
| src/sampleworks/eval/structure_utils.py | Implements _closest_canonical_amino_acid() and canonicalize_mixed_altloc_residues(), and applies it when loading reference stacks. |
| scripts/patch_output_cif_files.py | Uses resolve_mixed_hetatm_atom_altlocs() and adjusts residue/chain remapping logic for current eval needs. |
| scripts/eval/rscc_grid_search_script.py | Sets add_missing_atoms=False in parse() calls for consistency with other pipelines. |
| .actlignore | Ignores additional local artifacts (*.tar, output/, .jj/). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Mirror the fix from guidance_script_utils - strip mixed ATOM/HETATM altlocs | ||
| # at the same residue position (e.g. 6NI5/6 CYS/CSO) so the reference matches | ||
| # what is generated by guidance. Returns the original path if nothing to fix. | ||
| safe_reference_path = resolve_mixed_hetatm_atom_altlocs(reference_path) | ||
| reference = load_any(safe_reference_path) | ||
| if safe_reference_path != reference_path: | ||
| safe_reference_path.unlink() | ||
|
|
||
| asym_unit = load_any(cif_file) | ||
| asym_unit = ensure_atom_array_stack(asym_unit) |
There was a problem hiding this comment.
Will address separately as there are multiple places this comes up. #339
marcuscollins
left a comment
There was a problem hiding this comment.
I have questions (see comments in rscc_grid_search_script.py and patch_output_cif_files.py) but the main thing is that I think this needs to be rebased as it seems to include changes that have to do with canoncalizing amino acids that I think are in a different PR.
| # Mirror the fix from guidance_script_utils - strip mixed ATOM/HETATM altlocs | ||
| # at the same residue position (e.g. 6NI5/6 CYS/CSO) so the reference matches | ||
| # what is generated by guidance. Returns the original path if nothing to fix. | ||
| safe_reference_path = resolve_mixed_hetatm_atom_altlocs(reference_path) | ||
| reference = load_any(safe_reference_path) | ||
| if safe_reference_path != reference_path: | ||
| safe_reference_path.unlink() | ||
|
|
||
| asym_unit = load_any(cif_file) | ||
| asym_unit = ensure_atom_array_stack(asym_unit) |
There was a problem hiding this comment.
Will address separately as there are multiple places this comes up. #339
| # which breaks the commented multi-chain handling below | ||
|
|
||
| mapping[cif_key] = ref_key[1] | ||
| # patch the residue numbers to match the original pdb |
There was a problem hiding this comment.
@k-chrispens did you apply this to all the generated CIF files? If so, I'm fine with it. We're probably going to be able to get rid of this script soon anyway.
| return atom_array | ||
|
|
||
|
|
||
| def _closest_canonical_amino_acid(res_name: str) -> str | None: |
There was a problem hiding this comment.
Isn't this in your other PR? Please rebase after merging that one.
| ) | ||
| # parse() returns only the first altloc. | ||
| ref_structure = parse(ref_path, ccd_mirror_path=None) | ||
| ref_structure = parse(ref_path, ccd_mirror_path=None, add_missing_atoms=False) |
There was a problem hiding this comment.
If you really want to remove hydrogens, add hydrogen_policy="remove"
de3d301 to
ac9e3f2
Compare
Strip mixed ATOM/HETATM altlocs and remap chain+residue per atom in patch_output_cif_files.py; pass add_missing_atoms=False in the RSCC grid search parse; extend .actlignore.
ac9e3f2 to
c1a8a23
Compare
There are a few regressions that needed to be made here to get the evals running completely for the paper. These changes are archived in the zenodo record but should be applied here for consistency until we fix the Protenix JSON parsing issue.
Summary by CodeRabbit
Bug Fixes
Chores