LOOS  v2.3.2
domain.py
1 #!/usr/bin/env python
2 #
3 # domain.py: track the motions of 2 portions of a protein, printing out the
4 # distance between the centroids, as well as the angle and torsion
5 # between the two domains first principal axis
6 # NOTE: This was written assuming the two chunks are part of the
7 # same molecule, and so doesn't respect periodicity.
8 # Alan Grossfield
9 
10 import sys
11 import loos
12 import loos.pyloos
13 import math
14 
15 header = " ".join(sys.argv)
16 print "# ", header
17 
18 system_file = sys.argv[1]
19 traj_file = sys.argv[2]
20 sel_string1 = sys.argv[3]
21 sel_string2 = sys.argv[4]
22 
23 system = loos.createSystem(system_file)
24 traj = loos.pyloos.Trajectory(traj_file, system)
25 
26 sel1 = loos.selectAtoms(system, sel_string1)
27 sel2 = loos.selectAtoms(system, sel_string2)
28 
29 for frame in traj:
30 
31  # compute distance
32  centroid1 = sel1.centroid()
33  centroid2 = sel2.centroid()
34 
35  diff = centroid2 - centroid1
36  distance = diff.length()
37 
38  # Compute angle between principal axes
39  vectors1 = sel1.principalAxes()
40  axis1 = vectors1[0]
41 
42  vectors2 = sel2.principalAxes()
43  axis2 = vectors2[0]
44  angle = math.acos(axis1 * axis2) * 180/math.pi
45 
46  # Compute torsion between principal axes
47  p1 = centroid1 + axis1
48  p2 = centroid2 + axis2
49 
50  tors = loos.torsion(p1, centroid1, centroid2, p2)
51 
52  # write output
53  print traj.index(), distance, angle, tors
54 
55 
56 
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