ProSHADE  0.7.6.0 (JUL 2021)
Protein Shape Detection
ProSHADE_data.cpp File Reference

This is the source file containing internal data representation and manipulation structures and functions. More...

#include "ProSHADE_data.hpp"
#include <gemmi/to_pdb.hpp>

Go to the source code of this file.

Namespaces

 ProSHADE_internal_symmetry
 This namespace contains the symmetry detection related code.
 

Functions

proshade_signed ProSHADE_internal_symmetry::addAxisUnlessSame (proshade_unsign fold, proshade_double axX, proshade_double axY, proshade_double axZ, proshade_double axHeight, proshade_double averageFSC, std::vector< proshade_double * > *prosp, proshade_double axErr)
 This function simply creates a new axis from information in aruments and tests if no such axis already exists, saving it if need be. More...
 
void axesToGroupTypeSanityCheck (proshade_unsign requiredAxes, proshade_unsign obtainedAxes, std::string groupType)
 This function checks that the required and obtained numbers of axes are correct, printing error if they are not. More...
 
bool checkElementAlreadyExists (std::vector< std::vector< proshade_double > > *elements, std::vector< proshade_double > *elem, proshade_double matrixTolerance)
 This function checks if the element list already contains a given matrix. More...
 
bool checkElementsFormGroup (std::vector< std::vector< proshade_double > > *elements, proshade_double matrixTolerance)
 This function checks if all group element products produce another group element. More...
 
bool sortProSHADESymmetryByFSC (proshade_double *a, proshade_double *b)
 This function allows using std::sort to sort vectors of ProSHADE symmetry format. More...
 

Detailed Description

This is the source file containing internal data representation and manipulation structures and functions.

This source file contains the ProSHADE_data class definitions as well as the code for simple manipulations with the data (more complex manipulations are done in dedicated source files) and caller functions for the more complex manipulations. The class described here is how ProSHADE stores the structural data internally; however, the user should not need to access any of this code manually, as changes to this structure may have large consequences unforseen by the user.

Copyright by Michal Tykac and individual contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3) Neither the name of Michal Tykac nor the names of this code's contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limitted to, the implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or the contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limitted to, procurement of substitute goods or services, loss of use, data or profits, or business interuption) however caused and on any theory of liability, whether in contract, strict liability or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Author
Michal Tykac
Garib N. Murshudov
Version
0.7.6.0
Date
JUL 2021

Definition in file ProSHADE_data.cpp.

Function Documentation

◆ axesToGroupTypeSanityCheck()

void axesToGroupTypeSanityCheck ( proshade_unsign  requiredAxes,
proshade_unsign  obtainedAxes,
std::string  groupType 
)

This function checks that the required and obtained numbers of axes are correct, printing error if they are not.

Parameters
[in]requiredAxesNumber of axes that are required by the symmetry type.
[in]obtainedAxesNumber of axes given.
[in]groupTypeA string specifying for which symmetry type the group elements are to be computed.

Definition at line 3044 of file ProSHADE_data.cpp.

3045 {
3046  //================================================ Sanity check
3047  if ( obtainedAxes != requiredAxes )
3048  {
3049  std::stringstream hlpSS;
3050  hlpSS << "The supplied number of axes for group element\n : detection ( >" << obtainedAxes << "< ) does not match the group type ( >" << groupType << "< ).";
3051  throw ProSHADE_exception ( "Mismatch between supplied number of axes and\n : symmetry type.", "ES00059", __FILE__, __LINE__, __func__, hlpSS.str() );
3052  }
3053 
3054  //================================================ Done
3055  return ;
3056 
3057 }

◆ checkElementAlreadyExists()

bool checkElementAlreadyExists ( std::vector< std::vector< proshade_double > > *  elements,
std::vector< proshade_double > *  elem,
proshade_double  matrixTolerance 
)

This function checks if the element list already contains a given matrix.

Parameters
[in]elementsVector containing all group elements.
[in]elemA single element which should already be in the list.
[in]matrixToleranceThe maximum allowed trace error on rotation matrices to be still considered the same.
[out]elementFoundA boolean value stating if the element was found int the elements list or not.

Definition at line 3066 of file ProSHADE_data.cpp.

3067 {
3068  //================================================ Initialise variables
3069  bool elementFound = false;
3070 
3071  //================================================ For each existing element
3072  for ( proshade_unsign elIt = 0; elIt < static_cast<proshade_unsign> ( elements->size() ); elIt++ )
3073  {
3074  if ( ProSHADE_internal_maths::rotationMatrixSimilarity ( &elements->at(elIt), elem, matrixTolerance ) )
3075  {
3076  elementFound = true;
3077  break;
3078  }
3079  }
3080 
3081  //================================================ Done
3082  return ( elementFound );
3083 
3084 }

◆ checkElementsFormGroup()

bool checkElementsFormGroup ( std::vector< std::vector< proshade_double > > *  elements,
proshade_double  matrixTolerance 
)

This function checks if all group element products produce another group element.

Parameters
[in]elementsVector containing all group elements.
[in]matrixToleranceThe maximum trace error for the matrices to be still considered the same.
[out]isGroupA boolean value stating if all group element products for another group element.

Definition at line 3092 of file ProSHADE_data.cpp.

3093 {
3094  //================================================ Initialise variables
3095  bool isGroup = true;
3096 
3097  //================================================ Multiply all group element pairs
3098  for ( proshade_unsign gr1 = 0; gr1 < static_cast<proshade_unsign> ( elements->size() ); gr1++ )
3099  {
3100  for ( proshade_unsign gr2 = 1; gr2 < static_cast<proshade_unsign> ( elements->size() ); gr2++ )
3101  {
3102  //======================================== Use unique pairs only
3103  if ( gr1 >= gr2 ) { continue; }
3104 
3105  //======================================== Multiply the two rotation matrices
3106  std::vector< proshade_double > product = ProSHADE_internal_maths::multiplyGroupElementMatrices ( &elements->at(gr1), &elements->at(gr2) );
3107 
3108  //======================================== Check the group already contains the produces as an element
3109  if ( !checkElementAlreadyExists ( elements, &product, matrixTolerance ) )
3110  {
3111  isGroup = false;
3112  break;
3113  }
3114  }
3115 
3116  //============================================ Stop if problem was found
3117  if ( !isGroup ) { break; }
3118  }
3119 
3120  //================================================ Done
3121  return ( isGroup );
3122 
3123 }

◆ sortProSHADESymmetryByFSC()

bool sortProSHADESymmetryByFSC ( proshade_double *  a,
proshade_double *  b 
)

This function allows using std::sort to sort vectors of ProSHADE symmetry format.

Parameters
[in]aPointer to a ProSHADE symmetry formatted array.
[in]bPointer to a ProSHADE symmetry formatted array.
[out]XBoolean whether a is larger than b.

Definition at line 1914 of file ProSHADE_data.cpp.

1915 {
1916  //================================================ Done
1917  return ( a[6] > b[6] );
1918 
1919 }
ProSHADE_exception
This class is the representation of ProSHADE exception.
Definition: ProSHADE_exceptions.hpp:37
ProSHADE_internal_maths::rotationMatrixSimilarity
bool rotationMatrixSimilarity(std::vector< proshade_double > *mat1, std::vector< proshade_double > *mat2, proshade_double tolerance=0.1)
This function compares the distance between two rotation matrices and decides if they are similar usi...
Definition: ProSHADE_maths.cpp:2299
ProSHADE_internal_maths::multiplyGroupElementMatrices
std::vector< proshade_double > multiplyGroupElementMatrices(std::vector< proshade_double > *el1, std::vector< proshade_double > *el2)
This function computes matrix multiplication using the ProSHADE group element matrix format as input ...
Definition: ProSHADE_maths.cpp:2245
checkElementAlreadyExists
bool checkElementAlreadyExists(std::vector< std::vector< proshade_double > > *elements, std::vector< proshade_double > *elem, proshade_double matrixTolerance)
This function checks if the element list already contains a given matrix.
Definition: ProSHADE_data.cpp:3066