Scripts: copymol.py

File copymol.py, 657 bytes (added by goddard, 9 years ago)
Line 
1# Example of how to copy a molecule with moved atoms.
2
3import chimera
4m = chimera.openModels.list(modelTypes = [chimera.Molecule])[0]
5
6# Make copy
7from Molecule import copy_molecule
8mc = copy_molecule(m)
9
10# Set copy name
11mc.name = m.name + ' copy'
12
13# Change atom coordinates
14xf = chimera.Xform.translation(chimera.Vector(20,0,0))
15from MoleculeTransform import transform_atom_coordinates
16transform_atom_coordinates(mc.atoms, xf)
17
18# Add copy to list of open models
19chimera.openModels.add([mc])
20
21# Make sure molecule copy gets same position as molecule.
22# By default it gets same position as model with lowest id number.
23mc.openState.xform = m.openState.xform