[chimerax-users] Select ring atoms of ligand using python in chimerax
Eric Pettersen
pett at cgl.ucsf.edu
Tue Jan 17 12:06:10 PST 2023
Hi Vijay,
I don't know exactly how efficient you need things to be, but here is some info...
Get all atoms:
from chimerax.atomic import all_atoms
atoms = all_atoms(session)
Filter down to just ligand atoms:
ligand_atoms = atoms.filter(atoms.structure_categories == "ligand")
Ligand ring atoms:
ring_atoms = [a for a in ligand_atoms if a.rings()]
Assign charges to ligand residues:
from chimerax.add_charge import add_charges
add_charges(session, ligand_atoms.unique_residues)
Sum the charges:
charge_sum = sum([a.charge for a in ligand_atoms])
This all assumes the structure has hydrogens. In particular, the charge sum will be massively negative if hydrogens are missing! Some of the calls above are covered in the ChimeraX programmer's guide (https://www.rbvi.ucsf.edu/chimerax/docs/devel/index.html <https://www.rbvi.ucsf.edu/chimerax/docs/devel/index.html>, also included in the app under Help), particularly the "API Reference" link.
When you said "select ring atoms" I don't know if you meant just find them (which the above does) or actually select them in the graphics window. This would do that:
session.selection.clear()
for a in ring_atoms:
a.selected = True
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On Jan 16, 2023, at 11:03 PM, Dr. Vijay Masand via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Dear all
> I am looking for an efficient method to select ring atoms of ligands using python in chimeraX. Also, is there any python code/method to get the sum of charges on ligand atoms only?
> Thanks in advance.
> From
> Vijay
>
> With Warm Regards
> Dr. Vijay H. Masand
> Department of Chemistry,
> Vidya Bharati College, Amravati, 444 602
> Maharashtra, India.
> Phone number- +91-9403312628
> https://sites.google.com/site/vijaymasand/ <https://sites.google.com/site/vijaymasand/>
>
> _______________________________________________
> ChimeraX-users mailing list
> 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/20230117/a756eb9f/attachment.html>
More information about the ChimeraX-users
mailing list