LOOS  v2.3.2
water-count.cpp
1 /*
2  water-count.cpp
3 
4  usage:
5  water-count prefix >output.asc
6 
7  Description:
8  Counts the number of waters that are inside the protein at each
9  timepoint and writes this out as a vector. In other words, it
10  just sums the rows for each column of the water matrix.
11 */
12 
13 
14 
15 /*
16  This file is part of LOOS.
17 
18  LOOS (Lightweight Object-Oriented Structure library)
19  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
20  Department of Biochemistry and Biophysics
21  School of Medicine & Dentistry, University of Rochester
22 
23  This package (LOOS) is free software: you can redistribute it and/or modify
24  it under the terms of the GNU General Public License as published by
25  the Free Software Foundation under version 3 of the License.
26 
27  This package is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  GNU General Public License for more details.
31 
32  You should have received a copy of the GNU General Public License
33  along with this program. If not, see <http://www.gnu.org/licenses/>.
34 */
35 
36 
37 
38 #include <loos.hpp>
39 #include <boost/format.hpp>
40 
41 
42 using namespace std;
43 using namespace loos;
44 
45 
46 int main(int argc, char *argv[]) {
47  string hdr = invocationHeader(argc, argv);
48 
49  if (argc != 2) {
50  cerr << "Usage - water-count prefix >output.asc\n";
51  cerr << "\nGiven a matrix of water classifications from water-inside,\n";
52  cerr << "counts the number of waters that are inside the\n";
53  cerr << "protein at each timepoint and writes this out as a 1-column\n";
54  cerr << "matrix.\n\n";
55  cerr << "See also water-inside.\n";
56 
57  exit(-1);
58  }
59 
60  string prefix(argv[1]);
61 
63  readAsciiMatrix(prefix + ".vol", V);
64 
66  readAsciiMatrix(prefix + ".asc", M);
67  uint m = M.rows();
68  uint n = M.cols();
69 
70  if (V.rows() != M.cols()) {
71  cerr << "ERROR - mismatch in volume and water matrix\n";
72  exit(-10);
73  }
74 
75  cout << "# " << hdr << endl;
76  cout << "# frame\tcount\tvolume\n";
77  for (uint i=0; i<n; ++i) {
78  long cnt = 0;
79  for (uint j=0; j<m; ++j)
80  cnt += M(j,i);
81  cout << i << "\t" << cnt << "\t" << V(i,0) << endl;
82  }
83 }
Simple matrix template class using policy classes to determine behavior.
Definition: MatrixImpl.hpp:53
STL namespace.
std::string invocationHeader(int argc, char *argv[])
Create an invocation header.
Definition: utils.cpp:124
Math::Matrix< T, P, S > readAsciiMatrix(std::istream &is)
Read in a matrix from a stream returning a newly created matrix.
Definition: MatrixRead.hpp:72
Namespace for most things not already encapsulated within a class.