| 1 | # Example of how to copy a molecule with moved atoms.
|
|---|
| 2 |
|
|---|
| 3 | import chimera
|
|---|
| 4 | m = chimera.openModels.list(modelTypes = [chimera.Molecule])[0]
|
|---|
| 5 |
|
|---|
| 6 | # Make copy
|
|---|
| 7 | from Molecule import copy_molecule
|
|---|
| 8 | mc = copy_molecule(m)
|
|---|
| 9 |
|
|---|
| 10 | # Set copy name
|
|---|
| 11 | mc.name = m.name + ' copy'
|
|---|
| 12 |
|
|---|
| 13 | # Change atom coordinates
|
|---|
| 14 | xf = chimera.Xform.translation(chimera.Vector(20,0,0))
|
|---|
| 15 | from MoleculeTransform import transform_atom_coordinates
|
|---|
| 16 | transform_atom_coordinates(mc.atoms, xf)
|
|---|
| 17 |
|
|---|
| 18 | # Add copy to list of open models
|
|---|
| 19 | chimera.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.
|
|---|
| 23 | mc.openState.xform = m.openState.xform
|
|---|