Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_init_rms() in Bio.PDB.qcprot.QCPSuperimposer returns an error #4314

Closed
KlaraDrofenik opened this issue May 25, 2023 · 3 comments · Fixed by #4316
Closed

get_init_rms() in Bio.PDB.qcprot.QCPSuperimposer returns an error #4314

KlaraDrofenik opened this issue May 25, 2023 · 3 comments · Fixed by #4316
Labels

Comments

@KlaraDrofenik
Copy link

Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0]
CPython
Linux-5.4.0-135-generic-x86_64-with-glibc2.35
1.81

Expected behaviour

The function get_init_rms() in Bio.PDB.qcprot.QCPSuperimposer should return the root mean square deviation of untransformed coordinates.

Actual behaviour

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[36], line 10
      8 super_imposerQPC.set_atoms([a1, a2, b1, b2], [b1, b2, a1, a2])
      9 super_imposerQPC.run()
---> 10 print(super_imposerQPC.get_init_rms())

File /opt/conda/lib/python3.10/site-packages/Bio/PDB/qcprot.py:349, in QCPSuperimposer.get_init_rms(self)
    347 if self.init_rms is None:
    348     diff = self.coords - self.reference_coords
--> 349     self.init_rms = np.sqrt(np.sum(np.dot(diff, diff), axis=0) / self._natoms)
    350 return self.init_rms

File <__array_function__ internals>:180, in dot(*args, **kwargs)

ValueError: shapes (4,3) and (4,3) not aligned: 3 (dim 1) != 4 (dim 0)

Steps to reproduce

import Bio
a1 = Bio.PDB.Atom.Atom("CA", [1, 1, 1], 0, 1, "", " CA ",1, element = "C")
a2 = Bio.PDB.Atom.Atom("CA", [2, 4, 6], 0, 1, "", " CA ",2, element = "C")
b1 = Bio.PDB.Atom.Atom("CA", [2, 2, 2], 0, 1, "", " CA ",3, element = "C")
b2 = Bio.PDB.Atom.Atom("CA", [3, 5, 7], 0, 1, "", " CA ",4, element = "C")

super_imposerQPC = Bio.PDB.qcprot.QCPSuperimposer()
super_imposerQPC.set_atoms([a1, a2, b1, b2], [b1, b2, a1, a2])
super_imposerQPC.run()
print(super_imposerQPC.get_init_rms())

Note

I think that file biopython/Bio/PDB/qcprot.py the useage of np.dot functions is problematic. I think the formula from Superimposer module, but updated for the variable names like np.sqrt(np.sum(np.sum(diff * diff)) / self.coords.shape[0]) should work.

@KlaraDrofenik KlaraDrofenik changed the title get_init_rms() in Bio.PDB.qcprot.QCPSuperimposer returns error get_init_rms() in Bio.PDB.qcprot.QCPSuperimposer returns an error May 25, 2023
@JoaoRodrigues
Copy link
Member

Absolutely, thank you for catching this! Would you be willing to make a pull request or you prefer we handle it?

@JoaoRodrigues
Copy link
Member

This should be included in #4312 if possible.

@KlaraDrofenik
Copy link
Author

Absolutely, thank you for catching this! Would you be willing to make a pull request or you prefer we handle it?

I would prefer if you handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants