<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Vijay,<div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>I don't know exactly how efficient you need things to be, but here is some info...</div><div class=""><br class=""></div><div class=""><i class="">Get all atoms</i><span style="font-style: normal;" class="">:</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from chimerax.atomic import all_atoms</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>atoms = all_atoms(session)</div><div class=""><br class=""></div><div class=""><i class="">Filter down to just ligand atoms</i><span style="font-style: normal;" class="">:</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ligand_atoms = atoms.filter(atoms.structure_categories == "ligand")</div><div class=""><br class=""></div><div class=""><i class="">Ligand ring atoms</i><span style="font-style: normal;" class="">:</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ring_atoms = [a for a in ligand_atoms if a.rings()]</div><div class=""><br class=""></div><div class=""><i class="">Assign charges to ligand residues</i><span style="font-style: normal;" class="">:</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from chimerax.add_charge import add_charges</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>add_charges(session, ligand_atoms.unique_residues)</div><div class=""><br class=""></div><div class=""><i class="">Sum the charges</i><span style="font-style: normal;" class="">:</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>charge_sum = sum([a.charge for a in ligand_atoms])</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>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 (<a href="https://www.rbvi.ucsf.edu/chimerax/docs/devel/index.html" class="">https://www.rbvi.ucsf.edu/chimerax/docs/devel/index.html</a>, also included in the app under Help), particularly the "API Reference" link.</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>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:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>session.selection.clear()</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>for a in ring_atoms:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>a.selected = True</div><div class=""><br class=""></div><div class=""><div class="">--Eric</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>Eric Pettersen</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>UCSF Computer Graphics Lab</div></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 16, 2023, at 11:03 PM, Dr. Vijay Masand via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Dear all<div class="">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?</div><div class="">Thanks in advance.</div><div class="">From</div><div class="">Vijay</div><div class=""><br clear="all" class=""><div class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class="">With Warm Regards</div><div class=""><b class="">Dr. Vijay H. Masand</b></div><div class="">Department of Chemistry,<br class="">Vidya Bharati College, Amravati, 444 602<br class="">Maharashtra, India.<br class="">Phone number- +91-9403312628<br class=""><a href="https://sites.google.com/site/vijaymasand/" target="_blank" class="">https://sites.google.com/site/vijaymasand/</a><br class=""><br class=""></div></div></div></div></div></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class=""></div></blockquote></div><br class=""></div></body></html>