<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Thibault,<div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>It seems to me that what your copy_torsion() function really wants is just two residues. I'd have your command register just a ResiduesArg (from chimerax.atomic) and have your function take just 'session' and 'residues' args. The function could check if len(residues) == 2 if you wanted. You would copy the psi angle from the second residue to the first with residues[0].psi = residues[1].psi. Phi/omega would work the same way. What you would then type to your command would be something like "copyTorsion #1:231 #2:231". </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 class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 31, 2022, at 6:52 AM, Thibault TUBIANA 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 class=""><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;" class=""><div class="">Hi!</div><div class=""><br data-mce-bogus="1" class=""></div><div class="">I would like to create a function to copy the torsion angle from a model to another one.</div><div class="">The function would take in argument the model ID of the reference and target model (<int>) and the residue id (<int>).</div><div class="">I looked a bit at the scripts available in <a href="https://rbvi.github.io/chimerax-recipes/" class="">https://rbvi.github.io/chimerax-recipes/</a> to have an idea of how to add function in ChimeraX, but I'm currently stuck at "how to get the list of atoms from a selection string ?".</div><div class=""><br data-mce-bogus="1" class=""></div><div class="">Here's my current script </div><div class=""><hr class=""></div><div class=""><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class="">from chimerax.core.commands import run</span></div><div class=""><br class=""></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class="">def copy_torsion(session, model1, model2, residue):</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> selection = f"torsion #{model2}:{residue}@n,ca,c:{residue+1}@n"</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> from chimerax.atomic import AtomsArg</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> atoms = AtomsArg(selection) </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> from chimerax.geometry import dihedral </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> cur_torsion = dihedral([*a.scene_coord for a in atoms])</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> torsion=run(session, f"torsion #{model1}:{residue}@n,ca,c:{residue+1}@n {cur_torsion}")</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> </span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class="">def register_command(logger):</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> from chimerax.core.commands import CmdDesc, register, FloatArg, IntArg, BoolArg, Color8Arg, StringArg</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> from chimerax.atomic import AtomsArg</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> desc = CmdDesc(required = [</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> ('model1', IntArg),</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> ('model2', IntArg),</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> ('residue', IntArg),</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> ],</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> synopsis='Copy torsion angle')</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> register('copyTorsion', desc, copy_torsion, logger=logger)</span></div><div class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""> <!--StartFragment--></span><div style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" class=""><br class=""></div><div style="font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial;" data-mce-style="color: #000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" class=""><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class="">register_command(session)</span></div><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;" class=""><!--EndFragment--> </span></div><div class=""><hr class=""></div><div class="">Thank you for your help :)</div><div class=""><br class="">Best regards,</div><div class="">Thibault.</div></div><div class=""><br class=""></div><div class=""><br data-mce-bogus="1" class=""></div><div data-marker="__SIG_PRE__" class=""><div class="">--<br class="">Thibault Tubiana, PhD</div><div class="">Postdoctoral Fellow @<a href="https://www.i2bc.paris-saclay.fr/equipe-interactions-and-assembly-mechanisms-of-proteins-and-peptides/" target="_blank" class="">IMAPP</a><br class=""></div><div class=""><div class=""><span style="font-size: 12pt;" class="">Institute for integrative biology of the cell (<a href="https://www.i2bc.paris-saclay.fr/" target="_blank" class="">I2BC</a>) - CNRS UMR 9198</span><br class=""></div><div class="">CEA Saclay, 91191 Gif sur Yvette - Bât 532 pce 34</div><div class="">Web Site: <a href="http://www.tubiana.me/" target="_blank" class="">http://www.tubiana.me/</a><br class=""></div></div><div class=""><br class=""></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>