Rotation (Euler) angles

110 views
Skip to first unread message

mohamed marzouk

unread,
Oct 12, 2021, 5:09:56 PM10/12/21
to MDnalysis discussion

Hello, 

I attended the great webinar yesterday on BioExcel, and I would like to use MDAnalysis alongside other MD simulation analysis tools like MDtraj.

During my dissociation simulation for protein/DNA complex, the system (protein) rotates (noticed during visual inspection), So I want to quantify this rotation. 

To do so, I want to get the rotation matrix used after alignment to calculate minimized RMSD, from this (Rotation matrix) I can get the angles of rotation. 
I found this MD analysis tutorial  4.2.1.1. RMS-fitting tutorial That shows how to get the rotation matrix.
My Q?
if there any function that can pick up the Euler angles from the rotation matrix?
I am trying to build my code to run all frames of trajectory and calculate the std deviation of these three angles along the whole trajectory. 
If not, can u suggest the other possible ways to obtain these angles ? 

Oliver Beckstein

unread,
Oct 12, 2021, 7:36:58 PM10/12/21
to mdnalysis-discussion
Hi Mohamed,

Welcome to the mailing list and thank you for attending the bioexcel webinar. I think you asked your question there and I suggested you come here.

As you already found out how to get the rotation martrix, look at functions in MDAnalysis.lib.transformations  https://docs.mdanalysis.org/stable/documentation_pages/lib/transformations.html (which is really Christoph Gohlkes transformations package that we are bundling — apparently, it now exists as its own package on pypi https://pypi.org/project/transformations/ ). 

You have to read through the docs to understand how Euler angles are represented – the module is fairly low level and for some reason, not all the docs are actually being built, so looking at the source code  https://github.com/MDAnalysis/mdanalysis/blob/develop/package/MDAnalysis/lib/transformations.py helps.


1) MDAnalysis.lib.transformations.euler_from_matrix() (unfortunately the documentation is missing… see the example code in the docs and the source https://github.com/MDAnalysis/mdanalysis/blob/149eb504e35670568201af28306fa04462f6c100/package/MDAnalysis/lib/transformations.py#L1061 ) : should give you exactly what you want:

a1, a2, a3 =  MDAnalysis.lib.transformations.euler_from_matrix(R, axes=“szxz")
(but check axes convention… I just added the axes keyword as a reminder that it exists!)

2) Not the Euler angles but the rotation axis (vector) and angle: MDAnalysis.lib.transformations.rotation_from_matrix
https://docs.mdanalysis.org/stable/documentation_pages/lib/transformations.html#MDAnalysis.lib.transformations.rotation_from_matrix 

3) MDAnalysis.lib.transformations.decompose_matrix() https://docs.mdanalysis.org/stable/documentation_pages/lib/transformations.html#MDAnalysis.lib.transformations.decompose_matrix will take a 4x4 matrix M (where M[:3, :3] == R and M[:, 3] = M[3, :] == [0, 0, 1]) and give you amongst other things the Euler angles around static (s) x,y, z axes (“sxyz” convention). 


You could write a function that computes the rotation matrix and Euler angles for one frame and then use a similar approach as in https://userguide.mdanalysis.org/stable/examples/analysis/custom_trajectory_analysis.html (see also my other email to the list today https://groups.google.com/g/mdnalysis-discussion/c/nWaRsEh1rww/m/Pmh4QkPsAQAJ ) to get it for your whole trajectory.

Hope this helped!

Oliver

 
--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/801090cd-846e-4c64-8367-fddd12f924aan%40googlegroups.com.

--
Oliver Beckstein (he/his/him)


MDAnalysis – a NumFOCUS fiscally sponsored project




Reply all
Reply to author
Forward
0 new messages