Hello, Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)? Thank you. Best, Siyoung
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure. Certainly you could do it with Python, but somebody else would have to advise on that. Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
Hi Siyoung, Here is Python code to select all atoms with x < 0. from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True You can type this in the ChimeraX Python shell (menu Tools / General / Shell), or probably easier, put it in a text file "select.cxc" and open that in ChimeraX to run it. Tom
On Oct 17, 2023, at 9:04 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
Oops. If you put this code in a file it needs to have a ".py" suffix, so call it select.py. The ".cxc" suffix is for ChimeraX commands. Tom
On Oct 17, 2023, at 12:58 PM, Tom Goddard via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Siyoung,
Here is Python code to select all atoms with x < 0.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
You can type this in the ChimeraX Python shell (menu Tools / General / Shell), or probably easier, put it in a text file "select.cxc" and open that in ChimeraX to run it.
Tom
On Oct 17, 2023, at 9:04 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
Hi Elaine, Thank you for your reply! Best, Siyoung On Tue, Oct 17, 2023 at 12:04 PM Elaine Meng <meng@cgl.ucsf.edu> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
Hi Tom, Thank you for your help. I can confirm that making a text file, select.py, that contains the below and running "run select.py" in the ChimeraX command line works. from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True I am quite interested in learning more about the chimerax.atomix library. Would there be any helpful resources about this? Would it be also possible to loop over a molecular dynamics trajectory and select wanted atoms in this way? Thank you. Best, Siyoung On Tue, Oct 17, 2023 at 4:06 PM Tom Goddard <goddard@sonic.net> wrote:
Oops. If you put this code in a file it needs to have a ".py" suffix, so call it select.py. The ".cxc" suffix is for ChimeraX commands.
Tom
On Oct 17, 2023, at 12:58 PM, Tom Goddard via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hi Siyoung,
Here is Python code to select all atoms with x < 0.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
You can type this in the ChimeraX Python shell (menu Tools / General / Shell), or probably easier, put it in a text file "select.cxc" and open that in ChimeraX to run it.
Tom
On Oct 17, 2023, at 9:04 AM, Elaine Meng via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
On Oct 17, 2023, at 1:53 PM, Siyoung Kim via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Tom,
Thank you for your help. I can confirm that making a text file, select.py, that contains the below and running "run select.py" in the ChimeraX command line works.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
I am quite interested in learning more about the chimerax.atomix library. Would there be any helpful resources about this?
There is automatically generated documentation, but I don't recommend it because it is poorly formatted and littered with rarely used constants and functions from base classes (e.g. Structure inherits from Model and Drawing and therefore documentation for first_intercept_children() [from Drawing] is included). Instead, I'd browse through the code for atomic class definitions themselves. The Cython class definitions for Atom, Element, and Bond are here: https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/atomic_cpp/... <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/atomic_cpp/cymol.pyx> . The definitions for the other classes are here: https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/molobje... <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/molobject.py> . The latter only has the base class definitions for Structure and PseudobondGroup (StructureData and PseudobondGroupData respectively). The final definitions are in structure.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/structure.py> and pbgroup.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/pbgroup.py> . Another approach is to find a bundle that does something similar to what you want to do and look at its code to see how it does it. All the ChimeraX source code is in the repository linked to above (and the Python code is included in every ChimeraX installation).
Would it be also possible to loop over a molecular dynamics trajectory and select wanted atoms in this way?
Yes. A structure that is a trajectory will have multiple "coordinate sets" (sets of coordinates for the atoms). Therefore you can loop through the trajectory like so: from chimerax.atomic import all_atomic_structures: for s in all_atomic_structures(session): for cs_id in s.coordset_ids: s.active_coordset_id = cs_id for a in s.atoms: a.selected = a.scene_coord[0] < 0 It may also be useful to know that the value returned by s.atoms is an "Atoms" instance (see molarray.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/molarray.py>) which in many ways can be treated as a vector for efficiency, which could definitely matter when processing a trajectory. So the above code could instead be: from chimerax.atomic import all_atomic_structures: for s in all_atomic_structures(session): for cs_id in s.coordset_ids: s.active_coordset_id = cs_id atoms = s.atoms atoms.selecteds = atoms.scene_coords[:,0] < 0 --Eric Eric Pettersen UCSF Computer Graphics Lab
Thank you. Best, Siyoung
On Tue, Oct 17, 2023 at 4:06 PM Tom Goddard <goddard@sonic.net <mailto:goddard@sonic.net>> wrote: Oops. If you put this code in a file it needs to have a ".py" suffix, so call it select.py. The ".cxc" suffix is for ChimeraX commands.
Tom
On Oct 17, 2023, at 12:58 PM, Tom Goddard via ChimeraX-users <chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu>> wrote:
Hi Siyoung,
Here is Python code to select all atoms with x < 0.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
You can type this in the ChimeraX Python shell (menu Tools / General / Shell), or probably easier, put it in a text file "select.cxc" and open that in ChimeraX to run it.
Tom
On Oct 17, 2023, at 9:04 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu>> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users <chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu>> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/ <https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/>
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/ <https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/>
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
Hi Eric, Thank you very much for the very helpful information! I learned a lot. Best, Siyoung On Fri, Oct 20, 2023 at 8:58 PM Eric Pettersen <pett@cgl.ucsf.edu> wrote:
On Oct 17, 2023, at 1:53 PM, Siyoung Kim via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hi Tom,
Thank you for your help. I can confirm that making a text file, select.py, that contains the below and running "run select.py" in the ChimeraX command line works.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
I am quite interested in learning more about the chimerax.atomix library. Would there be any helpful resources about this?
There is automatically generated documentation, but I don't recommend it because it is poorly formatted and littered with rarely used constants and functions from base classes (*e.g.* Structure inherits from Model and Drawing and therefore documentation for first_intercept_children() [from Drawing] is included). Instead, I'd browse through the code for atomic class definitions themselves. The Cython class definitions for Atom, Element, and Bond are here: https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/atomic_cpp/... . The definitions for the other classes are here: https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/molobje... . The latter only has the base class definitions for Structure and PseudobondGroup (StructureData and PseudobondGroupData respectively). The final definitions are in structure.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/structure.py> and pbgroup.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/pbgroup.py> .
Another approach is to find a bundle that does something similar to what you want to do and look at its code to see how it does it. All the ChimeraX source code is in the repository linked to above (and the Python code is included in every ChimeraX installation).
Would it be also possible to loop over a molecular dynamics trajectory and select wanted atoms in this way?
Yes. A structure that is a trajectory will have multiple "coordinate sets" (sets of coordinates for the atoms). Therefore you can loop through the trajectory like so:
from chimerax.atomic import all_atomic_structures: for s in all_atomic_structures(session): for cs_id in s.coordset_ids: s.active_coordset_id = cs_id for a in s.atoms: a.selected = a.scene_coord[0] < 0
It may also be useful to know that the value returned by s.atoms is an "Atoms" instance (see molarray.py <https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/atomic/src/molarray.py>) which in many ways can be treated as a vector for efficiency, which could definitely matter when processing a trajectory. So the above code could instead be:
from chimerax.atomic import all_atomic_structures: for s in all_atomic_structures(session): for cs_id in s.coordset_ids: s.active_coordset_id = cs_id atoms = s.atoms atoms.selecteds = atoms.scene_coords[:,0] < 0
--Eric
Eric Pettersen UCSF Computer Graphics Lab
Thank you. Best, Siyoung
On Tue, Oct 17, 2023 at 4:06 PM Tom Goddard <goddard@sonic.net> wrote:
Oops. If you put this code in a file it needs to have a ".py" suffix, so call it select.py. The ".cxc" suffix is for ChimeraX commands.
Tom
On Oct 17, 2023, at 12:58 PM, Tom Goddard via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hi Siyoung,
Here is Python code to select all atoms with x < 0.
from chimerax.atomic import all_atoms for a in all_atoms(session): if a.scene_coord[0] < 0: a.selected = True
You can type this in the ChimeraX Python shell (menu Tools / General / Shell), or probably easier, put it in a text file "select.cxc" and open that in ChimeraX to run it.
Tom
On Oct 17, 2023, at 9:04 AM, Elaine Meng via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hello Siyoung, Sorry no, I can't think of a way to do it with a ChimeraX command. Maybe you could do it by using the initial orientation of the structure (just opening and not rotating) and veerrryyy carefully using the mouse to select a rectangle (Ctrl-click drag) but that is probably too difficult. Also you would need to know where X=0 is from just looking at the structure.
Certainly you could do it with Python, but somebody else would have to advise on that.
Best, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On Oct 17, 2023, at 5:33 AM, Siyoung Kim via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hello,
Would there be a selection keyword that selects atoms based on their coordinates? For instance, is there a way that I can select atoms whose x coordinates are below 0 (e.g., x < 0)?
Thank you. Best, Siyoung
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
participants (4)
-
Elaine Meng
-
Eric Pettersen
-
Siyoung Kim
-
Tom Goddard