LOOS  v2.3.2
enm-lib.hpp
1 
2 /*
3  This file is part of LOOS.
4 
5  LOOS (Lightweight Object-Oriented Structure library)
6  Copyright (c) 2010 Tod D. Romo
7  Department of Biochemistry and Biophysics
8  School of Medicine & Dentistry, University of Rochester
9 
10  This package (LOOS) is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation under version 3 of the License.
13 
14  This package is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 
29 #if !defined(LOOS_ENMLIB_HPP)
30 #define LOOS_ENMLIB_HPP
31 
32 #include <loos.hpp>
33 #include "hessian.hpp"
34 
36 namespace ENM {
37 
38  // -------------------------------------
39  // Support routines & types
40 
41 
43  void copyMasses(loos::AtomicGroup& target, const loos::AtomicGroup& source);
44 
45 
46 
48  void massFromPSF(loos::AtomicGroup& grp, const std::string& name);
49 
52 
53 
56 
57 
58  // -------------------------------------
59 
60 
61 
62  // This class describes the interface for all ENMs...
63  // To instantiate, you must pass a SuperBlock which determines how the
64  // hessian is built.
65 
68  public:
70 
75  ElasticNetworkModel(SuperBlock* blocker) : blocker_(blocker), name_("ENM"), prefix_(""), meta_(""), debugging_(false), verbosity_(0) { }
76  virtual ~ElasticNetworkModel() { }
77 
78  // Should we allow this?
79  void setSuperBlockFunction(SuperBlock* p) { blocker_ = p; }
80 
82  virtual void solve() =0;
83 
85  void prefix(const std::string& s) { prefix_ = s; }
86  std::string prefix() const { return(prefix_); }
87 
89  void meta(const std::string& s) { meta_ = s; }
90  std::string meta() const { return(meta_); }
91 
93  void debugging(const bool b) { debugging_ = b; }
94  bool debugging() const { return(debugging_); }
95 
97  void verbosity(const int i) { verbosity_ = i; }
98  int verbosity() const { return(verbosity_); }
99 
100  // -----------------------------------------------------
102  SpringFunction::Params setParams(const SpringFunction::Params& v) {
103  return(blocker_->setParams(v));
104  }
105 
107  bool validParams() const { return(blocker_->validParams()); }
108 
110  uint paramSize() const { return(blocker_->paramSize()); }
111  // -----------------------------------------------------
112 
113 
115  const loos::DoubleMatrix& eigenvectors() const { return(eigenvecs_); }
116 
118  const loos::DoubleMatrix& eigenvalues() const { return(eigenvals_); }
119 
121  const loos::DoubleMatrix& hessian() const { return(hessian_); }
122 
123 
124 
125  protected:
126 
127 
129 
133  void buildHessian();
134 
135 
136  protected:
137  // Arguably, some of the following should be private rather than
138  // protected... But for now, we'll just cheat and make 'em all
139  // protected..
140  SuperBlock* blocker_;
141  std::string name_;
142  std::string prefix_;
143  std::string meta_;
144  bool debugging_;
145  int verbosity_;
146 
147  loos::DoubleMatrix eigenvecs_;
148  loos::DoubleMatrix eigenvals_;
149 
150  loos::DoubleMatrix hessian_;
151 
152  };
153 
154 
155 };
156 
157 #endif
158 
159 
ElasticNetworkModel(SuperBlock *blocker)
Base constructor for all ENMs.
Definition: enm-lib.hpp:75
void copyMasses(AtomicGroup &target, const AtomicGroup &source)
Map masses from one group onto another... Minimal error checking...
Definition: enm-lib.cpp:34
Simple matrix template class using policy classes to determine behavior.
Definition: MatrixImpl.hpp:53
const loos::DoubleMatrix & eigenvectors() const
Accessors for eigenpairs and hessian.
Definition: enm-lib.hpp:115
void verbosity(const int i)
How wordy are we?
Definition: enm-lib.hpp:97
void debugging(const bool b)
Debugging flag (generally means write out all intermediate matrices)
Definition: enm-lib.hpp:93
This class creates superblocks in a hessian.
Definition: hessian.hpp:52
uint paramSize() const
Forwards to contained superblock.
Definition: enm-lib.hpp:110
virtual void solve()=0
Computes the hessian and solves for the eigenpairs.
DoubleMatrix getMasses(const AtomicGroup &grp)
Build the 3n x 3n diagonal mass matrix for a group.
Definition: enm-lib.cpp:65
void buildHessian()
Construct the hessian using the contained SuperBlock.
Definition: enm-lib.cpp:84
void massFromOccupancy(AtomicGroup &grp)
The masses are stored in the occupancy field of a PDB...
Definition: enm-lib.cpp:58
virtual SpringFunction::Params setParams(const SpringFunction::Params &v)
Forwards to the contained SpringFunction...
Definition: hessian.hpp:76
Namespace to encapsulate Elastic Network Model routines.
Definition: anm-lib.hpp:32
const loos::DoubleMatrix & eigenvalues() const
Accessors for eigenpairs and hessian.
Definition: enm-lib.hpp:118
bool validParams() const
Forwards to contained superblock.
Definition: enm-lib.hpp:107
virtual uint paramSize() const
Forwards to the contained SpringFunction...
Definition: hessian.hpp:84
virtual bool validParams() const
Forwards to the contained SpringFunction...
Definition: hessian.hpp:81
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
void meta(const std::string &s)
Any metadata that gets added to matrices written out.
Definition: enm-lib.hpp:89
void massFromPSF(AtomicGroup &grp, const string &name)
Copy the masses from a PSF onto a group.
Definition: enm-lib.cpp:51
const loos::DoubleMatrix & hessian() const
Accessors for eigenpairs and hessian.
Definition: enm-lib.hpp:121
Interface for all ENMs.
Definition: enm-lib.hpp:67
SpringFunction::Params setParams(const SpringFunction::Params &v)
Forwards to contained superblock.
Definition: enm-lib.hpp:102
void prefix(const std::string &s)
Filename prefix when we have to write something out.
Definition: enm-lib.hpp:85