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

#include <RMSD.h>

Public Member Functions

 RMSD ()
 Constructor. 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_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_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...
 
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_Rot (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, Tensor &Rotation, const bool squared=false)
 calculate rotation matrix, derivative of rotation matrix w.r.t. positions More...
 
double calc_Rot_DRotDRr01 (const std::vector< Vector > &positions, Tensor &Rotation, std::array< std::array< Tensor, 3 >, 3 > &DRotDRr01, const bool squared=false)
 calculate rotation matrix, derivative of rotation matrix w.r.t. positions, derivative of rotation matrix w.r.t. rr01 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 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 calculateWithCloseStructure (const std::vector< Vector > &positions, std::vector< Vector > &DDistDPos, const Tensor &rotationPosClose, const Tensor &rotationRefClose, std::array< std::array< Tensor, 3 >, 3 > &drotationPosCloseDrr01, const bool squared=false)
 calculate with close structure, i.e. approximate the RMSD without expensive computation of rotation matrix by reusing saved rotation matrices from previous iterations More...
 
void clear ()
 clear the structure More...
 
std::vector< double > getAlign ()
 
std::vector< double > getDisplace ()
 
std::string getMethod ()
 
const std::vector< Vector > & getReference () const
 
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_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_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 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_Rot (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &derivatives, Tensor &Rotation, bool squared=false) const
 
template<bool safe, bool alEqDis>
double optimalAlignment_Rot_DRotDRr01 (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, Tensor &Rotation, std::array< std::array< Tensor, 3 >, 3 > &drotationPosCloseDrr01, 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 optimalAlignmentWithCloseStructure (const std::vector< double > &align, const std::vector< double > &displace, const std::vector< Vector > &positions, const std::vector< Vector > &reference, std::vector< Vector > &derivatives, const Tensor &rotationPosClose, const Tensor &rotationRefClose, std::array< std::array< Tensor, 3 >, 3 > &drotationPosCloseDrr01, bool squared=false) const
 
void set (const PDB &, const 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, const std::string &mytype, bool remove_center=true, bool normalize_weights=true)
 set align displace reference and type from input vectors 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...
 
void setReference (const std::vector< Vector > &reference)
 set reference coordinates, remove the com by using uniform weights More...
 
void setType (const std::string &mytype)
 set the type of alignment we are doing More...
 
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...
 

Static Public Member Functions

static Tensor getMatrixFromDRot (const 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

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

Private Attributes

std::vector< double > align
 
AlignmentMethod alignmentMethod
 
std::vector< double > displace
 
Vector positions_center
 
bool positions_center_is_calculated
 
bool positions_center_is_removed
 
std::vector< Vectorreference
 
Vector reference_center
 
bool reference_center_is_calculated
 
bool reference_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

◆ AlignmentMethod

Enumerator
SIMPLE 
OPTIMAL 
OPTIMAL_FAST 

Constructor & Destructor Documentation

◆ RMSD()

PLMD::RMSD::RMSD ( )

Constructor.

Member Function Documentation

◆ addCenter()

void PLMD::RMSD::addCenter ( std::vector< Vector > &  p,
const Vector c 
)
inlineprivate

◆ calc_DDistDRef()

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

◆ calc_DDistDRef_Rot_DRotDPos()

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 
)

◆ calc_DDistDRef_Rot_DRotDPos_DRotDRef()

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 
)

◆ calc_FitElements()

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

◆ calc_PCAelements()

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

◆ calc_Rot()

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

calculate rotation matrix, derivative of rotation matrix w.r.t. positions

◆ calc_Rot_DRotDRr01()

double PLMD::RMSD::calc_Rot_DRotDRr01 ( const std::vector< Vector > &  positions,
Tensor Rotation,
std::array< std::array< Tensor, 3 >, 3 > &  DRotDRr01,
const bool  squared = false 
)

calculate rotation matrix, derivative of rotation matrix w.r.t. positions, derivative of rotation matrix w.r.t. rr01

◆ calc_SOMA()

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

◆ calculate()

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.

◆ calculateCenter()

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

◆ calculateWithCloseStructure()

double PLMD::RMSD::calculateWithCloseStructure ( const std::vector< Vector > &  positions,
std::vector< Vector > &  DDistDPos,
const Tensor rotationPosClose,
const Tensor rotationRefClose,
std::array< std::array< Tensor, 3 >, 3 > &  drotationPosCloseDrr01,
const bool  squared = false 
)

calculate with close structure, i.e. approximate the RMSD without expensive computation of rotation matrix by reusing saved rotation matrices from previous iterations

◆ clear()

void PLMD::RMSD::clear ( )

clear the structure

◆ getAlign()

std::vector< double > PLMD::RMSD::getAlign ( )

◆ getDisplace()

std::vector< double > PLMD::RMSD::getDisplace ( )

◆ getMatrixFromDRot()

static Tensor PLMD::RMSD::getMatrixFromDRot ( const 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)

◆ getMethod()

std::string PLMD::RMSD::getMethod ( )

◆ getReference()

const std::vector< Vector > & PLMD::RMSD::getReference ( ) const

◆ optimalAlignment()

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

◆ optimalAlignment_DDistDRef()

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

◆ optimalAlignment_DDistDRef_Rot_DRotDPos()

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

◆ optimalAlignment_DDistDRef_Rot_DRotDPos_DRotDRef()

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

◆ optimalAlignment_Fit()

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 
)

◆ optimalAlignment_PCA()

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

◆ optimalAlignment_Rot()

template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_Rot ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  derivatives,
Tensor Rotation,
bool  squared = false 
) const

◆ optimalAlignment_Rot_DRotDRr01()

template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignment_Rot_DRotDRr01 ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
Tensor Rotation,
std::array< std::array< Tensor, 3 >, 3 > &  drotationPosCloseDrr01,
bool  squared = false 
) const

◆ optimalAlignment_SOMA()

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

◆ optimalAlignmentWithCloseStructure()

template<bool safe, bool alEqDis>
double PLMD::RMSD::optimalAlignmentWithCloseStructure ( const std::vector< double > &  align,
const std::vector< double > &  displace,
const std::vector< Vector > &  positions,
const std::vector< Vector > &  reference,
std::vector< Vector > &  derivatives,
const Tensor rotationPosClose,
const Tensor rotationRefClose,
std::array< std::array< Tensor, 3 >, 3 > &  drotationPosCloseDrr01,
bool  squared = false 
) const

◆ removeCenter()

void PLMD::RMSD::removeCenter ( std::vector< Vector > &  p,
const Vector c 
)
inlineprivate

◆ set() [1/2]

void PLMD::RMSD::set ( const PDB pdb,
const 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.

◆ set() [2/2]

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

set align displace reference and type from input vectors

◆ setAlign()

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

◆ setDisplace()

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

◆ setReference()

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

◆ setType()

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

set the type of alignment we are doing

◆ simpleAlignment()

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

◆ align

std::vector<double> PLMD::RMSD::align
private

◆ alignmentMethod

AlignmentMethod PLMD::RMSD::alignmentMethod
private

◆ displace

std::vector<double> PLMD::RMSD::displace
private

◆ positions_center

Vector PLMD::RMSD::positions_center
private

◆ positions_center_is_calculated

bool PLMD::RMSD::positions_center_is_calculated
private

◆ positions_center_is_removed

bool PLMD::RMSD::positions_center_is_removed
private

◆ reference

std::vector<Vector> PLMD::RMSD::reference
private

◆ reference_center

Vector PLMD::RMSD::reference_center
private

◆ reference_center_is_calculated

bool PLMD::RMSD::reference_center_is_calculated
private

◆ reference_center_is_removed

bool PLMD::RMSD::reference_center_is_removed
private

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