<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>Atom objects have an 'element' attribute which in turn has 'name' and 'number' attributes.  The 'name' attribute is actually the atomic symbol, <i class="">e.g.</i><span style="font-style: normal;" class=""> H for hydrogen.</span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>You can use normal Python operations, such as 'not', to find these things, so the non-ring ligand atoms are: [a for a in ligand_atoms if not a.rings()]</div><div class=""><br class=""></div><div class="">--Eric<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 17, 2023, at 6:26 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="">Thank you for the details and nice solution, Eric. <div class="">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 class="">Thanks in advance.</div><div class=""> <br clear="all" class=""><div class=""><div dir="ltr" class="gmail_signature" data-smartmail="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><br class=""></div></div></div><br class=""><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" class="">pett@cgl.ucsf.edu</a>> wrote:<br class=""></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;" class="">Hi Vijay,<div class=""><span style="white-space:pre-wrap" class="">       </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 style="white-space:pre-wrap" class="">    </span>from chimerax.atomic import all_atoms</div><div class=""><span style="white-space:pre-wrap" class="">      </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 style="white-space:pre-wrap" class=""> </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 style="white-space:pre-wrap" class="">     </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 style="white-space:pre-wrap" class="">       </span>from chimerax.add_charge import add_charges</div><div class=""><span style="white-space:pre-wrap" class="">        </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 style="white-space:pre-wrap" class="">  </span>charge_sum = sum([a.charge for a in ligand_atoms])</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">  </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" 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 style="white-space:pre-wrap" class="">    </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 style="white-space:pre-wrap" class="">       </span>session.selection.clear()</div><div class=""><span style="white-space:pre-wrap" class="">  </span>for a in ring_atoms:</div><div class=""><span style="white-space:pre-wrap" class="">               </span>a.selected = True</div><div class=""><br class=""></div><div class=""><div class="">--Eric</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">      </span>Eric Pettersen</div><div class=""><span style="white-space:pre-wrap" class="">     </span>UCSF Computer Graphics Lab</div></div><div class=""><br class=""><div class=""><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" target="_blank" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div><br class=""><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=""><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" target="_blank" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class=""><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank" class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></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>