Skip to content

fix b_factor field overflow for values rounding up to a wider integer part - #161

Open
IMGillusion wants to merge 1 commit into
BioPandas:mainfrom
IMGillusion:fix-bfactor-field-width
Open

IMGillusion wants to merge 1 commit into
BioPandas:mainfrom
IMGillusion:fix-bfactor-field-width

Conversation

@IMGillusion

Copy link
Copy Markdown

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

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Biopandas PDB output formatting leads to a ton of segments when reading with MDAnalysis: reason and my quick fix

1 participant