LOOS  v2.3.2
water-extract.cpp
1 /*
2  water-extract.cpp
3 
4  usage:
5  water-extract [options] model trajectory >output.pdb
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, Alan Grossfield
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 <iterator>
32 #include <boost/format.hpp>
33 #include <boost/program_options.hpp>
34 
35 #include <loos.hpp>
36 #include <DensityGrid.hpp>
37 #include <DensityTools.hpp>
38 #include <DensityOptions.hpp>
39 
40 
41 using namespace std;
42 using namespace loos;
43 using namespace loos::DensityTools;
44 
45 
46 
47 int main(int argc, char *argv[]) {
48  string hdr = invocationHeader(argc, argv);
49 
52  opts::BasicWater* watopts = new opts::BasicWater;
53 
54  opts::AggregateOptions options;
55  options.add(basopts).add(tropts).add(watopts);
56  if (!options.parse(argc, argv))
57  exit(-1);
58 
59 
60 
61  AtomicGroup model = tropts->model;
62  pTraj traj = tropts->trajectory;
63  vector<uint> frames = tropts->frameList();
64 
65  AtomicGroup subset = selectAtoms(model, watopts->prot_string);
66  AtomicGroup waters = selectAtoms(model, watopts->water_string);
67 
68  AtomicGroup liquid;
69  uint current_id = 1;
70 
71  for (vector<uint>::iterator t = frames.begin(); t != frames.end(); ++t) {
72 
73  traj->readFrame(*t);
74  traj->updateGroupCoords(model);
75 
76  vector<int> mask = watopts->filter_func->filter(waters, subset);
77  for (uint j=0; j<mask.size(); ++j)
78  if (mask[j]) {
79  pAtom atom(new Atom(*(waters[j])));
80  atom->id(current_id);
81  atom->resid(current_id++);
82  atom->segid("WATER");
83  liquid.append(atom);
84  }
85 
86  }
87 
88  PDB pdb = PDB::fromAtomicGroup(liquid);
89  pdb.remarks().add(hdr);
90  cout << pdb;
91 }
Remarks & remarks(void)
Accessor for the remarks object...
Definition: pdb.cpp:547
void add(const std::string s)
Add a remark.
Definition: pdb_remarks.cpp:52
Trajectory with either a –range or –skip.
Options specific to tools that work with water/internal-water.
AtomicGroup & append(pAtom pa)
Append the atom onto the group.
STL namespace.
bool parse(int argc, char *argv[])
Parses a command line, returning true if parsing was ok.
AtomicGroup model
Model that describes the trajectory.
virtual std::vector< int > filter(const loos::AtomicGroup &, const loos::AtomicGroup &)=0
Given a molecule and a set of waters, pick which waters are inside.
Basic Atom class for handling atom properties.
Definition: Atom.hpp:50
std::string water_string
User-specified strings.
Options common to all tools (including –fullhelp)
std::string invocationHeader(int argc, char *argv[])
Create an invocation header.
Definition: utils.cpp:124
Namespace for Density package.
Definition: DensityGrid.hpp:48
PDB reading/writing class.
Definition: pdb.hpp:69
AtomicGroup selectAtoms(const AtomicGroup &source, const std::string selection)
Applies a string-based selection to an atomic group...
Definition: utils.cpp:195
DensityTools::WaterFilterBase * filter_func
Filter for determining internal waters.
std::vector< uint > frameList() const
Returns the list of frames the user requested.
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.
Combines a set of OptionsPackages.
AggregateOptions & add(OptionsPackage *pack)
Add a pointer to an OptionsPackage that will be used for options.