LOOS  v2.3.2
flip_chirality.py
1 #!/usr/bin/env python
2 """
3  flip_chirality is a largely pointless tool -- it reads in a structure,
4  reverses the sign of the x coordinate, and prints it as a PDB to stdout.
5 """
6 """
7 
8  This file is part of LOOS.
9 
10  LOOS (Lightweight Object-Oriented Structure library)
11  Copyright (c) 2012 Alan Grossfield, Grossfield Lab
12  Department of Biochemistry and Biophysics
13  School of Medicine & Dentistry, University of Rochester
14 
15  This package (LOOS) is free software: you can redistribute it and/or modify
16  it under the terms of the GNU General Public License as published by
17  the Free Software Foundation under version 3 of the License.
18 
19  This package is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program. If not, see <http://www.gnu.org/licenses/>.
26 """
27 
28 import loos
29 import sys
30 
31 filename = sys.argv[1]
32 
33 system = loos.createSystem(filename)
34 
35 system.centerAtOrigin()
36 # loop over atoms and reverse the sign of the x coordinate
37 for i in range(system.size()):
38  # 2 different ways to assign to coordinates
39  # SWIG won't let us do: coords.x() = new_x
40  # so we can do this:
41  #system[i].coords().x(-system[i].coords().x())
42  # or this:
43  system[i].coords()[0] *= -1.0
44 
45 system.centerAtOrigin()
46 
47 # convert to PDB and print out
48 pdb = loos.PDB_fromAtomicGroup(system)
49 
50 # now rotate 180 degrees around the z axis
51 z_axis = loos.GCoord(0,0,1)
52 pdb.rotate(z_axis, 180)
53 
54 # print the pdb out
55 print pdb
56 
57 
58 
AtomicGroup createSystem(const std::string &filename, const std::string &filetype)
Definition: sfactories.cpp:119