LOOS  v2.3.2
rmsd_to_average.py
1 #!/usr/bin/env python
2 """
3  Compute an optimal average structure using an iterative alignment method, then
4  output the RMSD from each frame and the average structure
5 """
6 """
7 
8  This file is part of LOOS.
9 
10  LOOS (Lightweight Object-Oriented Structure library)
11  Copyright (c) 2012 Tod Romo, 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 
29 
30 # Import LOOS
31 import loos
32 import loos.pyloos
33 import argparse
34 import sys
35 
36 
37 parser = argparse.ArgumentParser()
38 parser.add_argument('model', help='Structure to use')
39 parser.add_argument('traj', help='Trajectory')
40 parser.add_argument('align', help='Selection to use for aligning')
41 parser.add_argument('--skip', help='Skip this amount from the start of the trajectory', type=int, default=0)
42 parser.add_argument('--stride', help='Step through the trajectory by this many frames', type=int, default=1)
43 parser.add_argument('--rmsd', help='Use this selection for computing the RMSD', default='all')
44 args = parser.parse_args()
45 
46 # Create the model & read in the trajectory
47 model = loos.createSystem(args.model)
48 traj = loos.pyloos.Trajectory(args.traj, model, skip = args.skip, stride = args.stride)
49 
50 patraj = loos.pyloos.AlignedVirtualTrajectory(traj, alignwith = args.align)
51 patraj.setSubset(args.rmsd)
52 average = loos.pyloos.averageStructure(traj)
53 
54 
55 avg_rmsd = 0
56 for structure in patraj:
57  rmsd = average.rmsd(structure)
58  avg_rmsd = avg_rmsd + rmsd
59  print "%d\t%f" % (patraj.index(), rmsd)
60 
61 print "# Average rmsd = %f" % (avg_rmsd/t)
62 
63 
64 
Python-based wrapper for LOOS Trajectories This class turns a loos Trajectory into something more pyt...
Definition: trajectories.py:55
A virtual trajectory that supports iterative alignment.
AtomicGroup createSystem(const std::string &filename, const std::string &filetype)
Definition: sfactories.cpp:119