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/
>