<div dir="ltr">Thank you for the details and nice solution, Eric. <div>How can I extend the above code to select ring nitrogen and oxygen atoms and to sum charges on different atoms (ring/non-ring)?<div>Thanks in advance.</div><div> <br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>With Warm Regards</div><div><b>Dr. Vijay H. Masand</b></div><div>Department of Chemistry,<br>Vidya Bharati College, Amravati, 444 602<br>Maharashtra, India.<br>Phone number- +91-9403312628<br><a href="https://sites.google.com/site/vijaymasand/" target="_blank">https://sites.google.com/site/vijaymasand/</a><br><br></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 18, 2023 at 1:36 AM Eric Pettersen <<a href="mailto:pett@cgl.ucsf.edu">pett@cgl.ucsf.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Hi Vijay,<div><span style="white-space:pre-wrap"> </span>I don't know exactly how efficient you need things to be, but here is some info...</div><div><br></div><div><i>Get all atoms</i><span style="font-style:normal">:</span></div><div><span style="white-space:pre-wrap"> </span>from chimerax.atomic import all_atoms</div><div><span style="white-space:pre-wrap"> </span>atoms = all_atoms(session)</div><div><br></div><div><i>Filter down to just ligand atoms</i><span style="font-style:normal">:</span></div><div><span style="white-space:pre-wrap"> </span>ligand_atoms = atoms.filter(atoms.structure_categories == "ligand")</div><div><br></div><div><i>Ligand ring atoms</i><span style="font-style:normal">:</span></div><div><span style="white-space:pre-wrap"> </span>ring_atoms = [a for a in ligand_atoms if a.rings()]</div><div><br></div><div><i>Assign charges to ligand residues</i><span style="font-style:normal">:</span></div><div><span style="white-space:pre-wrap"> </span>from chimerax.add_charge import add_charges</div><div><span style="white-space:pre-wrap"> </span>add_charges(session, ligand_atoms.unique_residues)</div><div><br></div><div><i>Sum the charges</i><span style="font-style:normal">:</span></div><div><span style="white-space:pre-wrap"> </span>charge_sum = sum([a.charge for a in ligand_atoms])</div><div><br></div><div><span style="white-space:pre-wrap"> </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" target="_blank">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><span style="white-space:pre-wrap"> </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><br></div><div><span style="white-space:pre-wrap"> </span>session.selection.clear()</div><div><span style="white-space:pre-wrap"> </span>for a in ring_atoms:</div><div><span style="white-space:pre-wrap"> </span>a.selected = True</div><div><br></div><div><div>--Eric</div><div><br></div><div><span style="white-space:pre-wrap"> </span>Eric Pettersen</div><div><span style="white-space:pre-wrap"> </span>UCSF Computer Graphics Lab</div></div><div><br><div><br><blockquote type="cite"><div>On Jan 16, 2023, at 11:03 PM, Dr. Vijay Masand via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" target="_blank">chimerax-users@cgl.ucsf.edu</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr">Dear all<div>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>Thanks in advance.</div><div>From</div><div>Vijay</div><div><br clear="all"><div><div dir="ltr"><div dir="ltr"><div>With Warm Regards</div><div><b>Dr. Vijay H. Masand</b></div><div>Department of Chemistry,<br>Vidya Bharati College, Amravati, 444 602<br>Maharashtra, India.<br>Phone number- +91-9403312628<br><a href="https://sites.google.com/site/vijaymasand/" target="_blank">https://sites.google.com/site/vijaymasand/</a><br><br></div></div></div></div></div></div></div>
_______________________________________________<br>ChimeraX-users mailing list<br><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank">ChimeraX-users@cgl.ucsf.edu</a><br>Manage subscription:<br><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br></div></blockquote></div><br></div></div></blockquote></div>