ProSHADE  0.6.5 (NOV 2018)
Protein Shape Descriptors and Symmetry Detection
ProSHADE_misc.h File Reference

This file contains the ProSHADE_internal_misc namespace and its miscellaneous functions. More...

#include <iostream>
#include <string.h>
#include <vector>
#include <array>
#include <numeric>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <iomanip>

Go to the source code of this file.

Namespaces

 ProSHADE_misc
 This groups together miscellaneous functions.
 

Functions

double ProSHADE_internal_misc::roundDouble (double val)
 Function for converting various types to string with definable precision. More...
 
template<typename T >
std::string ProSHADE_internal_misc::to_string_with_precision (const T val, const int precision=6)
 Function for converting various types to string with definable precision. More...
 
double ProSHADE_internal_misc::pearsonCorrCoeff (double *valSet1, double *valSet2, unsigned int length)
 Function for computing the Pearson correlation coefficient. More...
 
std::array< double, 2 > ProSHADE_internal_misc::complexMultiplication (double *r1, double *i1, double *r2, double *i2)
 Function to multiply two complex numbers. More...
 
std::array< double, 2 > ProSHADE_internal_misc::complexMultiplicationConjug (double *r1, double *i1, double *r2, double *i2)
 Function to multiply two complex numbers where the second number is conjugated before the multiplication. More...
 
double ProSHADE_internal_misc::complexMultiplicationReal (double *r1, double *i1, double *r2, double *i2)
 Function to multiply two complex numbers, returning only the real part of the result. More...
 
double ProSHADE_internal_misc::complexMultiplicationConjugReal (double *r1, double *i1, double *r2, double *i2)
 Function to multiply two complex numbers where the second number is conjugated before the multiplication, returning only the real part of the result. More...
 
void ProSHADE_internal_misc::printHelp ()
 This function prints the help dialogue and terminates. More...
 
void ProSHADE_internal_misc::getAirplaneEulerFromMatrix (double mat00, double mat01, double mat02, double mat10, double mat11, double mat12, double mat20, double mat21, double mat22, double *heading, double *attitude, double *bank)
 This function converts the rotation matrix to the airplane convention Euler angles. More...
 
void ProSHADE_internal_misc::getAxisOnlyFromAirplaneEuler (double heading, double attitude, double bank, double *X, double *Y, double *Z)
 This function provides the conversion from airplane converntion Euler angles to the axis of the Axis-Angle representation. More...
 
std::vector< std::vector< double > > ProSHADE_internal_misc::getMatrixFromAxisAngle (std::array< double, 5 > tetrSymm)
 This function finds the rotation matrix from the angle-axis representation. More...
 
std::array< double, 5 > ProSHADE_internal_misc::getAxisAngleFromRotationMatrix (std::vector< std::vector< double > > rotMat)
 This function converts rotation matrix to the axis-angle ProSHADE representation. More...
 
void ProSHADE_internal_misc::getAxisAngleFromEuler (double eulAlpha, double eulBeta, double eulGamma, double *X, double *Y, double *Z, double *Angle, bool AngleOnly=false)
 This function does the conversion from ZXZ Euler angles to the angle-axis rotation representation. More...
 
void ProSHADE_internal_misc::getEulerFromAxisAngle (double *eulAlpha, double *eulBeta, double *eulGamma, double X, double Y, double Z, double Angle)
 This function does the conversion from ZXZ Euler angles to the angle-axis rotation representation. More...
 
std::array< double, 5 > ProSHADE_internal_misc::getAxisAngleFromSymmetryAxes (std::vector< std::vector< double >> symAxes, std::vector< std::vector< double >> basisAxes, unsigned int order1, unsigned int order2)
 This function takes a set of one or two axes and a set of three basis vector axes, returning the angle-axis representation of the rotation required to align the input axes to the input basis axes. More...
 

Detailed Description

The following code defines a few miscellanous functions, which were not initially even meant to be functions, but as it turned harder and harder to keep track of all the parameters I decided to just have the code here. This also allows any potential changes to be applied to all the places at once, should it be necessary.

This file is part of the ProSHADE library for calculating shape descriptors and symmetry operators of protein structures. This is a prototype code, which is by no means complete or fully tested. Its use is at your own risk only. There is no quarantee that the results are correct.

Author
Michal Tykac
Garib N. Murshudov
Version
0.6.5
Date
NOV 2018

Definition in file ProSHADE_misc.h.

Function Documentation

§ complexMultiplication()

std::array< double, 2 > ProSHADE_internal_misc::complexMultiplication ( double *  r1,
double *  i1,
double *  r2,
double *  i2 
)

This function takes pointers to the real and imaginary parst of two complex numbers and returns the result of their multiplication.

Parameters
[in]r1Pointer to the real value of number 1.
[in]i1Pointer to the imaginary value of number 1.
[in]r2Pointer to the real value of number 2.
[in]i2Pointer to the imaginary value of number 2.
[out]XThe result of multiplication of the two complex numbers.
Warning
This function only works with double precision.
This is an internal function which should not be used by the user.

Definition at line 112 of file ProSHADE_descriptors.cpp.

§ complexMultiplicationConjug()

std::array< double, 2 > ProSHADE_internal_misc::complexMultiplicationConjug ( double *  r1,
double *  i1,
double *  r2,
double *  i2 
)

This function takes pointers to the real and imaginary parst of two complex numbers and returns the result of their multiplication after the second number has been conjugated.

Parameters
[in]r1Pointer to the real value of number 1.
[in]i1Pointer to the imaginary value of number 1.
[in]r2Pointer to the real value of number 2.
[in]i2Pointer to the imaginary value of number 2.
[out]XThe result of multiplication of the two complex numbers after the second number conjugate has been obtained and used.
Warning
This function only works with double precision.
This is an internal function which should not be used by the user.

Definition at line 143 of file ProSHADE_descriptors.cpp.

§ complexMultiplicationConjugReal()

double ProSHADE_internal_misc::complexMultiplicationConjugReal ( double *  r1,
double *  i1,
double *  r2,
double *  i2 
)

This function takes pointers to the real and imaginary parst of two complex numbers and returns the result of their multiplication after the second number has been conjugated, returning only the real part of the result.

Parameters
[in]r1Pointer to the real value of number 1.
[in]i1Pointer to the imaginary value of number 1.
[in]r2Pointer to the real value of number 2.
[in]i2Pointer to the imaginary value of number 2.
[out]XThe real part of result of multiplication of the two complex numbers after the second number conjugate has been obtained and used.
Warning
This function only works with double precision.
This is an internal function which should not be used by the user.

Definition at line 199 of file ProSHADE_descriptors.cpp.

§ complexMultiplicationReal()

double ProSHADE_internal_misc::complexMultiplicationReal ( double *  r1,
double *  i1,
double *  r2,
double *  i2 
)

This function takes pointers to the real and imaginary parst of two complex numbers and returns the result of their multiplication, returning only the real part of the result.

Parameters
[in]r1Pointer to the real value of number 1.
[in]i1Pointer to the imaginary value of number 1.
[in]r2Pointer to the real value of number 2.
[in]i2Pointer to the imaginary value of number 2.
[out]XThe real part of the result of multiplication of the two complex numbers.
Warning
This function only works with double precision.
This is an internal function which should not be used by the user.

Definition at line 174 of file ProSHADE_descriptors.cpp.

§ getAirplaneEulerFromMatrix()

void ProSHADE_internal_misc::getAirplaneEulerFromMatrix ( double  mat00,
double  mat01,
double  mat02,
double  mat10,
double  mat11,
double  mat12,
double  mat20,
double  mat21,
double  mat22,
double *  heading,
double *  attitude,
double *  bank 
)
inline

This function takes the rotation matrix and computes the Euler angles in the Airplane (heading, attitude and bank ) notation. This is necessary to apply when the standard convertion from Euler to Axis-angle fails due to very small normalisation constant (it may not fail completely, but becomes unreliable is what is meant here).

Parameters
[in]mat00The rotation matrix element in row 0 column 0.
[in]mat01The rotation matrix element in row 0 column 1.
[in]mat02The rotation matrix element in row 0 column 2.
[in]mat10The rotation matrix element in row 1 column 0.
[in]mat11The rotation matrix element in row 1 column 1.
[in]mat12The rotation matrix element in row 1 column 2.
[in]mat20The rotation matrix element in row 2 column 0.
[in]mat21The rotation matrix element in row 2 column 1.
[in]mat22The rotation matrix element in row 2 column 2.
[in]headingPointer to the heading holding variable of the Euler airplane convention.
[in]attitudePointer to the attitude holding variable of the Euler airplane convention.
[in]bankPointer to the bank holding variable of the Euler airplane convention.
Warning
This is an internal function which should not be used by the user.

Definition at line 518 of file ProSHADE_misc.h.

§ getAxisAngleFromEuler()

void ProSHADE_internal_misc::getAxisAngleFromEuler ( double  eulAlpha,
double  eulBeta,
double  eulGamma,
double *  X,
double *  Y,
double *  Z,
double *  Angle,
bool  AngleOnly = false 
)
inline

The function converts the ZXZ Euler angles provided by the SOFT library onto the angle-axis representation, which is easier to use when detecting symmetries. However, the standard conversion depends on normalisation of the axis and if the normalisation constant is very small, this is prone to instability and small numerical errors can lead to very different results. Therefore, in these cases a conversion from the rotation matrix is used instead to make the results more stable.

Parameters
[in]eulAlphaThe alpha angle of the ZXZ Euler angles.
[in]eulBetaThe beta angle of the ZXZ Euler angles.
[in]eulGammaThe gamma angle of the ZXZ Euler angles.
[in]XA pointer to the X-axis element holding variable of the axis-angle representation.
[in]YA pointer to the Y-axis element holding variable of the axis-angle representation.
[in]ZA pointer to the Z-axis element holding variable of the axis-angle representation.
[in]AngleA pointer to the angle holding variable of the axis-angle representation.
[in]AngleOnlyBoolean value determining if only the angle is required, as in this case much faster version can be used.
Warning
This is an internal function which should not be used by the user.

Definition at line 826 of file ProSHADE_misc.h.

§ getAxisAngleFromRotationMatrix()

std::array<double,5> ProSHADE_internal_misc::getAxisAngleFromRotationMatrix ( std::vector< std::vector< double > >  rotMat)
inline

This function takes a rotation matrix in the ProSHADE format (vector of vectors of doubles) and converts it to the ProSHADE format of Angle-Axis representation (i.e. array of 5 doubles, first being the number of repeats of the angle in 2pi, second being x, third being y, fourth being z and the fifth one being the average peak height, which is in this case set to zero. If there is a singularity, this is solved by converting to Airplane Euler angles and then using these for more accurate axis determination.

Parameters
[in]rotMatRotation matrix in the ProSHADE format (i.e. vector of vectors of doubles).
[out]XAngle-axis representation of the same rotation in the ProSHADE format.
Warning
This is an internal function which should not be used by the user.

Definition at line 680 of file ProSHADE_misc.h.

§ getAxisAngleFromSymmetryAxes()

std::array<double,5> ProSHADE_internal_misc::getAxisAngleFromSymmetryAxes ( std::vector< std::vector< double >>  symAxes,
std::vector< std::vector< double >>  basisAxes,
unsigned int  order1,
unsigned int  order2 
)
inline

This function takes one or two vectors, presumably the symmetry axis (axes) of the structure. It will then use Gram-Schmidt normalisation to produce a set of three vectors, containing the input vector(s) and being perfectly perpendicular to each other. The function will then proceed to compute the rotation matrix representing the rotation required to move these three vectors to the suppllied (second argument) basis vectors. The two order parameters are required to specify to which basis vector the first and second axes should be aligned to. Finally, the function will return the angle=axis representation of the rotation matrix in a format comprehensive for the ProSHADE rotation functionality.

Parameters
[in]symAxesA vector of vectors of the symmetry (input vectors) axes. The axes MUST be in columns and the allowed number of columns is 1 or 2.
[in]basisAxesA vector of vectors with dimensions 3x3. The column vectors specify the basis vectors to which the rotation should align the symAxes vectors. For standard Cartesian system, just input identity matrix.
[in]order1Which of the axes resulting from the above symAxes orthogonalisation should be aligned to the basis system X-axis?
[in]order2Which of the axes resulting from the above symAxes orthogonalisation should be aligned to the basis system Y-axis?
[out]XA standard array of doubles with the angle as the first entry, followed by the X, Y and Z components of the angle-axis rotation representation. The last number is empty.
Warning
This is an internal function which should not be used by the user.

Definition at line 957 of file ProSHADE_misc.h.

§ getAxisOnlyFromAirplaneEuler()

void ProSHADE_internal_misc::getAxisOnlyFromAirplaneEuler ( double  heading,
double  attitude,
double  bank,
double *  X,
double *  Y,
double *  Z 
)
inline

This function converts the Euler angles in the airplane convention format into the axis of the Axis-Angle rotation representation. This is necessary to apply when the standard convertion from Euler to Axis-angle fails due to very small normalisation constant (it may not fail completely, but becomes unreliable is what is meant here).

Parameters
[in]headingThe heading of the Euler airplane convention.
[in]attitudeThe attitude of the Euler airplane convention.
[in]bankThe bank of the Euler airplane convention.
[in]XA pointer to the X-axis element holding variable of the axis-angle representation.
[in]YA pointer to the Y-axis element holding variable of the axis-angle representation.
[in]ZA pointer to the Z-axis element holding variable of the axis-angle representation.
Warning
This is an internal function which should not be used by the user.

Definition at line 574 of file ProSHADE_misc.h.

§ getEulerFromAxisAngle()

void ProSHADE_internal_misc::getEulerFromAxisAngle ( double *  eulAlpha,
double *  eulBeta,
double *  eulGamma,
double  X,
double  Y,
double  Z,
double  Angle 
)
inline

The function converts the ZXZ Euler angles provided by the SOFT library onto the angle-axis representation, which is easier to use when detecting symmetries. However, the standard conversion depends on normalisation of the axis and if the normalisation constant is very small, this is prone to instability and small numerical errors can lead to very different results. Therefore, in these cases a conversion from the rotation matrix is used instead to make the results more stable.

Parameters
[in]eulAlphaThe alpha angle of the ZXZ Euler angles.
[in]eulBetaThe beta angle of the ZXZ Euler angles.
[in]eulGammaThe gamma angle of the ZXZ Euler angles.
[in]XA pointer to the X-axis element holding variable of the axis-angle representation.
[in]YA pointer to the Y-axis element holding variable of the axis-angle representation.
[in]ZA pointer to the Z-axis element holding variable of the axis-angle representation.
[in]AngleA pointer to the angle holding variable of the axis-angle representation.
[in]AngleOnlyBoolean value determining if only the angle is required, as in this case much faster version can be used.
Warning
This is an internal function which should not be used by the user.

Definition at line 916 of file ProSHADE_misc.h.

§ getMatrixFromAxisAngle()

std::vector< std::vector<double> > ProSHADE_internal_misc::getMatrixFromAxisAngle ( std::array< double, 5 >  tetrSymm)
inline

This function takes the angle-axis representaton of rotation and returns the rotation matrix representing the same rotation.

Parameters
[in]tetrSymmStd array of five doubles specifying the n in Cn, x, y, z of angle-axis rotation and the peak height.
[out]XRotation matrix equivalent to the rotation given as angle-axis representation in the input.
Warning
This is an internal function which should not be used by the user.

Definition at line 627 of file ProSHADE_misc.h.

§ pearsonCorrCoeff()

double ProSHADE_internal_misc::pearsonCorrCoeff ( double *  valSet1,
double *  valSet2,
unsigned int  length 
)

This function takes two numerical arrays of same length and proceeds to compute the Pearson's correlation coefficient, which it then returns.

Parameters
[in]valSet1This is the set of x-values.
[in]valSet2This is the set of y-values.
[in]lengthThe length of both arrays (both arrays have to have the same length).
[out]XThe Pearson's correlation coefficient value.
Warning
This function only works with double precision.
This is an internal function which should not be used by the user.

Definition at line 62 of file ProSHADE_descriptors.cpp.

§ printHelp()

void ProSHADE_internal_misc::printHelp ( )
inline
Warning
This is an internal function which should not be used by the user.

Definition at line 177 of file ProSHADE_misc.h.

§ roundDouble()

double ProSHADE_internal_misc::roundDouble ( double  val)
inline

This template function takes an argument and converts it to string using a given precision.

Parameters
[in]valThe value to be converted to string.
[in]precisionThe precision to which the conversion should be done.
[out]XA string conversion of the original variable contents.
Warning
This is an internal function which should not be used by the user.

Definition at line 56 of file ProSHADE_misc.h.

§ to_string_with_precision()

template<typename T >
std::string ProSHADE_internal_misc::to_string_with_precision ( const T  val,
const int  precision = 6 
)

This template function takes an argument and converts it to string using a given precision.

Parameters
[in]valThe value to be converted to string.
[in]precisionThe precision to which the conversion should be done.
[out]XA string conversion of the original variable contents.
Warning
This is an internal function which should not be used by the user.

Definition at line 72 of file ProSHADE_misc.h.