LOOS  v2.3.2
assign_frames.cpp
1 /*
2  Assign frames of a trajectory to bins (determined by reference structures)
3 */
4 
5 
6 
7 /*
8 
9  This file is part of LOOS.
10 
11  LOOS (Lightweight Object-Oriented Structure library)
12  Copyright (c) 2011, Tod D. Romo
13  Department of Biochemistry and Biophysics
14  School of Medicine & Dentistry, University of Rochester
15 
16  This package (LOOS) is free software: you can redistribute it and/or modify
17  it under the terms of the GNU General Public License as published by
18  the Free Software Foundation under version 3 of the License.
19 
20  This package is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with this program. If not, see <http://www.gnu.org/licenses/>.
27 */
28 
29 
30 
31 #include <loos.hpp>
32 
33 #include "fid-lib.hpp"
34 
35 using namespace std;
36 using namespace loos;
37 
38 
39 string fullHelpMessage(void) {
40  string msg =
41  "\n"
42  "SYNOPSIS\n"
43  "\tConstruct a structural histogram given a set of fiducial structures\n"
44  "\n"
45  "DESCRIPTION\n"
46  "\n"
47  "\tThis tool assigns the frames of a trajectory to the closest bin based\n"
48  "on the fiducial structures given. See Lyman & Zuckerman,\n"
49  "J Phys Chem B (2007) 111:12876-12882 for more details.\n"
50  "\n"
51  "EXAMPLES\n"
52  "\n"
53  "\tassign_frames model.pdb simulation.dcd all 'name == \"CA\"' \\\n"
54  "\t zuckerman.dcd >assignments.asc\n"
55  "This example assigns all frames in simulation.dcd using the fiducials stored in zuckerman.dcd,\n"
56  "writing the assignments to assignments.asc.\n"
57  "\n"
58  "NOTES\n"
59  "\tThe selection used here must match that given to ufidpick\n"
60  "SEE ALSO\n"
61  "\tufidpick, effsize.pl, hierarchy, neff\n";
62 
63  return(msg);
64 }
65 
66 
67 int main(int argc, char *argv[]) {
68  string hdr = invocationHeader(argc, argv);
69 
70  if (argc != 6) {
71  cerr << "Usage - " << argv[0] << " model trajectory range selection fiducials.dcd >assignments.asc\n";
72  fullHelpMessage();
73  exit(-1);
74  }
75 
76  int k = 1;
77  AtomicGroup model = createSystem(argv[k++]);
78  pTraj traj = createTrajectory(argv[k++], model);
79  string range(argv[k++]);
80  string selection(argv[k++]);
81 
82  AtomicGroup subset = selectAtoms(model, selection);
83  AtomicGroup ref_model = subset.copy();
84  ref_model.resetAtomIndices();
85 
86  pTraj fiducials = createTrajectory(argv[k++], ref_model);
87 
88  vecUint frames;
89  if (range == "all")
90  for (uint i=0; i<traj->nframes(); ++i)
91  frames.push_back(i);
92  else
93  frames = parseRangeList<uint>(range);
94 
95  vecGroup refs;
96  cerr << "Reading fiducials...\n";
97  readTrajectory(refs, ref_model, fiducials);
98  cerr << "Read in " << refs.size() << " fiducials.\n";
99  cerr << "Assigning...\n";
100  vecUint assigned = assignStructures(subset, traj, frames, refs);
101  cout << "# " << hdr << endl;
102  copy(assigned.begin(), assigned.end(), ostream_iterator<uint>(cout, "\n"));
103 
104 }
STL namespace.
AtomicGroup createSystem(const std::string &filename)
Factory function for reading in structure files.
Definition: sfactories.cpp:115
std::string invocationHeader(int argc, char *argv[])
Create an invocation header.
Definition: utils.cpp:124
AtomicGroup selectAtoms(const AtomicGroup &source, const std::string selection)
Applies a string-based selection to an atomic group...
Definition: utils.cpp:195
AtomicGroup copy(void) const
Creates a deep copy of this group.
Definition: AtomicGroup.cpp:56
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.
void resetAtomIndices()
Reset the atom indices (used for interfacing with trajectories)