Repository navigation
Fix to_pdb for ANISOU records after label_models - #166
Merged
Merged
Conversation
label_models() adds an integer model_id column to the ANISOU frame too. to_pdb() only skipped unexpected columns for ATOM and HETATM, so for ANISOU it tried to concatenate the integer column to the output string and raised a TypeError. Skip model_id like to_pdb_stream() does, and skip other unexpected ANISOU columns with a warning.
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation resolves the reported failure and includes appropriate regression coverage.
0 open findings
What changed in this PR
Fixes PDB export for labeled models containing ANISOU records.
Changes:
- Skips
model_idduring PDB serialization. - Validates unexpected columns against each record’s schema.
- Adds regression tests and changelog documentation.
| File | Description |
|---|---|
biopandas/pdb/pandas_pdb.py |
Corrects column handling during PDB export. |
tests/pdb/test_write_pdb.py |
Tests labeled and unexpected ANISOU columns. |
docs/CHANGELOG.md |
Documents the export fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Code of Conduct
Read.
Description
label_models()adds an integermodel_idcolumn to theANISOUframe as well as toATOMandHETATM.to_pdb()only skipped unexpected columns forATOMandHETATM, so forANISOUit tried to append the integer column to the output string and failed:to_pdb()now skipsmodel_idsilently, the same wayto_pdb_stream()already drops it, and unexpectedANISOUcolumns are skipped with the same warning used forATOM/HETATM(checked against theANISOUrecord fields).Two tests added in
tests/pdb/test_write_pdb.py: writing the ANISOU test file afterlabel_models()gives back the original file without amodel_idwarning, and an extraANISOUcolumn is warned about and skipped. Both fail onmainand pass with this change.Related issues or pull requests
Fixes #124
Pull Request Checklist
./docs/sources/CHANGELOG.mdfile (if applicable) (the changelog lives atdocs/CHANGELOG.md)./biopandas/*/testsdirectories (if applicable)biopandas/docs/sources/(if applicable) (not needed)PYTHONPATH='.' pytest ./biopandas -svand make sure that all unit tests pass (ranpytest tests/pdb: 86 passed, 3 skipped, 7 xfailed)flake8 ./biopandas(no new warnings in the changed lines)