[chimerax-users] Trajectory computation slowing down overtime
Shubham Devesh Ramgoolam
sdramgoolam at uwaterloo.ca
Mon Jun 27 23:27:40 PDT 2022
Ok. Thanks a lot.
Shubham
________________________________
From: Eric Pettersen <pett at cgl.ucsf.edu>
Sent: June 27, 2022 12:57 PM
To: Shubham Devesh Ramgoolam <sdramgoolam at uwaterloo.ca>
Cc: ChimeraX Users Help <chimerax-users at cgl.ucsf.edu>
Subject: Re: [chimerax-users] Trajectory computation slowing down overtime
Hi Shubham,
Both angles are perfectly valid. Since most people would intuitively think of the "angle between the planes" as the smaller (<=90) angle, that's why in the plane-plane angle sample code I supplied it always returns the <=90 angle:
Plane-plane angle:
from chimerax.geometry import angle
a = angle(plane1.normal, plane2.normal)
if a > 90:
a = 180 - a
--Eric
On Jun 27, 2022, at 12:04 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:
Hi all,
I have noticed that for some residue, the plane normal displayed in the log, after using define plane command, is antiparallel to the plane normal obtained with low level mathematical primitives.
This would cause any angle measurement involving one such plane and another ‘regular’ plane (same plane normal in both cases) to be different when using the angle command than when using the low level mathematical primitives. The angles are supplementary instead of identical.
I have inserted a screenshot of my log and shell showing the plane normal obtained with the define plane command and with the low level mathematical primitives.
<1041C798FB7B4B68B81CF26A82B04195.jpg>
I am not sure if this is a valid question but which value represents the true angle between the planes?
Regards,
Shubham Ramgoolam
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Eric Pettersen<mailto:pett at cgl.ucsf.edu>
Sent: Tuesday, June 14, 2022 3:20
To: Shubham Devesh Ramgoolam<mailto:sdramgoolam at uwaterloo.ca>
Cc: ChimeraX Users Help<mailto:chimerax-users at cgl.ucsf.edu>
Subject: Re: [chimerax-users] Trajectory computation slowing down overtime
Hi Shubham,
Looking at your graph, even the initial time is way too slow, 10+ seconds/frame. For this kind of analysis, you should be using low level mathematical primitives rather than the graphical axes/planes/centroids, which are intended for interactive use and have a lot of additional overhead, like a triangle mesh for the graphical depiction, color information, etc.
So the first thing is you will need to get is the atoms that the primitives will based on. Assuming you know how to select the atoms with a command, you can get them with:
from chimerax.atomic import selected_atoms
run(session, "sel some-atom-spec")
atoms = selected_atoms(session)
So, the low level primitives are:
Centroid: just an xyz point, which you can get with:
from chimerax.centroid import centroid
centroid_pt = centroid(atoms.coords)
(which is just atoms.coords.mean(0) actually)
Axis: as long as you not measuring distances with an axis, all you need is a direction vector, which is also just an xyz value, which you can get with:
from numpy.linalg import svd
center = atoms.coords.mean(0)
_, vals, vecs = sud(atoms.coords - center, full_matrices=False)
xyz = vecs[vals.argsort()[-1])
Plane: an origin point and a normal vector, encapsulated as a chimera.geometry.Plane object, e.g.:
from chimerax.geometry import Plane
plane = Plane(atoms.coords)
Here are example measurements:
Centroid-centroid distance:
from chimerax.geometry import distance
d = distance(xyz1, xyz2)
Centroid-plane distance:
d = abs(plane.distance(xyz))
Axis-axis angle:
from chimerax.geometry import angle
a = angle(xyz1, xyz2)
This returns a value in the range 0-180. To map that into the 0-90 range:
if a > 90:
a = 180 - a
Plane-plane angle:
from chimerax.geometry import angle
a = angle(plane1.normal, plane2.normal)
if a > 90:
a = 180 - a
--Eric
On Jun 13, 2022, at 11:38 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:
Hi Eric,
No, I did not.
I tried it now by adding the following code at the end of the first for loop: run(session, ‘close #1.*’)
It made the issue worse, the computation took longer than before. I believe it is because it takes time to close these models.
(Originally, I tried fixing the issue by closing the entire session and starting a new one. However, it took too much time for chimeraX to close a session, after defining lots of geometric objects.)
Is there a quicker to close these models at the end of each frame?
Shubham
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Eric Pettersen<mailto:pett at cgl.ucsf.edu>
Sent: Monday, June 13, 2022 20:43
To: Shubham Devesh Ramgoolam<mailto:sdramgoolam at uwaterloo.ca>
Cc: chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>
Subject: Re: [chimerax-users] Trajectory computation slowing down overtime
Hi Shubham,
Defining those geometric objects creates models. Are you closing those models at the end of each frame?
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
On Jun 11, 2022, at 11:21 PM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>> wrote:
I just wanted to specify that I am using the nogui mode of chimeraX for the computation.
Shubham.
<CB8387F6EE204E1BA668D200AE4A00A4.png>
From: Shubham Devesh Ramgoolam
Sent: June 12, 2022 1:38 AM
To: chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu> <chimerax-users at cgl.ucsf.edu<mailto:chimerax-users at cgl.ucsf.edu>>
Subject: Trajectory computation slowing down overtime
Hi all,
I hope you are doing well.
I have a Python script for analyzing specific residue pairs for every frame in a trajectory.
It does so, by using 2 for loops:
For frame in list_frames:
Set current frame to frame
For pair in specific_residue_pairs:
Do computation
The computation involves defining geometric objects(centroids, axes, planes) and performing calculations with them(distance, angles).
The issue here is that as we move further in list_frames, the computation takes longer and longer. There is a somewhat linear increase in computation time, as illustrated below:
<E0E35EA38D4345BE98A480EB08BE8CEC.png>
Is there a way to maintain the same computation time for every frame in the trajectory?
Regards,
Shubham Ramgoolam
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users at cgl.ucsf.edu<mailto:ChimeraX-users at cgl.ucsf.edu>
Manage subscription:
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users at cgl.ucsf.edu<mailto:ChimeraX-users at cgl.ucsf.edu>
Manage subscription:
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users at cgl.ucsf.edu<mailto:ChimeraX-users at cgl.ucsf.edu>
Manage subscription:
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220628/ca60e3a0/attachment-0001.html>
More information about the ChimeraX-users
mailing list