Hi!
I would like to create a function to copy the torsion angle from a model to another one. The function would take in argument the model ID of the reference and target model (<int>) and the residue id (<int>). I looked a bit at the scripts available in [ https://rbvi.github.io/chimerax-recipes/ | https://rbvi.github.io/chimerax-recipes/ ] 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 ?".
Here's my current script
from chimerax.core.commands import run
def copy_torsion(session, model1, model2, residue): selection = f"torsion #{model2}:{residue}@n,ca,c:{residue+1}@n" from chimerax.atomic import AtomsArg atoms = AtomsArg(selection) from chimerax.geometry import dihedral cur_torsion = dihedral([*a.scene_coord for a in atoms]) torsion=run(session, f"torsion #{model1}:{residue}@n,ca,c:{residue+1}@n {cur_torsion}") def register_command(logger): from chimerax.core.commands import CmdDesc, register, FloatArg, IntArg, BoolArg, Color8Arg, StringArg from chimerax.atomic import AtomsArg desc = CmdDesc(required = [ ('model1', IntArg), ('model2', IntArg), ('residue', IntArg), ], synopsis='Copy torsion angle') register('copyTorsion', desc, copy_torsion, logger=logger)
register_command(session)
Thank you for your help :)
Best regards, Thibault.