LOOS  v2.3.2
psf-masses.cpp
1 /*
2  psf-masses
3 
4 
5  Takes masses from a PSF file and places them into the occupancy field of a PDB.
6 
7 */
8 
9 
10 /*
11  This file is part of LOOS.
12 
13  LOOS (Lightweight Object-Oriented Structure library)
14  Copyright (c) 2009 Tod D. Romo
15  Department of Biochemistry and Biophysics
16  School of Medicine & Dentistry, University of Rochester
17 
18  This package (LOOS) is free software: you can redistribute it and/or modify
19  it under the terms of the GNU General Public License as published by
20  the Free Software Foundation under version 3 of the License.
21 
22  This package is distributed in the hope that it will be useful,
23  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  GNU General Public License for more details.
26 
27  You should have received a copy of the GNU General Public License
28  along with this program. If not, see <http://www.gnu.org/licenses/>.
29 
30 */
31 
32 
33 
34 
35 #include <loos.hpp>
36 
37 
38 using namespace loos;
39 using namespace std;
40 
41 
42 pAtom findMatch(const pAtom& probe, const AtomicGroup& grp) {
43  for (AtomicGroup::const_iterator i = grp.begin(); i != grp.end(); ++i)
44  if ((*i)->name() == probe->name() && (*i)->id() == probe->id()
45  && (*i)->resname() == probe->resname() && (*i)->resid() == probe->resid()
46  && (*i)->segid() == probe->segid())
47  return(*i);
48 
49  pAtom null;
50  return(null);
51 }
52 
53 
54 string fullHelpMessage(void) {
55  string msg =
56  "\n"
57  "SYNOPSIS\n"
58  "\n"
59  "Places masses from a PSF file into the occupancy field of a PDB\n"
60  "\n"
61  "DESCRIPTION\n"
62  "\n"
63  "Places masses from a PSF file into a PDB file using the occupancy\n"
64  "column. This is useful for ENMs like VSA, which can account for\n"
65  "varying masses on the beads. The LOOS VSA tool can read masses from\n"
66  "the occupancy column with the -o1 option.\n"
67  "\n"
68  "Note: The psf and pdb must contain the same atoms.\n"
69  "\n"
70  //
71  "EXAMPLES\n"
72  "\n"
73  "psf-masses model.psf model.pdb > newmodel.pdb \n"
74  "\tGiven model.psf and model.pdb put the masses from the\n"
75  "\tpsf file in a PDB called newmodel.pdb. The other info\n"
76  "\tis obtained from model.pdb\n"
77  "\n"
78  "SEE ALSO\n"
79  "\n"
80  "Packages/ElasticNetworks/heavy-ca - \n"
81  "\tThis tool will sum the masses of a residue using\n"
82  "\tthe value in the occupancy field and place the total\n"
83  "\tmass on the CA for use in an ENM.\n"
84  "\n"
85  "\n";
86 
87  return(msg);
88 }
89 
90 
91 int main(int argc, char *argv[]) {
92  if (argc != 3) {
93  cerr << "Usage- psf-masses model.psf model.pdb >newmodel.pdb\n";
94  cerr << fullHelpMessage();
95  exit(0);
96  }
97 
98  string hdr = invocationHeader(argc, argv);
99 
100  AtomicGroup source = createSystem(argv[1]);
101  AtomicGroup target = createSystem(argv[2]);
102 
103  for (AtomicGroup::iterator i = target.begin(); i != target.end(); ++i) {
104  pAtom match = findMatch(*i, source);
105  if (!match) {
106  cerr << "ERROR- no match found for atom " << **i << endl;
107  exit(-1);
108  }
109 
110  if (!match->checkProperty(Atom::massbit)) {
111  cerr << "ERROR- Atom has no mass: " << *match << endl;
112  exit(-1);
113  }
114 
115  (*i)->occupancy(match->mass());
116  }
117 
118 
119  PDB pdb = PDB::fromAtomicGroup(target);
120  pdb.remarks().add(hdr);
121  cout << pdb;
122 }
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
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
PDB reading/writing class.
Definition: pdb.hpp:69
static PDB fromAtomicGroup(const AtomicGroup &)
Class method for creating a PDB from an AtomicGroup.
Definition: pdb.cpp:528
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.