Time-efficient python code for obtaining coordinates of atoms
Hi all, I hope you are doing well. I am looking for a time-efficient way of obtaining the coordinates of specified residues. I cannot use the command getcrd as I need these coordinates in a python script for defining geometric objects (getcrd prints the output to the log).
My attempt at this consisted of selecting all of the specified residues via run(session, ‘sel ...’), accessing that selection using selected_residues(session), and then, extracting the coordinates using .atoms.coords. The issue here is that run(session, ‘sel ...’) slows down if there are lots of specified residues.
I tried bypassing the command ‘sel’ by first importing AtomSpecArg from chimerax.core.commands.atomspec and then using AtomSpecArg.parse('my residue_ID', session)[0].evaluate(session).atoms[0]. However, this is even slower.
Regards, Shubham
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
Hi Shubham, First off, 'getcrd' really should return the coordinates in addition to logging them, so I have fixed that and the fix will be in tonight's daily build. But I don't think that really helps you because atom-spec parsing in ChimeraX is relatively slow, and I assume you would need to provide the same (long) atom spec to getcrd that you were using with "sel". We want to improve the speed and reliability of atom-spec parsing, but achieving that is quite aways off at this point and so won't help with your current situation. I assume that which residues you need coordinates from are changing frequently, otherwise the cost of selecting them once wouldn't be that big a deal. Depending on what criteria you are using to choose the residues, maybe you could loop through chimerax.atomic.all_structures(session).residues and get the coordinates of the residues that meet your criteria.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 1, 2022, at 2:32 AM, Shubham Devesh Ramgoolam via ChimeraX-users chimerax-users@cgl.ucsf.edu wrote:
Hi all, I hope you are doing well. I am looking for a time-efficient way of obtaining the coordinates of specified residues. I cannot use the command getcrd as I need these coordinates in a python script for defining geometric objects (getcrd prints the output to the log).
My attempt at this consisted of selecting all of the specified residues via run(session, ‘sel ...’), accessing that selection using selected_residues(session), and then, extracting the coordinates using .atoms.coords. The issue here is that run(session, ‘sel ...’) slows down if there are lots of specified residues.
I tried bypassing the command ‘sel’ by first importing AtomSpecArg from chimerax.core.commands.atomspec and then using AtomSpecArg.parse('my residue_ID', session)[0].evaluate(session).atoms[0]. However, this is even slower.
Regards, Shubham
Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu mailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Ok. Thank you, Eric. I appreciate it, Shubham
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
From: Eric Pettersenmailto:pett@cgl.ucsf.edu Sent: Tuesday, August 2, 2022 5:34 To: Shubham Devesh Ramgoolammailto:sdramgoolam@uwaterloo.ca Cc: chimerax-users@cgl.ucsf.edumailto:chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Time-efficient python code for obtaining coordinates of atoms
Hi Shubham, First off, 'getcrd' really should return the coordinates in addition to logging them, so I have fixed that and the fix will be in tonight's daily build. But I don't think that really helps you because atom-spec parsing in ChimeraX is relatively slow, and I assume you would need to provide the same (long) atom spec to getcrd that you were using with "sel". We want to improve the speed and reliability of atom-spec parsing, but achieving that is quite aways off at this point and so won't help with your current situation. I assume that which residues you need coordinates from are changing frequently, otherwise the cost of selecting them once wouldn't be that big a deal. Depending on what criteria you are using to choose the residues, maybe you could loop through chimerax.atomic.all_structures(session).residues and get the coordinates of the residues that meet your criteria.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 1, 2022, at 2:32 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edumailto:chimerax-users@cgl.ucsf.edu> wrote:
Hi all, I hope you are doing well. I am looking for a time-efficient way of obtaining the coordinates of specified residues. I cannot use the command getcrd as I need these coordinates in a python script for defining geometric objects (getcrd prints the output to the log).
My attempt at this consisted of selecting all of the specified residues via run(session, ‘sel ...’), accessing that selection using selected_residues(session), and then, extracting the coordinates using .atoms.coords. The issue here is that run(session, ‘sel ...’) slows down if there are lots of specified residues.
I tried bypassing the command ‘sel’ by first importing AtomSpecArg from chimerax.core.commands.atomspec and then using AtomSpecArg.parse('my residue_ID', session)[0].evaluate(session).atoms[0]. However, this is even slower.
Regards, Shubham
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edumailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Hi Shubham,
Here is example Python code to lookup residues by chain identifier and residue numbers.
https://rbvi.github.io/chimerax-recipes/residues/residues.html https://rbvi.github.io/chimerax-recipes/residues/residues.html
Tom
On Aug 1, 2022, at 10:39 PM, Shubham Devesh Ramgoolam via ChimeraX-users chimerax-users@cgl.ucsf.edu wrote:
Ok. Thank you, Eric. I appreciate it, Shubham
Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows
From: Eric Pettersen mailto:pett@cgl.ucsf.edu Sent: Tuesday, August 2, 2022 5:34 To: Shubham Devesh Ramgoolam mailto:sdramgoolam@uwaterloo.ca Cc: chimerax-users@cgl.ucsf.edu mailto:chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Time-efficient python code for obtaining coordinates of atoms
Hi Shubham, First off, 'getcrd' really should return the coordinates in addition to logging them, so I have fixed that and the fix will be in tonight's daily build. But I don't think that really helps you because atom-spec parsing in ChimeraX is relatively slow, and I assume you would need to provide the same (long) atom spec to getcrd that you were using with "sel". We want to improve the speed and reliability of atom-spec parsing, but achieving that is quite aways off at this point and so won't help with your current situation. I assume that which residues you need coordinates from are changing frequently, otherwise the cost of selecting them once wouldn't be that big a deal. Depending on what criteria you are using to choose the residues, maybe you could loop through chimerax.atomic.all_structures(session).residues and get the coordinates of the residues that meet your criteria.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 1, 2022, at 2:32 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edu mailto:chimerax-users@cgl.ucsf.edu> wrote:
Hi all, I hope you are doing well. I am looking for a time-efficient way of obtaining the coordinates of specified residues. I cannot use the command getcrd as I need these coordinates in a python script for defining geometric objects (getcrd prints the output to the log).
My attempt at this consisted of selecting all of the specified residues via run(session, ‘sel ...’), accessing that selection using selected_residues(session), and then, extracting the coordinates using .atoms.coords. The issue here is that run(session, ‘sel ...’) slows down if there are lots of specified residues.
I tried bypassing the command ‘sel’ by first importing AtomSpecArg from chimerax.core.commands.atomspec and then using AtomSpecArg.parse('my residue_ID', session)[0].evaluate(session).atoms[0]. However, this is even slower.
Regards, Shubham
Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu mailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Thank you Tom. I appreciate it, Shubham.
________________________________ From: Tom Goddard goddard@sonic.net Sent: August 2, 2022 4:15 PM To: Shubham Devesh Ramgoolam sdramgoolam@uwaterloo.ca Cc: ChimeraX Users Help chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Time-efficient python code for obtaining coordinates of atoms
Hi Shubham,
Here is example Python code to lookup residues by chain identifier and residue numbers.
https://rbvi.github.io/chimerax-recipes/residues/residues.html
Tom
On Aug 1, 2022, at 10:39 PM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edumailto:chimerax-users@cgl.ucsf.edu> wrote:
Ok. Thank you, Eric. I appreciate it, Shubham
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
From: Eric Pettersenmailto:pett@cgl.ucsf.edu Sent: Tuesday, August 2, 2022 5:34 To: Shubham Devesh Ramgoolammailto:sdramgoolam@uwaterloo.ca Cc: chimerax-users@cgl.ucsf.edumailto:chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Time-efficient python code for obtaining coordinates of atoms
Hi Shubham, First off, 'getcrd' really should return the coordinates in addition to logging them, so I have fixed that and the fix will be in tonight's daily build. But I don't think that really helps you because atom-spec parsing in ChimeraX is relatively slow, and I assume you would need to provide the same (long) atom spec to getcrd that you were using with "sel". We want to improve the speed and reliability of atom-spec parsing, but achieving that is quite aways off at this point and so won't help with your current situation. I assume that which residues you need coordinates from are changing frequently, otherwise the cost of selecting them once wouldn't be that big a deal. Depending on what criteria you are using to choose the residues, maybe you could loop through chimerax.atomic.all_structures(session).residues and get the coordinates of the residues that meet your criteria.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 1, 2022, at 2:32 AM, Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edumailto:chimerax-users@cgl.ucsf.edu> wrote:
Hi all, I hope you are doing well. I am looking for a time-efficient way of obtaining the coordinates of specified residues. I cannot use the command getcrd as I need these coordinates in a python script for defining geometric objects (getcrd prints the output to the log).
My attempt at this consisted of selecting all of the specified residues via run(session, ‘sel ...’), accessing that selection using selected_residues(session), and then, extracting the coordinates using .atoms.coords. The issue here is that run(session, ‘sel ...’) slows down if there are lots of specified residues.
I tried bypassing the command ‘sel’ by first importing AtomSpecArg from chimerax.core.commands.atomspec and then using AtomSpecArg.parse('my residue_ID', session)[0].evaluate(session).atoms[0]. However, this is even slower.
Regards, Shubham
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edumailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
_______________________________________________ ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edumailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
participants (3)
-
Eric Pettersen
-
Shubham Devesh Ramgoolam
-
Tom Goddard