fix b_factor field overflow for values rounding up to a wider integer part - #161
Open
IMGillusion wants to merge 1 commit into
Open
IMGillusion wants to merge 1 commit into
IMGillusion wants to merge 1 commit into
Conversation
99.996 formats as 100.00 (7 chars), which spilled into the segid/element columns and broke the 80-char ATOM line. The old check compared the raw integer-part length against the formatted width, so anything that rounds up a digit was misclassified. Now the formatted string itself decides. Fixes BioPandas#109
This branch has not been deployed
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.
The b_factor format check compared the raw integer-part length against the 6-char PDB field width, so anything that rounded up across a digit boundary took the wrong branch: 99.996 formats as "100.00" (7 chars) and the extra char spilled into the segid/element columns, pushing the line past 80 chars. That is the overflow from #109 (MDAnalysis then read the stray digit as a segid and turned one chain into thousands).
The check now uses the formatted string. 97.39 / 99.99 / 99.996 / 100.32 / 999.99 all come out as 80-char lines with the element in cols 77-78. Values >= 1000.00 still overflow; PDB v3 simply has no room for them in a 6-char field, behavior unchanged, noted in the docstring.
tests/pdb/test_to_pdb_bfactor.py covers the rounding-up edge. pdb suite green locally (49 passed; test_b_factor_shift deselected here, it needs RCSB network).
Fixes #109