LOOS  v2.3.2
simple_model_calc.cpp
1 /*
2  simple_model_calc.cpp
3 
4  (c) 2011 Tod D. Romo, Grossfield Lab
5  Department of Biochemistry
6  University of Rochster School of Medicine and Dentistry
7 
8 
9  C++ template for writing a tool that performs a calculation on a model with minimal
10  command-line options
11 */
12 
13 
14 /*
15  This file is part of LOOS.
16 
17  LOOS (Lightweight Object-Oriented Structure library)
18  Copyright (c) 2011 Tod D. Romo
19  Department of Biochemistry and Biophysics
20  School of Medicine & Dentistry, University of Rochester
21 
22  This package (LOOS) is free software: you can redistribute it and/or modify
23  it under the terms of the GNU General Public License as published by
24  the Free Software Foundation under version 3 of the License.
25 
26  This package is distributed in the hope that it will be useful,
27  but WITHOUT ANY WARRANTY; without even the implied warranty of
28  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  GNU General Public License for more details.
30 
31  You should have received a copy of the GNU General Public License
32  along with this program. If not, see <http://www.gnu.org/licenses/>.
33 
34 */
35 
36 
37 
38 #include <loos.hpp>
39 
40 using namespace std;
41 using namespace loos;
42 
43 
44 
45 int main(int argc, char *argv[]) {
46 
47  // How the tool was invoked, for logging purposes...
48  string header = invocationHeader(argc, argv);
49 
50  // ***EDIT***
51  // Verify correct number of command-line arguments
52  if (argc != 3) {
53  cerr << "Usage- simple_model_calc model-name selection\n";
54  }
55 
56  // Handle command-line arguments
57  int arg_index = 1;
58 
59  // Read in the model
60  AtomicGroup model = createSystem(argv[arg_index++]);
61 
62  // Select a subset of it
63  AtomicGroup subset = selectAtoms(model, argv[arg_index++]);
64 
65  // ***EDIT***
66  // Iterate over all atoms in the subset, performing some computation
67  for (AtomicGroup::iterator atom = subset.begin(); atom != subset.end(); ++atom) {
68  // Do something
69  // calculateSomething(*atom)
70  }
71 
72  // ***EDIT***
73  // Show results...
74 
75 }
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
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.