![]() |
ProSHADE
0.6.5 (NOV 2018)
Protein Shape Descriptors and Symmetry Detection
|
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... | |
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.
Definition in file ProSHADE_misc.h.
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.
[in] | r1 | Pointer to the real value of number 1. |
[in] | i1 | Pointer to the imaginary value of number 1. |
[in] | r2 | Pointer to the real value of number 2. |
[in] | i2 | Pointer to the imaginary value of number 2. |
[out] | X | The result of multiplication of the two complex numbers. |
Definition at line 112 of file ProSHADE_descriptors.cpp.
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.
[in] | r1 | Pointer to the real value of number 1. |
[in] | i1 | Pointer to the imaginary value of number 1. |
[in] | r2 | Pointer to the real value of number 2. |
[in] | i2 | Pointer to the imaginary value of number 2. |
[out] | X | The result of multiplication of the two complex numbers after the second number conjugate has been obtained and used. |
Definition at line 143 of file ProSHADE_descriptors.cpp.
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.
[in] | r1 | Pointer to the real value of number 1. |
[in] | i1 | Pointer to the imaginary value of number 1. |
[in] | r2 | Pointer to the real value of number 2. |
[in] | i2 | Pointer to the imaginary value of number 2. |
[out] | X | The real part of result of multiplication of the two complex numbers after the second number conjugate has been obtained and used. |
Definition at line 199 of file ProSHADE_descriptors.cpp.
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.
[in] | r1 | Pointer to the real value of number 1. |
[in] | i1 | Pointer to the imaginary value of number 1. |
[in] | r2 | Pointer to the real value of number 2. |
[in] | i2 | Pointer to the imaginary value of number 2. |
[out] | X | The real part of the result of multiplication of the two complex numbers. |
Definition at line 174 of file ProSHADE_descriptors.cpp.
|
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).
[in] | mat00 | The rotation matrix element in row 0 column 0. |
[in] | mat01 | The rotation matrix element in row 0 column 1. |
[in] | mat02 | The rotation matrix element in row 0 column 2. |
[in] | mat10 | The rotation matrix element in row 1 column 0. |
[in] | mat11 | The rotation matrix element in row 1 column 1. |
[in] | mat12 | The rotation matrix element in row 1 column 2. |
[in] | mat20 | The rotation matrix element in row 2 column 0. |
[in] | mat21 | The rotation matrix element in row 2 column 1. |
[in] | mat22 | The rotation matrix element in row 2 column 2. |
[in] | heading | Pointer to the heading holding variable of the Euler airplane convention. |
[in] | attitude | Pointer to the attitude holding variable of the Euler airplane convention. |
[in] | bank | Pointer to the bank holding variable of the Euler airplane convention. |
Definition at line 518 of file ProSHADE_misc.h.
|
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.
[in] | eulAlpha | The alpha angle of the ZXZ Euler angles. |
[in] | eulBeta | The beta angle of the ZXZ Euler angles. |
[in] | eulGamma | The gamma angle of the ZXZ Euler angles. |
[in] | X | A pointer to the X-axis element holding variable of the axis-angle representation. |
[in] | Y | A pointer to the Y-axis element holding variable of the axis-angle representation. |
[in] | Z | A pointer to the Z-axis element holding variable of the axis-angle representation. |
[in] | Angle | A pointer to the angle holding variable of the axis-angle representation. |
[in] | AngleOnly | Boolean value determining if only the angle is required, as in this case much faster version can be used. |
Definition at line 826 of file ProSHADE_misc.h.
|
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.
[in] | rotMat | Rotation matrix in the ProSHADE format (i.e. vector of vectors of doubles). |
[out] | X | Angle-axis representation of the same rotation in the ProSHADE format. |
Definition at line 680 of file ProSHADE_misc.h.
|
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.
[in] | symAxes | A 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] | basisAxes | A 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] | order1 | Which of the axes resulting from the above symAxes orthogonalisation should be aligned to the basis system X-axis? |
[in] | order2 | Which of the axes resulting from the above symAxes orthogonalisation should be aligned to the basis system Y-axis? |
[out] | X | A 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. |
Definition at line 957 of file ProSHADE_misc.h.
|
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).
[in] | heading | The heading of the Euler airplane convention. |
[in] | attitude | The attitude of the Euler airplane convention. |
[in] | bank | The bank of the Euler airplane convention. |
[in] | X | A pointer to the X-axis element holding variable of the axis-angle representation. |
[in] | Y | A pointer to the Y-axis element holding variable of the axis-angle representation. |
[in] | Z | A pointer to the Z-axis element holding variable of the axis-angle representation. |
Definition at line 574 of file ProSHADE_misc.h.
|
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.
[in] | eulAlpha | The alpha angle of the ZXZ Euler angles. |
[in] | eulBeta | The beta angle of the ZXZ Euler angles. |
[in] | eulGamma | The gamma angle of the ZXZ Euler angles. |
[in] | X | A pointer to the X-axis element holding variable of the axis-angle representation. |
[in] | Y | A pointer to the Y-axis element holding variable of the axis-angle representation. |
[in] | Z | A pointer to the Z-axis element holding variable of the axis-angle representation. |
[in] | Angle | A pointer to the angle holding variable of the axis-angle representation. |
[in] | AngleOnly | Boolean value determining if only the angle is required, as in this case much faster version can be used. |
Definition at line 916 of file ProSHADE_misc.h.
|
inline |
This function takes the angle-axis representaton of rotation and returns the rotation matrix representing the same rotation.
[in] | tetrSymm | Std array of five doubles specifying the n in Cn, x, y, z of angle-axis rotation and the peak height. |
[out] | X | Rotation matrix equivalent to the rotation given as angle-axis representation in the input. |
Definition at line 627 of file ProSHADE_misc.h.
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.
[in] | valSet1 | This is the set of x-values. |
[in] | valSet2 | This is the set of y-values. |
[in] | length | The length of both arrays (both arrays have to have the same length). |
[out] | X | The Pearson's correlation coefficient value. |
Definition at line 62 of file ProSHADE_descriptors.cpp.
|
inline |
Definition at line 177 of file ProSHADE_misc.h.
|
inline |
This template function takes an argument and converts it to string using a given precision.
[in] | val | The value to be converted to string. |
[in] | precision | The precision to which the conversion should be done. |
[out] | X | A string conversion of the original variable contents. |
Definition at line 56 of file ProSHADE_misc.h.
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.
[in] | val | The value to be converted to string. |
[in] | precision | The precision to which the conversion should be done. |
[out] | X | A string conversion of the original variable contents. |
Definition at line 72 of file ProSHADE_misc.h.