forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RMSD.h
114 lines (100 loc) · 3.74 KB
/
RMSD.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2013 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifndef __PLUMED_tools_RMSD_h
#define __PLUMED_tools_RMSD_h
#include "Vector.h"
#include <vector>
#include <string>
namespace PLMD{
class Log;
class PDB;
class OptimalAlignment;
/** \ingroup TOOLBOX
A class that implements RMSD calculations
This is a class that implements the various infrastructure to calculate the
RMSD or MSD respect a given frame. It can be done through an optimal alignment scheme
as Kearsley or, more simply, by resetting the center of mass.
This is the class that decides this. A very simple use is
\verbatim
#include "tools/PDB.h"
#include "tools/RMSD.h"
#include "tools/Vector.h"
using namespace PLMD;
RMSD rmsd;
PDB pdb;
// get the pdb (see PDB documentation)
pdb.read("file.pdb",true,1.0);
string type;
type.assign("OPTIMAL");
// set the reference and the type
rmsd.set(pdb,type);
// this calculates the rmsd and the derivatives
vector<Vector> derivs;
double val;
val=rmsd.calculate(getPositions(),derivs,true);
\endverbatim
**/
class RMSD
{
enum AlignmentMethod {SIMPLE, OPTIMAL, OPTIMAL_FAST};
AlignmentMethod alignmentMethod;
std::vector<Vector> reference;
std::vector<double> align;
std::vector<double> displace;
OptimalAlignment *myoptimalalignment;
Log *log;
public:
/// Constructor
RMSD(Log & log );
/// a copy constructor
RMSD(const RMSD &);
/// assignment
RMSD& operator=(const RMSD& );
/// the destructor needs to delete the myalignment object eventually
~RMSD();
/// clear the structure
void clear();
/// set reference, align and displace from input pdb structure
void set(const PDB&, std::string mytype);
/// set the type of alignment we are doing
void setType(std::string mytype);
/// set reference coordinates
void setReference(const std::vector<Vector> & reference);
/// set weights
void setAlign(const std::vector<double> & align);
/// set align
void setDisplace(const std::vector<double> & displace);
///
std::string getMethod();
///
double simpleAlignment(const std::vector<double> & align,
const std::vector<double> & displace,
const std::vector<Vector> & positions,
const std::vector<Vector> & reference ,
Log* &log,
std::vector<Vector> & derivatives, bool squared=false);
template <bool safe>
double optimalAlignment(const std::vector<double> & align,
const std::vector<double> & displace,
const std::vector<Vector> & positions,
const std::vector<Vector> & reference ,
std::vector<Vector> & derivatives, bool squared=false);
/// Compute rmsd
double calculate(const std::vector<Vector> & positions,std::vector<Vector> &derivatives, bool squared=false);
};
}
#endif