LOOS  v2.3.2
protein_tilt.py
1 #!/usr/bin/env python
2 
3 import loos
4 import loos.pyloos
5 import sys
6 import math
7 
8 if len(sys.argv) < 4 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
9  print "Usage: ", sys.argv[0], " system trajectory selection1 [selection2...]"
10  print " Prints the average of the orientation vectors of the "
11  print " individual selections, assuming each individual vector "
12  print " points in the +z direction"
13  sys.exit()
14 
15 #print len(sys.argv)
16 print "#", " ".join(sys.argv)
17 system_filename = sys.argv[1]
18 traj_filename = sys.argv[2]
19 selections = sys.argv[3:]
20 
21 
22 system = loos.createSystem(system_filename)
23 traj = loos.pyloos.Trajectory(traj_filename, system)
24 
25 helices = []
26 for s in selections:
27  helices.append(loos.selectAtoms(system, s))
28 
29 
30 
31 print "#Frame\tAngle\tCosine"
32 
33 for frame in traj:
34 
35  vec = loos.GCoord(0.,0.,0.)
36  for h in helices:
37  pca = h.principalAxes()
38  v = pca[0]
39  if v.z() < 0:
40  v *= -1.
41  vec += v
42 
43  cosine = vec.z() / vec.length()
44 
45  cosine = max(-1.0, cosine)
46  cosine = min(1.0, cosine)
47  ang = math.acos(cosine) * 180./math.pi
48 
49  print traj.index(), ang, cosine
50 
51 
Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more pyt...
Definition: trajectories.py:55
AtomicGroup selectAtoms(const AtomicGroup &source, const std::string selection)
Applies a string-based selection to an atomic group...
Definition: utils.cpp:195
AtomicGroup createSystem(const std::string &filename, const std::string &filetype)
Definition: sfactories.cpp:119