Skip to content

Replace C-extension with pure Python code for QCP superimposition. - #3876

Merged
JoaoRodrigues merged 7 commits into
biopython:masterfrom
JoaoRodrigues:qcprot
Apr 25, 2022
Merged

JoaoRodrigues merged 7 commits into
biopython:masterfrom
JoaoRodrigues:qcprot

Conversation

@JoaoRodrigues

@JoaoRodrigues JoaoRodrigues commented Mar 11, 2022 •

Copy link
Copy Markdown
Member
  • 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.)

This PR replaces the QCPSuperimposer C module with a pure Python implementation, with minimal loss of performance. In fact, it improves performance in my tests by ~30%. The API is largely the same, with the addition of set_atoms and apply, to mirror the behavior of Superimposer and simplify access to the algorithm. Also refactored the tests to use assertEqual instead of multiple calls to numpy.array_equal, which were making debugging failing tests quite difficult.

@JoaoRodrigues
JoaoRodrigues requested a review from peterjc March 11, 2022 23:42
Comment thread Bio/PDB/qcprot.py Resolved
Comment thread Bio/PDB/qcprot.py Resolved
Comment thread Bio/PDB/qcprot.py Resolved
Comment thread Bio/PDB/qcprot.py Resolved
@joaomcteixeira

Copy link
Copy Markdown

Crazy implementation 😉
Gave some very minor comments 👍

@codecov

codecov Bot commented Mar 12, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #3876 (d2c8854) into master (4ecfd97) will decrease coverage by 5.54%.
The diff coverage is 80.09%.

❗ Current head d2c8854 differs from pull request most recent head 8089a6e. Consider uploading reports for the commit 8089a6e to get more accurate results

@@            Coverage Diff             @@
##           master    #3876      +/-   ##
==========================================
- Coverage   84.31%   78.76%   -5.55%     
==========================================
  Files         322      303      -19     
  Lines       55095    52176    -2919     
==========================================
- Hits        46452    41098    -5354     
- Misses       8643    11078    +2435     
Impacted Files Coverage Δ
Bio/PDB/qcprot.py 79.79% <79.79%> (ø)
Bio/PDB/QCPSuperimposer/__init__.py 25.00% <100.00%> (-64.86%) ⬇️
Bio/PDB/PICIO.py 5.00% <0.00%> (-82.30%) ⬇️
Bio/Phylo/CDAOIO.py 4.46% <0.00%> (-80.36%) ⬇️
Bio/PDB/internal_coords.py 10.69% <0.00%> (-76.66%) ⬇️
Bio/phenotype/pm_fitting.py 12.28% <0.00%> (-75.44%) ⬇️
Bio/PDB/SCADIO.py 11.84% <0.00%> (-68.43%) ⬇️
Bio/PDB/mmtf/__init__.py 28.57% <0.00%> (-61.91%) ⬇️
Bio/Graphics/__init__.py 25.00% <0.00%> (-58.34%) ⬇️
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ecfd97...8089a6e. Read the comment docs.

@JoaoRodrigues

Copy link
Copy Markdown
Member Author

@peterjc any idea on why the tests would be failing with the import errors? Locally they all pass (on MacOS and Windows).

@peterjc

peterjc commented Apr 16, 2022

Copy link
Copy Markdown
Member

e.g.

ERROR while importing Bio.pairwise2: cannot import name '_aligners' from partially initialized module 'Bio.Align' (most likely due to a circular import) (D:\a\biopython\biopython\Bio\Align\__init__.py)

I have no idea, @mdehoon may be able to tell? There is nothing obviously changed on the C side in this PR that I can see.

@JoaoRodrigues

JoaoRodrigues commented Apr 16, 2022 •

Copy link
Copy Markdown
Member Author

Thanks. This is also happening on master, the latest commit is also failing with this message. The weird thing is that it seems to run fine on Linux, so maybe it's a CI configuration thing with MacOS and Windows?

The tests started failing after this commit b67c382, which is weird because it also didn't touch the C code.

@JoaoRodrigues

Copy link
Copy Markdown
Member Author

I can reproduce this locally with python=3.7 but none of the others. Working on a fix now.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants