| | 1 | = Flip Atom Z Coordinates = |
| | 2 | |
| | 3 | Here is Python code defining a command flip that changes atom z coordinates z -> -z. This changes the hand of the atomic structure, for instance changing all L amino acids to D amino acids. Open flip.py in ChimeraX 1.0 to define the flip command |
| | 4 | |
| | 5 | {{{ |
| | 6 | open flip.py |
| | 7 | }}} |
| | 8 | |
| | 9 | then use the command on the atomic model. |
| | 10 | |
| | 11 | {{{ |
| | 12 | flip #1 |
| | 13 | }}} |
| | 14 | |
| | 15 | [[Image(flip.png, 500px)]] |
| | 16 | |
| | 17 | Here is the [attachment:flip.py flip.py] code: |
| | 18 | |
| | 19 | {{{ |
| | 20 | # Create command to change atom coordiates z -> -z. |
| | 21 | # Opening this file in ChimeraX 1.0 defines the flip command. |
| | 22 | # |
| | 23 | # flip #1 |
| | 24 | |
| | 25 | def flip(session, atoms): |
| | 26 | xyz = atoms.coords |
| | 27 | xyz[:,2] *= -1 |
| | 28 | atoms.coords = xyz |
| | 29 | |
| | 30 | def register_command(session): |
| | 31 | from chimerax.core.commands import CmdDesc, register |
| | 32 | from chimerax.atomic import AtomsArg |
| | 33 | desc = CmdDesc(required=[('atoms', AtomsArg)], |
| | 34 | synopsis='flip atom z coordinates') |
| | 35 | register('flip', desc, flip, logger=session.logger) |
| | 36 | |
| | 37 | register_command(session) |
| | 38 | }}} |