Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PLMD::RMSD Class Reference

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. More...

#include <RMSD.h>

Public Member Functions

 RMSD ()
 Constructor. More...
 
void clear ()
 clear the structure More...
 
void set (const PDB &, std::string mytype, bool remove_center=true, bool normalize_weights=true)
 set reference, align and displace from input pdb structure: evtl remove com from the initial structure and normalize the input weights from the pdb More...
 
void set (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &reference, std::string mytype, bool remove_center=true, bool normalize_weights=true)
 set align displace reference and type from input vectors More...
 
void setType (std::string mytype)
 set the type of alignment we are doing More...
 
void setReference (const std::vector< Vector > &reference)
 set reference coordinates, remove the com by using uniform weights More...
 
void setAlign (const std::vector< double > &align, bool normalize_weights=true, bool remove_center=true)
 set weights and remove the center from reference with normalized weights. If the com has been removed, it resets to the new value More...
 
void setDisplace (const std::vector< double > &displace, bool normalize_weights=true)
 set align More...
 
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, std::vector< Vector > &derivatives, std::vector< Vector > &displacement, bool squared=false) const
 workhorses More...
 
template<bool safe, bool alEqDis>
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 > &DDistDPos, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_DDistDRef (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_SOMA (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_DDistDRef_Rot_DRotDPos (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_DDistDRef_Rot_DRotDPos_DRotDRef (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, Matrix< std::vector< Vector > > &DRotDRef, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_PCA (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &alignedpositions, std::vector< Vector > &centeredpositions, std::vector< Vector > &centeredreference, Tensor &Rotation, std::vector< Vector > &DDistDPos, Matrix< std::vector< Vector > > &DRotDPos, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_Fit (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, std::vector< Vector > &centeredpositions, Vector &center_positions, bool squared=false)
 
double calculate (const std::vector< Vector > &positions, std::vector< Vector > &derivatives, bool squared=false) const
 Compute rmsd: note that this is an intermediate layer which is kept in order to evtl expand with more alignment types/user options to be called while keeping the workhorses separated. More...
 
double calc_DDistDRef (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, const bool squared=false)
 Other convenience methods: calculate the derivative of distance respect to position(DDistDPos) and reference (DDistDPos) More...
 
double calc_SOMA (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, const bool squared=false)
 calculate the derivative for SOMA (i.e. derivative respect to reference frame without the matrix derivative) More...
 
double calc_DDistDRef_Rot_DRotDPos (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, const bool squared=false)
 
double calc_DDistDRef_Rot_DRotDPos_DRotDRef (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, std::vector< Vector > &DDistDRef, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, Matrix< std::vector< Vector > > &DRotDRef, const bool squared=false)
 
double calc_PCAelements (const std::vector< Vector > &pos, std::vector< Vector > &DDistDPos, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, std::vector< Vector > &alignedpositions, std::vector< Vector > &centeredpositions, std::vector< Vector > &centeredreference, const bool &squared=false) const
 convenience method to retrieve all the bits and pieces for PCA More...
 
double calc_FitElements (const std::vector< Vector > &pos, Tensor &Rotation, Matrix< std::vector< Vector > > &DRotDPos, std::vector< Vector > &centeredpositions, Vector &center_positions, const bool &squared=false)
 convenience method to retrieve all the bits and pieces needed by FitToTemplate More...
 

Static Public Member Functions

static Tensor getMatrixFromDRot (Matrix< std::vector< Vector > > &drotdpos, const unsigned &i, const unsigned &a)
 static convenience method to get the matrix i,a from drotdpos (which is a bit tricky) More...
 

Private Types

enum  AlignmentMethod { SIMPLE, OPTIMAL, OPTIMAL_FAST }
 

Private Member Functions

Vector calculateCenter (std::vector< Vector > &p, std::vector< double > &w)
 
void removeCenter (std::vector< Vector > &p, Vector &c)
 
void addCenter (std::vector< Vector > &p, Vector &c)
 

Private Attributes

AlignmentMethod alignmentMethod
 
std::vector< Vectorreference
 
std::vector< double > align
 
std::vector< double > displace
 
Vector reference_center
 
bool reference_center_is_calculated
 
bool reference_center_is_removed
 
Vector positions_center
 
bool positions_center_is_calculated
 
bool positions_center_is_removed
 

Detailed Description

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

#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);

Member Enumeration Documentation

Enumerator
SIMPLE 
OPTIMAL 
OPTIMAL_FAST 

Constructor & Destructor Documentation

PLMD::RMSD::RMSD ( )

Constructor.

Member Function Documentation

void PLMD::RMSD::addCenter ( std::vector< Vector > &  p,
Vector c 
)
inlineprivate
double PLMD::RMSD::calc_DDistDRef ( const std::vector< Vector > &  positions,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
const bool  squared = false 
)

Other convenience methods: calculate the derivative of distance respect to position(DDistDPos) and reference (DDistDPos)

convenience method for calculating the standard derivatives and the derivative of the rmsd respect to the reference position

double PLMD::RMSD::calc_DDistDRef_Rot_DRotDPos ( const std::vector< Vector > &  positions,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
const bool  squared = false 
)
double PLMD::RMSD::calc_DDistDRef_Rot_DRotDPos_DRotDRef ( const std::vector< Vector > &  positions,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
Matrix< std::vector< Vector > > &  DRotDRef,
const bool  squared = false 
)
double PLMD::RMSD::calc_FitElements ( const std::vector< Vector > &  pos,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
std::vector< Vector > &  centeredpositions,
Vector center_positions,
const bool &  squared = false 
)

convenience method to retrieve all the bits and pieces needed by FitToTemplate

double PLMD::RMSD::calc_PCAelements ( const std::vector< Vector > &  pos,
std::vector< Vector > &  DDistDPos,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
std::vector< Vector > &  alignedpositions,
std::vector< Vector > &  centeredpositions,
std::vector< Vector > &  centeredreference,
const bool &  squared = false 
) const

convenience method to retrieve all the bits and pieces for PCA

double PLMD::RMSD::calc_SOMA ( const std::vector< Vector > &  positions,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
const bool  squared = false 
)

calculate the derivative for SOMA (i.e. derivative respect to reference frame without the matrix derivative)

convenience method for calculating the standard derivatives and the derivative of the rmsd respect to the reference position without the matrix contribution as required by SOMA

double PLMD::RMSD::calculate ( const std::vector< Vector > &  positions,
std::vector< Vector > &  derivatives,
bool  squared = false 
) const

Compute rmsd: note that this is an intermediate layer which is kept in order to evtl expand with more alignment types/user options to be called while keeping the workhorses separated.

This is the main workhorse for rmsd that decides to use specific optimal alignment versions.

Vector PLMD::RMSD::calculateCenter ( std::vector< Vector > &  p,
std::vector< double > &  w 
)
inlineprivate
void PLMD::RMSD::clear ( )

clear the structure

static Tensor PLMD::RMSD::getMatrixFromDRot ( Matrix< std::vector< Vector > > &  drotdpos,
const unsigned &  i,
const unsigned &  a 
)
inlinestatic

static convenience method to get the matrix i,a from drotdpos (which is a bit tricky)

string PLMD::RMSD::getMethod ( )
template<bool safe, bool alEqDis>
template double PLMD::RMSD::optimalAlignment< false, false > ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  DDistDPos,
bool  squared = false 
) const
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_DDistDRef ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
bool  squared = false 
) const
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_DDistDRef_Rot_DRotDPos ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
bool  squared = false 
) const
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_DDistDRef_Rot_DRotDPos_DRotDRef ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
Matrix< std::vector< Vector > > &  DRotDRef,
bool  squared = false 
) const
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_Fit ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
Tensor Rotation,
Matrix< std::vector< Vector > > &  DRotDPos,
std::vector< Vector > &  centeredpositions,
Vector center_positions,
bool  squared = false 
)
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_PCA ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  alignedpositions,
std::vector< Vector > &  centeredpositions,
std::vector< Vector > &  centeredreference,
Tensor Rotation,
std::vector< Vector > &  DDistDPos,
Matrix< std::vector< Vector > > &  DRotDPos,
bool  squared = false 
) const
template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_SOMA ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  DDistDPos,
std::vector< Vector > &  DDistDRef,
bool  squared = false 
) const
void PLMD::RMSD::removeCenter ( std::vector< Vector > &  p,
Vector c 
)
inlineprivate
void PLMD::RMSD::set ( const PDB pdb,
std::string  mytype,
bool  remove_center = true,
bool  normalize_weights = true 
)

set reference, align and displace from input pdb structure: evtl remove com from the initial structure and normalize the input weights from the pdb

general method to set all the rmsd property at once by using a pdb where occupancy column sets the weights for the atoms involved in the alignment and beta sets the weight that are used for calculating the displacement.

void PLMD::RMSD::set ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  reference,
std::string  mytype,
bool  remove_center = true,
bool  normalize_weights = true 
)

set align displace reference and type from input vectors

void PLMD::RMSD::setAlign ( const std::vector< double > &  align,
bool  normalize_weights = true,
bool  remove_center = true 
)

set weights and remove the center from reference with normalized weights. If the com has been removed, it resets to the new value

the alignment weights are here normalized to 1 and the center of the reference is removed accordingly

void PLMD::RMSD::setDisplace ( const std::vector< double > &  displace,
bool  normalize_weights = true 
)

set align

here the weigth for normalized weighths are normalized and set

void PLMD::RMSD::setReference ( const std::vector< Vector > &  reference)

set reference coordinates, remove the com by using uniform weights

this calculates the center of mass for the reference and removes it from the reference itself considering uniform weights for alignment

void PLMD::RMSD::setType ( std::string  mytype)

set the type of alignment we are doing

double PLMD::RMSD::simpleAlignment ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  derivatives,
std::vector< Vector > &  displacement,
bool  squared = false 
) const

workhorses

Member Data Documentation

std::vector<double> PLMD::RMSD::align
private
AlignmentMethod PLMD::RMSD::alignmentMethod
private
std::vector<double> PLMD::RMSD::displace
private
Vector PLMD::RMSD::positions_center
private
bool PLMD::RMSD::positions_center_is_calculated
private
bool PLMD::RMSD::positions_center_is_removed
private
std::vector<Vector> PLMD::RMSD::reference
private
Vector PLMD::RMSD::reference_center
private
bool PLMD::RMSD::reference_center_is_calculated
private
bool PLMD::RMSD::reference_center_is_removed
private

The documentation for this class was generated from the following files: