Skip to content

fixes formatting for extremely high B-factor values - #5047

Merged
JoaoRodrigues merged 9 commits into
biopython:masterfrom
OWissett:bfactor_writing
Sep 3, 2025
Merged

JoaoRodrigues merged 9 commits into
biopython:masterfrom
OWissett:bfactor_writing

Conversation

@OWissett

@OWissett OWissett commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit
    locally, and understand that continuous integration checks will be used to
    confirm the Biopython unit tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

Closes #5046

@OWissett
OWissett marked this pull request as draft August 28, 2025 15:04
@OWissett
OWissett marked this pull request as ready for review August 28, 2025 15:08
Comment thread Bio/PDB/PDBIO.py Resolved

@JoaoRodrigues JoaoRodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, see my comment.

If possible, could you also add a unit test covering this scenario? You can modify one of the files we already have in the test suite, just add a couple of large b-factors and see if the file is written correctly.

@OWissett

Copy link
Copy Markdown
Contributor Author

Will do on Monday. I'm away from civilisation this weekend. I'll be up a mountain.

@JoaoRodrigues

Copy link
Copy Markdown
Member

Will do on Monday. I'm away from civilisation this weekend. I'll be up a mountain.

Thanks and enjoy!

@OWissett

OWissett commented Sep 1, 2025

Copy link
Copy Markdown
Contributor Author

I have added unit tests, and restructured how the formatting works a little bit. Since technically the maximum value for a bfactor can be 999_999 (if we have no decimals) we can now handle those without emitting a warning.

I also have accounted for the case where rounding increases the number of digits.

Finally, I added a new warning class PDBIOWarning, as I feel it makes sense to have a dedicated warning for saving PDBs compared to other PDB warnings, in the same way we have a PDBContructionWarning

@JoaoRodrigues JoaoRodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, but looks good to me. If you can, add a small snippet to NEWS.rst explaining this change, as this can surprise some people.

Comment thread Bio/PDB/PDBExceptions.py Resolved
Comment thread Bio/PDB/PDBIO.py Resolved
Comment thread Tests/test_PDB_PDBIO.py Resolved
Comment thread Tests/test_PDB_PDBIO.py Resolved
@JoaoRodrigues

Copy link
Copy Markdown
Member

Thanks a lot @OWissett, super nice contribution. I've enabled the full CI workflow to run on these changes and once the tests/checks pass, happy to merge.

@codecov

codecov Bot commented Sep 2, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.32%. Comparing base (d1c4b3d) to head (83a4443).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5047      +/-   ##
==========================================
+ Coverage   85.45%   86.32%   +0.87%     
==========================================
  Files         286      286              
  Lines       59854    59874      +20     
==========================================
+ Hits        51147    51686     +539     
+ Misses       8707     8188     -519     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoaoRodrigues
JoaoRodrigues merged commit d3de878 into biopython:master Sep 3, 2025
@JoaoRodrigues

Copy link
Copy Markdown
Member

Merged, thanks again @OWissett !

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.

Edge case B-factor writing error

2 participants