ProSHADE  0.7.5.3 (FEB 2021)
Protein Shape Detection
ProSHADE_data.cpp
Go to the documentation of this file.
1 
24 //==================================================== ProSHADE
25 #include "ProSHADE_data.hpp"
26 
27 //==================================================== Gemmi PDB output - this cannot be with the rest of includes for some stb_sprintf library related reasons ...
28 #define GEMMI_WRITE_IMPLEMENTATION
29 #include <gemmi/to_pdb.hpp>
30 
40 {
41  //================================================ Initialise variables
42  // ... Variables regarding input file
43  this->fileName = "";
44  this->fileType = ProSHADE_internal_io::UNKNOWN;
45 
46  // ... Variables regarding map
47  this->internalMap = NULL;
48 
49  // ... Variables regarding map information
50  this->xDimSize = 0.0;
51  this->yDimSize = 0.0;
52  this->zDimSize = 0.0;
53  this->aAngle = 0.0;
54  this->bAngle = 0.0;
55  this->cAngle = 0.0;
56  this->xDimIndices = 0;
57  this->yDimIndices = 0;
58  this->zDimIndices = 0;
59  this->xGridIndices = 0;
60  this->yGridIndices = 0;
61  this->zGridIndices = 0;
62  this->xAxisOrder = 1;
63  this->yAxisOrder = 2;
64  this->zAxisOrder = 3;
65  this->xAxisOrigin = 0;
66  this->yAxisOrigin = 0;
67  this->zAxisOrigin = 0;
68  this->xCom = 0.0;
69  this->yCom = 0.0;
70  this->zCom = 0.0;
71 
72  // ... Variables regarding original input values (i.e. these do not change with ProSHADE manipulations)
73  this->xDimSizeOriginal = 0.0;
74  this->yDimSizeOriginal = 0.0;
75  this->zDimSizeOriginal = 0.0;
76  this->xDimIndicesOriginal = 0;
77  this->yDimIndicesOriginal = 0;
78  this->zDimIndicesOriginal = 0;
79  this->xAxisOriginOriginal = 0;
80  this->yAxisOriginOriginal = 0;
81  this->zAxisOriginOriginal = 0;
82  this->originalMapXCom = 0.0;
83  this->originalMapYCom = 0.0;
84  this->originalMapZCom = 0.0;
85  this->mapMovFromsChangeX = 0.0;
86  this->mapMovFromsChangeY = 0.0;
87  this->mapMovFromsChangeZ = 0.0;
88  this->mapCOMProcessChangeX = 0.0;
89  this->mapCOMProcessChangeY = 0.0;
90  this->mapCOMProcessChangeZ = 0.0;
91 
92  // ... Variables regarding rotation and translation of original input files
93  this->originalPdbRotCenX = 0.0;
94  this->originalPdbRotCenY = 0.0;
95  this->originalPdbRotCenZ = 0.0;
96  this->originalPdbTransX = 0.0;
97  this->originalPdbTransY = 0.0;
98  this->originalPdbTransZ = 0.0;
99 
100  // ... Variables regarding iterator positions
101  this->xFrom = 0;
102  this->yFrom = 0;
103  this->zFrom = 0;
104  this->xTo = 0;
105  this->yTo = 0;
106  this->zTo = 0;
107 
108  // ... Variables regarding SH mapping spheres
109  this->spherePos = std::vector<proshade_single> ( );
110  this->noSpheres = 0;
111  this->spheres = NULL;
112  this->sphericalHarmonics = NULL;
113  this->rotSphericalHarmonics = NULL;
114  this->maxShellBand = 0;
115 
116  // ... Variables regarding shape distance computations
117  this->rrpMatrices = NULL;
118  this->eMatrices = NULL;
119  this->so3Coeffs = NULL;
120  this->so3CoeffsInverse = NULL;
121  this->wignerMatrices = NULL;
122  this->integrationWeight = 0.0;
123  this->maxCompBand = 0;
124  this->translationMap = NULL;
125 
126 
127  // ... Control variables
128  this->isEmpty = true;
129 
130  //================================================ Done
131 
132 }
133 
160 ProSHADE_internal_data::ProSHADE_data::ProSHADE_data ( ProSHADE_settings* settings, std::string strName, double *mapVals, int len, proshade_single xDmSz, proshade_single yDmSz, proshade_single zDmSz, proshade_unsign xDmInd, proshade_unsign yDmInd, proshade_unsign zDmInd, proshade_signed xFr, proshade_signed yFr, proshade_signed zFr, proshade_signed xT, proshade_signed yT, proshade_signed zT, proshade_unsign inputO )
161 {
162  //================================================ Initialise variables
163  // ... Variables regarding input file
164  this->fileName = strName;
165  this->fileType = ProSHADE_internal_io::MAP;
166 
167  // ... Variables regarding map
168  this->internalMap = NULL;
169 
170  // ... Variables regarding map information
171  this->xDimSize = xDmSz;
172  this->yDimSize = yDmSz;
173  this->zDimSize = zDmSz;
174  this->aAngle = 90.0;
175  this->bAngle = 90.0;
176  this->cAngle = 90.0;
177  this->xDimIndices = xDmInd;
178  this->yDimIndices = yDmInd;
179  this->zDimIndices = zDmInd;
180  this->xGridIndices = xDmInd;
181  this->yGridIndices = yDmInd;
182  this->zGridIndices = zDmInd;
183  this->xAxisOrder = 1;
184  this->yAxisOrder = 2;
185  this->zAxisOrder = 3;
186  this->xAxisOrigin = xFr;
187  this->yAxisOrigin = yFr;
188  this->zAxisOrigin = zFr;
189  this->xCom = 0.0;
190  this->yCom = 0.0;
191  this->zCom = 0.0;
192 
193  // ... Variables regarding original input values (i.e. these do not change with ProSHADE manipulations)
194  this->xDimSizeOriginal = 0.0;
195  this->yDimSizeOriginal = 0.0;
196  this->zDimSizeOriginal = 0.0;
197  this->xDimIndicesOriginal = 0;
198  this->yDimIndicesOriginal = 0;
199  this->zDimIndicesOriginal = 0;
200  this->xAxisOriginOriginal = 0;
201  this->yAxisOriginOriginal = 0;
202  this->zAxisOriginOriginal = 0;
203  this->originalMapXCom = 0.0;
204  this->originalMapYCom = 0.0;
205  this->originalMapZCom = 0.0;
206  this->mapMovFromsChangeX = 0.0;
207  this->mapMovFromsChangeY = 0.0;
208  this->mapMovFromsChangeZ = 0.0;
209  this->mapCOMProcessChangeX = 0.0;
210  this->mapCOMProcessChangeY = 0.0;
211  this->mapCOMProcessChangeZ = 0.0;
212 
213  // ... Variables regarding rotation and translation of original input files
214  this->originalPdbRotCenX = 0.0;
215  this->originalPdbRotCenY = 0.0;
216  this->originalPdbRotCenZ = 0.0;
217  this->originalPdbTransX = 0.0;
218  this->originalPdbTransY = 0.0;
219  this->originalPdbTransZ = 0.0;
220 
221  // ... Variables regarding iterator positions
222  this->xFrom = xFr;
223  this->yFrom = yFr;
224  this->zFrom = zFr;
225  this->xTo = xT;
226  this->yTo = yT;
227  this->zTo = zT;
228 
229  // ... Variables regarding SH mapping spheres
230  this->spherePos = std::vector<proshade_single> ( );
231  this->noSpheres = 0;
232  this->spheres = NULL;
233  this->sphericalHarmonics = NULL;
234  this->rotSphericalHarmonics = NULL;
235  this->maxShellBand = 0;
236 
237  // ... Variables regarding shape distance computations
238  this->rrpMatrices = NULL;
239  this->eMatrices = NULL;
240  this->so3Coeffs = NULL;
241  this->so3CoeffsInverse = NULL;
242  this->wignerMatrices = NULL;
243  this->integrationWeight = 0.0;
244  this->maxCompBand = 0;
245  this->translationMap = NULL;
246 
247  // ... Control variables
248  this->isEmpty = false;
249  this->inputOrder = inputO;
250 
251  //================================================ Sanity checks
252  if ( static_cast<proshade_unsign> ( len ) != ( xDmInd * yDmInd * zDmInd ) )
253  {
254  throw ProSHADE_exception ( "Structure class input map has wrong dimensions.", "EP00044", __FILE__, __LINE__, __func__, "The supplied map array size has different dimensions to\n : the required map dimensions." );
255  }
256 
257  if ( ( static_cast<proshade_signed> ( xT - xFr ) != static_cast<proshade_signed> ( xDmInd - 1 ) ) ||
258  ( static_cast<proshade_signed> ( yT - yFr ) != static_cast<proshade_signed> ( yDmInd - 1 ) ) ||
259  ( static_cast<proshade_signed> ( zT - zFr ) != static_cast<proshade_signed> ( zDmInd - 1 ) ) )
260  {
261  throw ProSHADE_exception ( "Structure class input dimensions not in line with map\n : to/from indices.", "EP00045", __FILE__, __LINE__, __func__, "The supplied map information does not add up. The\n : dimensions are not in line with the indexing start/stop\n : position distances and therefore proper map indexing\n : cannot be done. Please check the input values." );
262  }
263 
264  //================================================ Allocate the map memory
265  this->internalMap = new proshade_double [this->xDimIndices * this->yDimIndices * this->zDimIndices];
266  ProSHADE_internal_misc::checkMemoryAllocation ( this->internalMap, __FILE__, __LINE__, __func__ );
267 
268  //================================================ Copy the values into the map
269  proshade_unsign arrPos = 0;
270  for ( proshade_unsign xIt = 0; xIt < this->xDimIndices; xIt++ )
271  {
272  for ( proshade_unsign yIt = 0; yIt < this->yDimIndices; yIt++ )
273  {
274  for ( proshade_unsign zIt = 0; zIt < this->zDimIndices; zIt++ )
275  {
276  arrPos = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
277  this->internalMap[arrPos] = static_cast<proshade_double> ( mapVals[arrPos] );
278  }
279  }
280  }
281 
282  //================================================ Release memory (it was allocated by the PyBind11 lambda function and needs to be released)
283  delete[] mapVals;
284 
285  //================================================ Done
286 
287 }
288 
296 {
297  //================================================ Release the internal map
298  if ( this->internalMap != NULL )
299  {
300  delete[] this->internalMap;
301  }
302 
303  //================================================ Release the sphere mapping
304  if ( this->spheres != NULL )
305  {
306  for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
307  {
308  if ( this->spheres[iter] != NULL )
309  {
310  delete this->spheres[iter];
311  this->spheres[iter] = NULL;
312  }
313  }
314  delete[] this->spheres;
315  }
316 
317  //================================================ Release the spherical harmonics
318  if ( this->sphericalHarmonics != NULL )
319  {
320  for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
321  {
322  if ( this->sphericalHarmonics[iter] != NULL )
323  {
324  delete[] this->sphericalHarmonics[iter];
325  this->sphericalHarmonics[iter] = NULL;
326  }
327  }
328  delete[] this->sphericalHarmonics;
329  }
330 
331  //================================================ Release the rotated spherical harmonics
332  if ( this->rotSphericalHarmonics != NULL )
333  {
334  for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
335  {
336  if ( this->rotSphericalHarmonics[iter] != NULL )
337  {
338  delete[] this->rotSphericalHarmonics[iter];
339  this->rotSphericalHarmonics[iter] = NULL;
340  }
341  }
342  delete[] this->rotSphericalHarmonics;
343  }
344 
345  //================================================ Release the RRP matrices (pre-computation for the energy levels descriptor)
346  if ( this->rrpMatrices != NULL )
347  {
348  for ( proshade_unsign bwIt = 0; bwIt < this->maxShellBand; bwIt++ )
349  {
350  if ( this->rrpMatrices[bwIt] != NULL )
351  {
352  for ( proshade_unsign shIt = 0; shIt < this->noSpheres; shIt++ )
353  {
354  if ( this->rrpMatrices[bwIt][shIt] != NULL )
355  {
356  delete[] this->rrpMatrices[bwIt][shIt];
357  }
358  }
359 
360  delete[] this->rrpMatrices[bwIt];
361  }
362  }
363 
364  delete[] this->rrpMatrices;
365  }
366 
367  //================================================ Release the E matrices
368  if ( this->eMatrices != NULL )
369  {
370  for ( proshade_unsign bandIter = 0; bandIter < this->maxCompBand; bandIter++ )
371  {
372  if ( this->eMatrices[bandIter] != NULL )
373  {
374  for ( proshade_unsign band2Iter = 0; band2Iter < static_cast<proshade_unsign> ( ( bandIter * 2 ) + 1 ); band2Iter++ )
375  {
376  if ( this->eMatrices[bandIter][band2Iter] != NULL )
377  {
378  delete[] this->eMatrices[bandIter][band2Iter];
379  }
380  }
381 
382  delete[] this->eMatrices[bandIter];
383  }
384  }
385 
386  delete[] this->eMatrices;
387  }
388 
389  //================================================ Release SOFT and inverse SOFT coefficients
390  if ( this->so3Coeffs != NULL )
391  {
392  delete[] this->so3Coeffs;
393  }
394  if ( this->so3CoeffsInverse != NULL )
395  {
396  delete[] this->so3CoeffsInverse;
397  }
398 
399  //================================================ Release Wigner matrices
400  if ( this->wignerMatrices != NULL )
401  {
402  for ( proshade_unsign bandIter = 1; bandIter < this->maxCompBand; bandIter++ )
403  {
404  if ( this->wignerMatrices[bandIter] != NULL )
405  {
406  for ( proshade_unsign order1Iter = 0; order1Iter < ( (bandIter * 2) + 1 ); order1Iter++ )
407  {
408  if ( this->wignerMatrices[bandIter][order1Iter] != NULL )
409  {
410  delete[] this->wignerMatrices[bandIter][order1Iter];
411  }
412  }
413  delete[] this->wignerMatrices[bandIter];
414  }
415  }
416  delete[] wignerMatrices;
417  }
418 
419  //================================================ Release translation map
420  if ( this->translationMap != NULL )
421  {
422  delete[] this->translationMap;
423  }
424 
425  //================================================ Release the angle-axis space rotation function
426  if ( this->sphereMappedRotFun.size() > 0 )
427  {
428  for ( proshade_unsign spIt = 0; spIt < static_cast<proshade_unsign> ( this->sphereMappedRotFun.size() ); spIt++ )
429  {
430  delete this->sphereMappedRotFun.at(spIt);
431  }
432  }
433 
434  //================================================ Done
435 
436 }
437 
447 void ProSHADE_internal_data::ProSHADE_data::readInStructure ( std::string fName, proshade_unsign inputO, ProSHADE_settings* settings )
448 {
449  //================================================ Report function start
450  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Starting to read the structure: " + fName );
451 
452  //================================================ Check if instance is empty
453  if ( !this->isEmpty )
454  {
455  throw ProSHADE_exception ( "Structure data class not empty.", "E000005", __FILE__, __LINE__, __func__, "Attempted to read in structure into a ProSHADE_data\n : object which already does have structure read in\n : i.e. " + this->fileName );
456  }
457 
458  //================================================ Save the filename
459  this->fileName = fName;
460 
461  //================================================ Check what is the input format
462  this->fileType = ProSHADE_internal_io::figureDataType ( this->fileName );
463 
464  //================================================ Save input order
465  this->inputOrder = inputO;
466 
467  //================================================ Decide how to proceed
468  switch ( this->fileType )
469  {
470  case ProSHADE_internal_io::UNKNOWN:
471  throw ProSHADE_exception ( "Unknown file type.", "E000006", __FILE__, __LINE__, __func__, "When attempting to read the file\n : " + this->fileName + "\n : the file extension was determined as unknown. This could\n : mean either that the file does not exist, or that it is\n : not one of the supported extensions." );
472  break;
473 
474  case ProSHADE_internal_io::PDB:
475  this->readInPDB ( settings );
476  break;
477 
478  case ProSHADE_internal_io::MAP:
479  this->readInMAP ( settings );
480  break;
481  }
482 
483  //================================================ This structure is now full
484  this->isEmpty = false;
485 
486  //================================================ Report function completion
487  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Structure read in successfully." );
488 
489  //================================================ Done
490  return ;
491 
492 }
493 
502 {
503  //================================================ Open the file
504  gemmi::Ccp4<float> map;
505  map.read_ccp4 ( gemmi::MaybeGzipped ( this->fileName.c_str() ) );
506 
507  //================================================ Convert to XYZ and create complete map, if need be
508  map.setup ( gemmi::GridSetup::ReorderOnly, NAN );
509 
510  //================================================ Read in the rest of the map file header
512  &this->xDimIndices, &this->yDimIndices, &this->zDimIndices,
513  &this->xDimSize, &this->yDimSize, &this->zDimSize,
514  &this->aAngle, &this->bAngle, &this->cAngle,
515  &this->xFrom, &this->yFrom, &this->zFrom,
516  &this->xAxisOrigin, &this->yAxisOrigin, &this->zAxisOrigin,
517  &this->xAxisOrder, &this->yAxisOrder, &this->zAxisOrder,
518  &this->xGridIndices, &this->yGridIndices, &this->zGridIndices );
519 
520  //================================================ Save the map density to ProSHADE variable
521  ProSHADE_internal_io::readInMapData ( &map, this->internalMap, this->xDimIndices, this->yDimIndices, this->zDimIndices, this->xAxisOrder, this->yAxisOrder, this->zAxisOrder );
522 
523  //================================================ Set resolution if need be
524  if ( settings->requestedResolution < 0.0 )
525  {
526  settings->setResolution ( std::min ( static_cast<proshade_double> ( this->xDimSize ) / static_cast<proshade_double> ( this->xDimIndices ),
527  std::min ( static_cast<proshade_double> ( this->yDimSize ) / static_cast<proshade_double> ( this->yDimIndices ),
528  static_cast<proshade_double> ( this->zDimSize ) / static_cast<proshade_double> ( this->zDimIndices ) ) ) * 2.0 );
529  }
530 
531  //================================================ Set iterators from and to
532  this->figureIndexStartStop ( );
533 
534  //================================================ If specific resolution is requested, make sure the map has it
535  if ( settings->changeMapResolution || settings->changeMapResolutionTriLinear )
536  {
537  this->reSampleMap ( settings );
538  }
539 
540  //================================================ Save the original sizes
541  this->xDimSizeOriginal = this->xDimSize;
542  this->yDimSizeOriginal = this->yDimSize;
543  this->zDimSizeOriginal = this->zDimSize;
544 
545  //================================================ Save the original index counts
546  this->xDimIndicesOriginal = this->xDimIndices;
547  this->yDimIndicesOriginal = this->yDimIndices;
548  this->zDimIndicesOriginal = this->zDimIndices;
549 
550  //================================================ Save the original axis origins
551  this->xAxisOriginOriginal = this->xAxisOrigin;
552  this->yAxisOriginOriginal = this->yAxisOrigin;
553  this->zAxisOriginOriginal = this->zAxisOrigin;
554 
555  //================================================ Compute and save the COM
556  this->findMapCOM ( );
557  this->originalMapXCom = this->xCom;
558  this->originalMapYCom = this->yCom;
559  this->originalMapZCom = this->zCom;
560 
561  //================================================ Done
562 
563 }
564 
575 {
576  //================================================ Set resolution if need be
577  if ( settings->requestedResolution < 0.0 )
578  {
579  settings->setResolution ( 8.0 );
580  }
581 
582  //================================================ Open PDB file for reading
583  gemmi::Structure pdbFile = gemmi::read_structure ( gemmi::MaybeGzipped ( this->fileName ) );
584 
585  //================================================ Change B-factors if need be
586  if ( settings->pdbBFactorNewVal >= 0.0 )
587  {
589  }
590 
591  //================================================ Remove waters if required
592  if ( settings->removeWaters )
593  {
595  }
596 
597  //================================================ Get PDB COM values
598  proshade_double xCOMPdb, yCOMPdb, zCOMPdb;
599  ProSHADE_internal_mapManip::findPDBCOMValues ( pdbFile, &xCOMPdb, &yCOMPdb, &zCOMPdb, settings->firstModelOnly );
600 
601  //================================================ Find the ranges
602  proshade_single xF, xT, yF, yT, zF, zT;
603  ProSHADE_internal_mapManip::determinePDBRanges ( pdbFile, &xF, &xT, &yF, &yT, &zF, &zT, settings->firstModelOnly );
604 
605  //================================================ Move ranges to have all FROM values 20
606  proshade_single xMov = 20.0 - xF;
607  proshade_single yMov = 20.0 - yF;
608  proshade_single zMov = 20.0 - zF;
609  ProSHADE_internal_mapManip::movePDBForMapCalc ( &pdbFile, xMov, yMov, zMov, settings->firstModelOnly );
610 
611  //================================================ Set the angstrom sizes
612  this->xDimSize = xT - xF + 40.0;
613  this->yDimSize = yT - yF + 40.0;
614  this->zDimSize = zT - zF + 40.0;
615 
616  //================================================ Generate map from nicely placed atoms (cell size will be range + 40)
617  ProSHADE_internal_mapManip::generateMapFromPDB ( pdbFile, this->internalMap, settings->requestedResolution, this->xDimSize, this->yDimSize, this->zDimSize, &this->xTo, &this->yTo, &this->zTo, settings->forceP1, settings->firstModelOnly );
618 
619  //================================================ Set the internal variables to correct values
620  this->setPDBMapValues ( );
621 
622  //================================================ Compute reverse movement based on COMs. If there is more than 1 models, simply moving back the xyzMov is not enough.
623  proshade_double xCOMMap, yCOMMap, zCOMMap;
624  ProSHADE_internal_mapManip::findMAPCOMValues ( this->internalMap, &xCOMMap, &yCOMMap, &zCOMMap,
625  this->xDimSize, this->yDimSize, this->zDimSize,
626  this->xFrom, this->xTo, this->yFrom, this->yTo, this->zFrom, this->zTo );
627 
628  if ( pdbFile.models.size() > 1 )
629  {
630  xMov = xCOMMap - xCOMPdb;
631  yMov = yCOMMap - yCOMPdb;
632  zMov = zCOMMap - zCOMPdb;
633  }
634 
635  //================================================ Move map back to the original PDB location
636  ProSHADE_internal_mapManip::moveMapByIndices ( &xMov, &yMov, &zMov, this->xDimSize, this->yDimSize, this->zDimSize,
637  &this->xFrom, &this->xTo, &this->yFrom, &this->yTo, &this->zFrom, &this->zTo,
638  &this->xAxisOrigin, &this->yAxisOrigin, &this->zAxisOrigin );
639  ProSHADE_internal_mapManip::moveMapByFourier ( this->internalMap, xMov, yMov, zMov, this->xDimSize, this->yDimSize, this->zDimSize,
640  this->xDimIndices, this->yDimIndices, this->zDimIndices );
641 
642  //================================================ If specific resolution is requested, make sure the map has it
643  if ( settings->changeMapResolution || settings->changeMapResolutionTriLinear )
644  {
645  this->reSampleMap ( settings );
646  }
647 
648  //================================================ Save the original sizes
649  this->xDimSizeOriginal = this->xDimSize;
650  this->yDimSizeOriginal = this->yDimSize;
651  this->zDimSizeOriginal = this->zDimSize;
652 
653  //================================================ Save the original index counts
654  this->xDimIndicesOriginal = this->xDimIndices;
655  this->yDimIndicesOriginal = this->yDimIndices;
656  this->zDimIndicesOriginal = this->zDimIndices;
657 
658  //================================================ Save the original axis origins
659  this->xAxisOriginOriginal = this->xAxisOrigin;
660  this->yAxisOriginOriginal = this->yAxisOrigin;
661  this->zAxisOriginOriginal = this->zAxisOrigin;
662 
663  //================================================ Compute and save the COM
664  this->findMapCOM ( );
665  this->originalMapXCom = this->xCom;
666  this->originalMapYCom = this->yCom;
667  this->originalMapZCom = this->zCom;
668 
669  //================================================ Done
670  return;
671 
672 }
673 
679 {
680  //================================================ Set starts to 0
681  this->xFrom = 0;
682  this->yFrom = 0;
683  this->zFrom = 0;
684 
685  //================================================ Set angles to 90 degrees
686  this->aAngle = 90.0;
687  this->bAngle = 90.0;
688  this->cAngle = 90.0;
689 
690  //================================================ Set dimension sizes in indices
691  this->xDimIndices = this->xTo;
692  this->yDimIndices = this->yTo;
693  this->zDimIndices = this->zTo;
694 
695  //================================================ Set grid indexing to cell indexing
696  this->xGridIndices = this->xDimIndices;
697  this->yGridIndices = this->yDimIndices;
698  this->zGridIndices = this->zDimIndices;
699 
700  //================================================ Set axis order
701  this->xAxisOrder = 1;
702  this->yAxisOrder = 2;
703  this->zAxisOrder = 3;
704 
705  //================================================ Set origin to the first index
706  this->xAxisOrigin = this->xFrom;
707  this->yAxisOrigin = this->yFrom;
708  this->zAxisOrigin = this->zFrom;
709 
710  //================================================ Done
711  return ;
712 
713 }
714 
720 {
721  //================================================ Set ends to origin + size - 1
722  this->xTo = this->xFrom + this->xDimIndices - 1;
723  this->yTo = this->yFrom + this->yDimIndices - 1;
724  this->zTo = this->zFrom + this->zDimIndices - 1;
725 
726  //================================================ Done
727  return ;
728 
729 }
730 
741 void ProSHADE_internal_data::ProSHADE_data::writeMap ( std::string fName, std::string title, int mode )
742 {
743  //================================================ Create and prepare new Grid gemmi object
744  gemmi::Grid<float> mapData;
745  mapData.set_unit_cell ( this->xDimSize, this->yDimSize, this->zDimSize, this->aAngle, this->bAngle, this->cAngle );
746  mapData.set_size_without_checking ( this->xDimIndices, this->yDimIndices, this->zDimIndices );
747  mapData.axis_order = gemmi::AxisOrder::XYZ;
748  mapData.spacegroup = &gemmi::get_spacegroup_p1();
749 
750  //================================================ Create and prepare new Ccp4 gemmi object
751  gemmi::Ccp4<float> map;
752  map.grid = mapData;
753  map.update_ccp4_header ( mode );
754 
755  //================================================ Fill in the header
757  this->xDimIndices, this->yDimIndices, this->zDimIndices,
758  this->xDimSize, this->yDimSize, this->zDimSize,
759  this->aAngle, this->bAngle, this->cAngle,
760  this->xFrom, this->yFrom, this->zFrom,
761  this->xAxisOrigin, this->yAxisOrigin, this->zAxisOrigin,
762  this->xAxisOrder, this->yAxisOrder, this->zAxisOrder,
763  this->xGridIndices, this->yGridIndices, this->zGridIndices,
764  title, mode );
765 
766  //================================================ Copy internal map to grid
767  proshade_unsign arrPos = 0;
768  for ( proshade_unsign uIt = 0; uIt < this->xDimIndices; uIt++ )
769  {
770  for ( proshade_unsign vIt = 0; vIt < this->yDimIndices; vIt++ )
771  {
772  for ( proshade_unsign wIt = 0; wIt < this->zDimIndices; wIt++ )
773  {
774  arrPos = wIt + this->zDimIndices * ( vIt + this->yDimIndices * uIt );
775  map.grid.set_value ( uIt, vIt, wIt, static_cast<float> ( this->internalMap[arrPos] ) );
776  }
777  }
778  }
779 
780  //================================================ Update the statistics in the header
781  map.update_ccp4_header ( mode, true );
782 
783  //================================================ Write out the map
784  map.write_ccp4_map ( fName );
785 
786  //================================================ Done
787  return ;
788 
789 }
790 
806 void ProSHADE_internal_data::ProSHADE_data::writePdb ( std::string fName, proshade_double euA, proshade_double euB, proshade_double euG, proshade_double trsX, proshade_double trsY, proshade_double trsZ, bool firstModel )
807 {
808  //================================================ Check for co-ordinate origin
809  if ( !ProSHADE_internal_io::isFilePDB ( this->fileName ) )
810  {
811  throw ProSHADE_exception ( "Cannot write co-ordinate file if the input file did not contain co-ordinates.", "EP00047", __FILE__, __LINE__, __func__, "You have called the WritePDB function on structure which\n : was created by reading in a map. This is not allowed as\n : ProSHADE cannot create co-ordinates from map file." );
812  }
813 
814  //================================================ Open PDB file for reading
815  gemmi::Structure pdbFile = gemmi::read_structure ( gemmi::MaybeGzipped ( this->fileName ) );
816 
817  //================================================ If the map was rotated, do the same for the co-ordinates, making sure we take into account the rotation centre of the map
818  if ( ( euA != 0.0 ) || ( euB != 0.0 ) || ( euG != 0.0 ) )
819  {
820  //============================================ Rotate the co-ordinates
821  ProSHADE_internal_mapManip::rotatePDBCoordinates ( &pdbFile, euA, euB, euG, this->originalPdbRotCenX, this->originalPdbRotCenY, this->originalPdbRotCenZ, firstModel );
822  }
823 
824  //================================================ Translate by required translation and the map centering (if applied)
825  ProSHADE_internal_mapManip::translatePDBCoordinates ( &pdbFile, trsX, trsY, trsZ, firstModel );
826 
827  //================================================ Write the PDB file
828  std::ofstream outCoOrdFile;
829  outCoOrdFile.open ( fName.c_str() );
830 
831  if ( outCoOrdFile.is_open() )
832  {
833  gemmi::PdbWriteOptions opt;
834  write_pdb ( pdbFile, outCoOrdFile, opt );
835  }
836  else
837  {
838  std::stringstream hlpMessage;
839  hlpMessage << "Failed to open the PDB file " << fName << " for output.";
840  throw ProSHADE_exception ( hlpMessage.str().c_str(), "EP00048", __FILE__, __LINE__, __func__, "ProSHADE has failed to open the PDB output file. This is\n : likely caused by either not having the write privileges\n : to the required output path, or by making a mistake in\n : the path." );
841  }
842 
843  outCoOrdFile.close ( );
844 
845  //================================================ Done
846  return ;
847 }
848 
857 void ProSHADE_internal_data::ProSHADE_data::writeMask ( std::string fName, proshade_double* mask )
858 {
859  //================================================ Allocate the memory
860  proshade_double* hlpMap = new proshade_double[this->xDimIndices * this->yDimIndices * this->zDimIndices];
861  ProSHADE_internal_misc::checkMemoryAllocation ( hlpMap, __FILE__, __LINE__, __func__ );
862 
863  //================================================ Copy original map and over-write with the mask
864  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
865  {
866  hlpMap[iter] = this->internalMap[iter];
867  this->internalMap[iter] = mask[iter];
868  }
869 
870  //================================================ Write out the mask
871  this->writeMap ( fName );
872 
873  //================================================ Copy the original map values back
874  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
875  {
876  this->internalMap[iter] = hlpMap[iter];
877  }
878 
879  //================================================ Release memory
880  delete[] hlpMap;
881 
882  //================================================ Done
883  return ;
884 }
885 
895 {
896  //================================================ Report function start
897  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Map inversion." );
898 
899  //================================================ Initialise variables
900  proshade_signed arrayPos, invPos;
901 
902  //================================================ Create helper map
903  proshade_double* hlpMap = new proshade_double [this->xDimIndices * this->yDimIndices * this->zDimIndices];
904  ProSHADE_internal_misc::checkMemoryAllocation ( hlpMap, __FILE__, __LINE__, __func__ );
905 
906  //================================================ Save map values to the helper map
907  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
908  {
909  hlpMap[iter] = this->internalMap[iter];
910  }
911 
912  //================================================ Invert the values
913  for ( proshade_signed xIt = 0; xIt < static_cast<proshade_signed> ( this->xDimIndices ); xIt++ )
914  {
915  for ( proshade_signed yIt = 0; yIt < static_cast<proshade_signed> ( this->yDimIndices ); yIt++ )
916  {
917  for ( proshade_signed zIt = 0; zIt < static_cast<proshade_signed> ( this->zDimIndices ); zIt++ )
918  {
919  //==================================== Var init
920  arrayPos = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
921  invPos = ( (this->zDimIndices-1) - zIt ) + this->zDimIndices * ( ( (this->yDimIndices-1) - yIt ) + this->yDimIndices * ( (this->xDimIndices-1) - xIt ) );
922 
923  //==================================== And save
924  this->internalMap[invPos] = hlpMap[arrayPos];
925  }
926  }
927  }
928 
929  //================================================ Release memory
930  delete[] hlpMap;
931 
932  //================================================ Report function completion
933  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Map inversion completed." );
934 
935  //================================================ Done
936  return ;
937 
938 }
939 
949 {
950  //================================================ Report function start
951  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Map normalisation." );
952 
953  //================================================ Initialise vector of map values
954  std::vector<proshade_double> mapVals ( this->xDimIndices * this->yDimIndices * this->zDimIndices, 0.0 );
955 
956  //================================================ Get all map values
957  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
958  {
959  mapVals.at(iter) = this->internalMap[iter];
960  }
961 
962  //================================================ Get mean and sd
963  proshade_double* meanSD = new proshade_double[2];
964  ProSHADE_internal_maths::vectorMeanAndSD ( &mapVals, meanSD );
965 
966  //================================================ Normalise the values
967  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
968  {
969  this->internalMap[iter] = ( this->internalMap[iter] - meanSD[0] ) / meanSD[1];
970  }
971 
972  //================================================ Clear the vector
973  mapVals.clear ( );
974 
975  //================================================ Release memory
976  delete[] meanSD;
977 
978  //================================================ Report function completion
979  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Map normalisation completed." );
980 
981  //================================================ Done
982  return ;
983 
984 }
985 
986 
996 {
997  //================================================ Report function start
998  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Computing mask." );
999 
1000  //================================================ Initialise the blurred map
1001  proshade_double* blurredMap = new proshade_double[this->xDimIndices * this->yDimIndices * this->zDimIndices];
1002  ProSHADE_internal_misc::checkMemoryAllocation ( blurredMap, __FILE__, __LINE__, __func__ );
1003 
1004  //================================================ Compute blurred map
1005  ProSHADE_internal_mapManip::blurSharpenMap ( this->internalMap, blurredMap, this->xDimIndices, this->yDimIndices, this->zDimIndices,
1006  this->xDimSize, this->yDimSize, this->zDimSize, settings->blurFactor );
1007 
1008  //================================================ Compute mask from blurred map and save it into the original map
1009  ProSHADE_internal_mapManip::getMaskFromBlurr ( blurredMap, this->internalMap, this->xDimIndices, this->yDimIndices, this->zDimIndices, settings->maskingThresholdIQRs );
1010 
1011  //================================================ Print the mask if need be
1012  if ( settings->saveMask ) { if ( settings->maskFileName == "" ) { this->writeMask ( "proshade_mask.map", blurredMap ); } else { std::stringstream ss; ss << settings->maskFileName << "_" << this->inputOrder << ".map"; this->writeMask ( ss.str(), blurredMap ); } }
1013 
1014  //================================================ Release memory
1015  delete[] blurredMap;
1016 
1017  //================================================ Report function completion
1018  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Mask computed." );
1019 
1020  //================================================ Done
1021  return ;
1022 
1023 }
1024 
1036 {
1037  //================================================ Report function start
1038  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Finding new boundaries." );
1039 
1040  //================================================ If same bounds as first one are required, test if possible and return these instead
1041  if ( settings->useSameBounds && ( this->inputOrder != 0 ) )
1042  {
1043  for ( proshade_unsign iter = 0; iter < 6; iter++ ) { ret[iter] = settings->forceBounds[iter]; }
1044  }
1045  //================================================ In this case, bounds need to be found de novo
1046  else
1047  {
1048  //============================================ Find the non-zero bounds
1049  ProSHADE_internal_mapManip::getNonZeroBounds ( this->internalMap, this->xDimIndices, this->yDimIndices, this->zDimIndices,
1050  this->xDimSize, this->yDimSize, this->zDimSize, ret );
1051 
1052  //============================================ Add the extra space
1053  ProSHADE_internal_mapManip::addExtraBoundSpace ( this->xDimIndices, this->yDimIndices, this->zDimIndices,
1054  this->xDimSize, this->yDimSize, this->zDimSize, ret, settings->boundsExtraSpace );
1055 
1056  //============================================ Beautify boundaries
1057  ProSHADE_internal_mapManip::beautifyBoundaries ( ret, this->xDimIndices, this->yDimIndices, this->zDimIndices, settings->boundsSimilarityThreshold, settings->verbose );
1058 
1059  //============================================ Report function results
1060  std::stringstream ssHlp;
1061  ssHlp << "New boundaries are: " << ret[1] - ret[0] + 1 << " x " << ret[3] - ret[2] + 1 << " x " << ret[5] - ret[4] + 1;
1062  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 3, ssHlp.str() );
1063 
1064  //============================================ If need be, save boundaries to be used for all other structure
1065  if ( settings->useSameBounds && ( this->inputOrder == 0 ) )
1066  {
1067  for ( proshade_unsign iter = 0; iter < 6; iter++ ) { settings->forceBounds[iter] = ret[iter]; }
1068  }
1069  }
1070 
1071  //================================================ Report function completion
1072  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "New boundaries determined." );
1073 
1074  //================================================ Done
1075  return ;
1076 
1077 }
1078 
1091 {
1092  //================================================ Report function start
1093  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Creating new structure according to the new bounds." );
1094 
1095  //================================================ Fill in basic info
1096  newStr->fileName = "N/A";
1097  newStr->fileType = ProSHADE_internal_io::MAP;
1098 
1099  //================================================ Fill in new structure values
1100  newStr->xDimIndices = static_cast<proshade_signed> ( newBounds[1] ) - static_cast<proshade_signed> ( newBounds[0] ) + 1;
1101  newStr->yDimIndices = static_cast<proshade_signed> ( newBounds[3] ) - static_cast<proshade_signed> ( newBounds[2] ) + 1;
1102  newStr->zDimIndices = static_cast<proshade_signed> ( newBounds[5] ) - static_cast<proshade_signed> ( newBounds[4] ) + 1;
1103 
1104  newStr->aAngle = this->aAngle;
1105  newStr->bAngle = this->aAngle;
1106  newStr->cAngle = this->aAngle;
1107 
1108  newStr->xDimSize = static_cast<proshade_single> ( newStr->xDimIndices ) * ( this->xDimSize / static_cast<proshade_single> ( this->xDimIndices ) );
1109  newStr->yDimSize = static_cast<proshade_single> ( newStr->yDimIndices ) * ( this->yDimSize / static_cast<proshade_single> ( this->yDimIndices ) );
1110  newStr->zDimSize = static_cast<proshade_single> ( newStr->zDimIndices ) * ( this->zDimSize / static_cast<proshade_single> ( this->zDimIndices ) );
1111 
1112  newStr->xGridIndices = newStr->xDimIndices;
1113  newStr->yGridIndices = newStr->yDimIndices;
1114  newStr->zGridIndices = newStr->zDimIndices;
1115 
1116  newStr->xAxisOrder = this->xAxisOrder;
1117  newStr->yAxisOrder = this->yAxisOrder;
1118  newStr->zAxisOrder = this->zAxisOrder;
1119 
1120  newStr->xAxisOrigin = this->xAxisOrigin + newBounds[0];
1121  newStr->yAxisOrigin = this->yAxisOrigin + newBounds[2];
1122  newStr->zAxisOrigin = this->zAxisOrigin + newBounds[4];
1123 
1124  newStr->xFrom = this->xFrom + newBounds[0];
1125  newStr->yFrom = this->yFrom + newBounds[2];
1126  newStr->zFrom = this->zFrom + newBounds[4];
1127 
1128  newStr->xTo = this->xTo - ( (this->xDimIndices-1) - newBounds[1] );
1129  newStr->yTo = this->yTo - ( (this->yDimIndices-1) - newBounds[3] );
1130  newStr->zTo = this->zTo - ( (this->zDimIndices-1) - newBounds[5] );
1131 
1132  //================================================ Allocate new structure map
1133  newStr->internalMap = new proshade_double[newStr->xDimIndices * newStr->yDimIndices * newStr->zDimIndices];
1134  ProSHADE_internal_misc::checkMemoryAllocation ( newStr->internalMap, __FILE__, __LINE__, __func__ );
1135 
1136  //================================================ Copy the map
1137  ProSHADE_internal_mapManip::copyMapByBounds ( newStr->xFrom, newStr->xTo, newStr->yFrom, newStr->yTo, newStr->zFrom, newStr->zTo,
1138  this->xFrom, this->yFrom, this->zFrom, newStr->yDimIndices, newStr->zDimIndices,
1139  this->xDimIndices, this->yDimIndices, this->zDimIndices, newStr->internalMap, this->internalMap );
1140 
1141  //================================================ Report function completion
1142  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "New structure created." );
1143 
1144  //================================================ Done
1145  return ;
1146 
1147 }
1148 
1157 {
1158  //================================================ Initialise the return variable
1159  proshade_single* changeVals = new proshade_single[6];
1160 
1161  //================================================ Now re-sample the map
1162  if ( settings->changeMapResolution )
1163  {
1164  ProSHADE_internal_mapManip::reSampleMapToResolutionFourier ( this->internalMap, settings->requestedResolution, this->xDimIndices, this->yDimIndices, this->zDimIndices,
1165  this->xDimSize, this->yDimSize, this->zDimSize, changeVals );
1166 
1167  if ( settings->changeMapResolutionTriLinear )
1168  {
1169  ProSHADE_internal_messages::printWarningMessage ( settings->verbose, "!!! ProSHADE WARNING !!! Requested both Fourier-space and real-space map re-sampling. Defaulting to only Fourier space re-samplling.", "WM00049" );
1170  }
1171  }
1172  if ( settings->changeMapResolutionTriLinear && !settings->changeMapResolution )
1173  {
1174  ProSHADE_internal_mapManip::reSampleMapToResolutionTrilinear ( this->internalMap, settings->requestedResolution, this->xDimIndices, this->yDimIndices, this->zDimIndices,
1175  this->xDimSize, this->yDimSize, this->zDimSize, changeVals );
1176 
1177  }
1178 
1179  //================================================ Set the internal values to reflect the new map size
1180  this->xDimIndices += static_cast<proshade_unsign> ( changeVals[0] );
1181  this->yDimIndices += static_cast<proshade_unsign> ( changeVals[1] );
1182  this->zDimIndices += static_cast<proshade_unsign> ( changeVals[2] );
1183 
1184  this->xGridIndices = this->xDimIndices;
1185  this->yGridIndices = this->yDimIndices;
1186  this->zGridIndices = this->zDimIndices;
1187 
1188  this->xTo += static_cast<proshade_unsign> ( changeVals[0] );
1189  this->yTo += static_cast<proshade_unsign> ( changeVals[1] );
1190  this->zTo += static_cast<proshade_unsign> ( changeVals[2] );
1191 
1192  this->xDimSize = changeVals[3];
1193  this->yDimSize = changeVals[4];
1194  this->zDimSize = changeVals[5];
1195 
1196  //================================================ Figure how much the new map moved
1197  proshade_single xMov = -( ( this->xFrom * ( this->xDimSize / static_cast<proshade_single> ( this->xDimIndices - changeVals[0] ) ) ) -
1198  ( this->xFrom * ( this->xDimSize / static_cast<proshade_single> ( this->xDimIndices ) ) ) );
1199  proshade_single yMov = -( ( this->yFrom * ( this->yDimSize / static_cast<proshade_single> ( this->yDimIndices - changeVals[1] ) ) ) -
1200  ( this->yFrom * ( this->yDimSize / static_cast<proshade_single> ( this->yDimIndices ) ) ) );
1201  proshade_single zMov = -( ( this->zFrom * ( this->zDimSize / static_cast<proshade_single> ( this->zDimIndices - changeVals[2] ) ) ) -
1202  ( this->zFrom * ( this->zDimSize / static_cast<proshade_single> ( this->zDimIndices ) ) ) );
1203 
1204  //================================================ Move by indices (this should be sufficient)
1205  ProSHADE_internal_mapManip::moveMapByIndices ( &xMov, &yMov, &zMov, this->xDimSize, this->yDimSize, this->zDimSize, &this->xFrom, &this->xTo,
1206  &this->yFrom, &this->yTo, &this->zFrom, &this->zTo, &this->xAxisOrigin, &this->yAxisOrigin, &this->zAxisOrigin );
1207 
1208  ProSHADE_internal_mapManip::moveMapByFourier ( this->internalMap, xMov, yMov, zMov, this->xDimSize, this->yDimSize, this->zDimSize,
1209  this->xDimIndices, this->yDimIndices, this->zDimIndices );
1210 
1211  //================================================ Release memory
1212  delete[] changeVals;
1213 
1214  //================================================ Done
1215  return ;
1216 
1217 }
1218 
1229 {
1230  //================================================ Report function start
1231  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Centering map onto its COM." );
1232 
1233  //================================================ Initialise local variables
1234  proshade_unsign arrPos = 0;
1235  proshade_single xCOM = 0.0;
1236  proshade_single yCOM = 0.0;
1237  proshade_single zCOM = 0.0;
1238  proshade_single totDens = 0.0;
1239 
1240  //================================================ Find the COM location
1241  for ( proshade_unsign xIt = 0; xIt < this->xDimIndices; xIt++ )
1242  {
1243  for ( proshade_unsign yIt = 0; yIt < this->yDimIndices; yIt++ )
1244  {
1245  for ( proshade_unsign zIt = 0; zIt < this->zDimIndices; zIt++ )
1246  {
1247  //==================================== Get index
1248  arrPos = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
1249 
1250  //==================================== Get COM
1251  if ( this->internalMap[arrPos] > 0.0 )
1252  {
1253  xCOM += static_cast<proshade_single> ( this->internalMap[arrPos] * xIt );
1254  yCOM += static_cast<proshade_single> ( this->internalMap[arrPos] * yIt );
1255  zCOM += static_cast<proshade_single> ( this->internalMap[arrPos] * zIt );
1256  totDens += static_cast<proshade_single> ( this->internalMap[arrPos] );
1257  }
1258  }
1259  }
1260  }
1261  xCOM /= totDens;
1262  yCOM /= totDens;
1263  zCOM /= totDens;
1264 
1265  //================================================ Find distance from COM to map centre in Angstroms
1266  proshade_single xDist = ( static_cast<proshade_single> ( this->xDimIndices / 2.0 ) - xCOM ) * static_cast<proshade_single> ( this->xDimSize / this->xDimIndices );
1267  proshade_single yDist = ( static_cast<proshade_single> ( this->yDimIndices / 2.0 ) - yCOM ) * static_cast<proshade_single> ( this->yDimSize / this->yDimIndices );
1268  proshade_single zDist = ( static_cast<proshade_single> ( this->zDimIndices / 2.0 ) - zCOM ) * static_cast<proshade_single> ( this->zDimSize / this->zDimIndices );
1269 
1270  //================================================ Move the map within the box
1271  ProSHADE_internal_mapManip::moveMapByFourier ( this->internalMap, xDist, yDist, zDist, this->xDimSize, this->yDimSize, this->zDimSize, this->xDimIndices, this->yDimIndices, this->zDimIndices );
1272 
1273  //================================================ Report function completion
1274  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Map centered." );
1275 
1276  //================================================ Done
1277  return ;
1278 
1279 }
1280 
1290 {
1291  //================================================ Report function start
1292  std::stringstream hlpSS;
1293  hlpSS << "Adding extra " << settings->addExtraSpace << " angstroms.";
1294  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, hlpSS.str() );
1295 
1296  //================================================ Figure how much indices need to change
1297  proshade_unsign xAddIndices = ProSHADE_internal_mapManip::myRound ( settings->addExtraSpace / static_cast<proshade_single> ( this->xDimSize / this->xDimIndices ) );
1298  proshade_unsign yAddIndices = ProSHADE_internal_mapManip::myRound ( settings->addExtraSpace / static_cast<proshade_single> ( this->yDimSize / this->yDimIndices ) );
1299  proshade_unsign zAddIndices = ProSHADE_internal_mapManip::myRound ( settings->addExtraSpace / static_cast<proshade_single> ( this->zDimSize / this->zDimIndices ) );
1300 
1301  //================================================ Update internal data variables
1302  this->xDimSize += static_cast<proshade_single> ( 2 * xAddIndices ) * static_cast<proshade_single> ( this->xDimSize / this->xDimIndices );
1303  this->yDimSize += static_cast<proshade_single> ( 2 * yAddIndices ) * static_cast<proshade_single> ( this->yDimSize / this->yDimIndices );
1304  this->zDimSize += static_cast<proshade_single> ( 2 * zAddIndices ) * static_cast<proshade_single> ( this->zDimSize / this->zDimIndices );
1305 
1306  this->xDimIndices += 2 * xAddIndices;
1307  this->yDimIndices += 2 * yAddIndices;
1308  this->zDimIndices += 2 * zAddIndices;
1309 
1310  this->xGridIndices = this->xDimIndices;
1311  this->yGridIndices = this->yDimIndices;
1312  this->zGridIndices = this->zDimIndices;
1313 
1314  this->xAxisOrigin -= xAddIndices;
1315  this->yAxisOrigin -= yAddIndices;
1316  this->zAxisOrigin -= zAddIndices;
1317 
1318  this->xFrom -= xAddIndices;
1319  this->yFrom -= yAddIndices;
1320  this->zFrom -= zAddIndices;
1321 
1322  this->xTo += xAddIndices;
1323  this->yTo += yAddIndices;
1324  this->zTo += zAddIndices;
1325 
1326  //================================================ Allocate new map
1327  proshade_double* newMap = new proshade_double[this->xDimIndices * this->yDimIndices * this->zDimIndices];
1328  ProSHADE_internal_misc::checkMemoryAllocation ( newMap, __FILE__, __LINE__, __func__ );
1329 
1330  //================================================ Set new map to zeroes
1331  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
1332  {
1333  newMap[iter] = 0.0;
1334  }
1335 
1336  //================================================ Update the map
1337  proshade_unsign newMapIndex, oldMapIndex;
1338  for ( proshade_unsign xIt = 0; xIt < (this->xDimIndices - xAddIndices); xIt++ )
1339  {
1340  //============================================ Check if point is applicable
1341  if ( xIt < xAddIndices ) { continue; }
1342 
1343  for ( proshade_unsign yIt = 0; yIt < (this->yDimIndices - yAddIndices); yIt++ )
1344  {
1345  //======================================== Check if point is applicable
1346  if ( yIt < yAddIndices ) { continue; }
1347 
1348  for ( proshade_unsign zIt = 0; zIt < (this->zDimIndices - zAddIndices); zIt++ )
1349  {
1350  //==================================== Check if point is applicable
1351  if ( zIt < zAddIndices ) { continue; }
1352 
1353  //==================================== Var init
1354  newMapIndex = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
1355  oldMapIndex = (zIt - zAddIndices) + (this->zDimIndices - ( 2 * zAddIndices ) ) * ( (yIt - yAddIndices) + (this->yDimIndices - ( 2 * yAddIndices ) ) * (xIt - xAddIndices) );
1356 
1357  newMap[newMapIndex] = this->internalMap[oldMapIndex];
1358  }
1359  }
1360  }
1361 
1362  //================================================ Copy new to old
1363  delete[] this->internalMap;
1364 
1365  this->internalMap = new proshade_double[this->xDimIndices * this->yDimIndices * this->zDimIndices];
1366  ProSHADE_internal_misc::checkMemoryAllocation ( this->internalMap, __FILE__, __LINE__, __func__ );
1367 
1368  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
1369  {
1370  this->internalMap[iter] = newMap[iter];
1371  }
1372 
1373  //================================================ Release memory
1374  delete[] newMap;
1375 
1376  //================================================ Report function completion
1377  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Extra space added." );
1378 
1379  //================================================ Done
1380  return ;
1381 
1382 }
1383 
1399 {
1400  //================================================ Invert map
1401  if ( settings->invertMap ) { this->invertMirrorMap ( settings ); }
1402  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Map inversion (mirror image) not requested." ); }
1403 
1404  //================================================ Normalise map
1405  if ( settings->normaliseMap ) { this->normaliseMap ( settings ); }
1406  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Map normalisation not requested." ); }
1407 
1408  //================================================ Compute mask
1409  //if ( settings->maskMap ) { if ( settings->useCorrelationMasking ) { this->maskMapCorrelation ( settings ); } else { this->maskMap ( settings ); } }
1410  if ( settings->maskMap ) { this->maskMap ( settings ); }
1411  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Masking not requested." ); }
1412 
1413  //================================================ Centre map
1414  if ( settings->moveToCOM ) { this->centreMapOnCOM ( settings ); }
1415  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Map centering not requested." ); }
1416 
1417  //================================================ Add extra space
1418  if ( settings->addExtraSpace != 0.0 ) { this->addExtraSpace ( settings ); }
1419  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Extra space not requested." ); }
1420 
1421  //================================================ Remove phase, if required
1422  if ( !settings->usePhase ) { this->removePhaseInormation ( settings ); ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Phase information removed from the data." ); }
1423  else { ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Phase information retained in the data." ); }
1424 
1425  //================================================ Set settings values which were left on AUTO by user and will not be set later
1426  settings->setVariablesLeftOnAuto ( );
1427 
1428  //================================================ Done
1429  return ;
1430 
1431 }
1432 
1443 {
1444  //================================================ Check the current settings value is set to auto
1445  if ( this->spherePos.size() != 0 )
1446  {
1447  std::stringstream hlpSS;
1448  hlpSS << "The sphere distances were determined as " << this->spherePos.at(0);
1449  for ( proshade_unsign iter = 1; iter < static_cast<proshade_unsign> ( this->spherePos.size() ); iter++ ) { hlpSS << "; " << this->spherePos.at(iter); }
1450  hlpSS << " Angstroms.";
1451  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 3, hlpSS.str() );
1452  return ;
1453  }
1454 
1455  //================================================ Find maximum diagonal
1456  proshade_unsign maxDim = std::max ( this->xDimSize, std::max ( this->yDimSize, this->zDimSize ) );
1457  proshade_unsign minDim = std::min ( this->xDimSize, std::min ( this->yDimSize, this->zDimSize ) );
1458  proshade_unsign midDim = 0;
1459  if ( ( this->xDimSize < maxDim ) && ( this->xDimSize > minDim ) ) { midDim = this->xDimSize; }
1460  else if ( ( this->yDimSize < maxDim ) && ( this->yDimSize > minDim ) ) { midDim = this->yDimSize; }
1461  else { midDim = this->zDimSize; }
1462 
1463  proshade_single maxDiag = std::sqrt ( std::pow ( static_cast<proshade_single> ( maxDim ), 2.0 ) +
1464  std::pow ( static_cast<proshade_single> ( midDim ), 2.0 ) );
1465 
1466  //================================================ Set between the points
1467  for ( proshade_single iter = 0.5; ( iter * settings->maxSphereDists ) < ( maxDiag / 2.0 ); iter += 1.0 )
1468  {
1469  ProSHADE_internal_misc::addToSingleVector ( &this->spherePos, ( iter * settings->maxSphereDists ) );
1470  }
1471 
1472  //================================================ Save the number of spheres
1473  this->noSpheres = static_cast<proshade_unsign> ( this->spherePos.size() );
1474 
1475  //================================================ Report progress
1476  std::stringstream hlpSS;
1477  hlpSS << "The sphere distances were determined as " << this->spherePos.at(0);
1478  for ( proshade_unsign iter = 1; iter < static_cast<proshade_unsign> ( this->spherePos.size() ); iter++ ) { hlpSS << "; " << this->spherePos.at(iter); }
1479  hlpSS << " Angstroms.";
1480  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 3, hlpSS.str() );
1481 
1482  //================================================ Done
1483  return ;
1484 
1485 }
1486 
1487 
1500 {
1501  //================================================ Report progress
1502  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Starting sphere mapping procedure." );
1503 
1504  //================================================ Determine spherical harmonics variables
1505  settings->determineAllSHValues ( this->xDimIndices, this->yDimIndices, this->zDimIndices );
1506  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Sphere settings determined." );
1507 
1508  //================================================ Find number of spheres supported
1509  this->getSpherePositions ( settings );
1510  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Sphere positions obtained." );
1511 
1512  //================================================ Create sphere objects and map the density
1513  this->spheres = new ProSHADE_internal_spheres::ProSHADE_sphere* [ this->noSpheres ];
1514  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( this->spherePos.size() ); iter++ )
1515  {
1516  std::stringstream ss;
1517  ss << "Now mapping sphere " << iter << " .";
1518  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 4, ss.str() );
1519 
1520  this->spheres[iter] = new ProSHADE_internal_spheres::ProSHADE_sphere ( this->xDimIndices, this->yDimIndices, this->zDimIndices,
1521  this->xDimSize, this->yDimSize, this->zDimSize, iter,
1522  &this->spherePos, settings->progressiveSphereMapping, settings->maxBandwidth,
1523  this->internalMap, &this->maxShellBand );
1524  }
1525 
1526  //================================================ Report completion
1527  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Sphere mapping procedure completed." );
1528 
1529  //================================================ Done
1530  return ;
1531 
1532 }
1533 
1543 {
1544  //================================================ Report progress
1545  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Starting spherical harmonics decomposition." );
1546 
1547  //================================================ Initialise memory
1548  this->sphericalHarmonics = new proshade_complex* [this->noSpheres];
1549  ProSHADE_internal_misc::checkMemoryAllocation ( this->sphericalHarmonics, __FILE__, __LINE__, __func__ );
1550  for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
1551  {
1552  this->sphericalHarmonics[iter] = new proshade_complex [(this->spheres[iter]->getLocalBandwidth() * 2) * (this->spheres[iter]->getLocalBandwidth() * 2)];
1553  ProSHADE_internal_misc::checkMemoryAllocation ( this->sphericalHarmonics[iter], __FILE__, __LINE__, __func__ );
1554  }
1555 
1556  //================================================ Compute the spherical harmonics
1557  for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
1558  {
1559  //============================================ Report progress
1560  std::stringstream ss;
1561  ss << "Now decomposing sphere " << iter << ". " << "( Band is: " << this->spheres[iter]->getLocalBandwidth() << ").";
1562  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 4, ss.str() );
1563 
1564  //============================================ Compute
1565  ProSHADE_internal_sphericalHarmonics::computeSphericalHarmonics ( this->spheres[iter]->getLocalBandwidth(), this->spheres[iter]->getMappedData(), this->sphericalHarmonics[iter] );
1566  }
1567 
1568  //================================================ Report completion
1569  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Spherical harmonics decomposition complete." );
1570 
1571  //======================================== Done
1572  return ;
1573 
1574 }
1575 
1587 void ProSHADE_internal_data::ProSHADE_data::detectSymmetryInStructure ( ProSHADE_settings* settings, std::vector< proshade_double* >* axes, std::vector < std::vector< proshade_double > >* allCs )
1588 {
1589  //================================================ Initialise variables
1590  std::vector< proshade_double* > CSyms = this->getCyclicSymmetriesList ( settings );
1591 
1592  //================================================ Was any particular symmetry requested?
1593  if ( settings->requestedSymmetryType == "" )
1594  {
1595  //============================================ Run the symmetry detection functions for C, D, T, O and I symmetries
1596  std::vector< proshade_double* > DSyms = this->getDihedralSymmetriesList ( settings, &CSyms );
1597  std::vector< proshade_double* > ISyms = this->getIcosahedralSymmetriesList ( settings, &CSyms );
1598  std::vector< proshade_double* > OSyms; std::vector< proshade_double* > TSyms;
1599  if ( ISyms.size() < 31 ) { OSyms = this->getOctahedralSymmetriesList ( settings, &CSyms ); if ( OSyms.size() < 13 ) { TSyms = this->getTetrahedralSymmetriesList ( settings, &CSyms ); } }
1600 
1601  //============================================ Decide on recommended symmetry
1602  this->saveRecommendedSymmetry ( settings, &CSyms, &DSyms, &TSyms, &OSyms, &ISyms, axes );
1603  }
1604 
1605  if ( settings->requestedSymmetryType == "C" )
1606  {
1607  //============================================ Run only the C symmetry detection and search for requested fold
1608  this->saveRequestedSymmetryC ( settings, &CSyms, axes );
1609  }
1610 
1611  if ( settings->requestedSymmetryType == "D" )
1612  {
1613  //============================================ Run only the D symmetry detection and search for requested fold
1614  std::vector< proshade_double* > DSyms = this->getDihedralSymmetriesList ( settings, &CSyms );
1615  this->saveRequestedSymmetryD ( settings, &DSyms, axes );
1616  }
1617 
1618  if ( settings->requestedSymmetryType == "T" )
1619  {
1620  //============================================ Run only the T symmetry detection and search for requested fold
1621  std::vector< proshade_double* > TSyms = this->getTetrahedralSymmetriesList ( settings, &CSyms );
1622  settings->setRecommendedFold ( 0 );
1623  if ( TSyms.size() == 7 ) { settings->setRecommendedSymmetry ( "T" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( TSyms.size() ); it++ ) { settings->setDetectedSymmetry ( TSyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, TSyms.at(it) ); } }
1624  else { settings->setRecommendedSymmetry ( "" ); }
1625  }
1626 
1627  if ( settings->requestedSymmetryType == "O" )
1628  {
1629  //============================================ Run only the O symmetry detection and search for requested fold
1630  std::vector< proshade_double* > OSyms = this->getOctahedralSymmetriesList ( settings, &CSyms );
1631  settings->setRecommendedFold ( 0 );
1632  if ( OSyms.size() == 13 ) { settings->setRecommendedSymmetry ( "O" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( OSyms.size() ); it++ ) { settings->setDetectedSymmetry ( OSyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, OSyms.at(it) ); } }
1633  else { settings->setRecommendedSymmetry ( "" ); }
1634  }
1635 
1636  if ( settings->requestedSymmetryType == "I" )
1637  {
1638  //============================================ Run only the T symmetry detection and search for requested fold
1639  std::vector< proshade_double* > ISyms = this->getIcosahedralSymmetriesList ( settings, &CSyms );
1640  settings->setRecommendedFold ( 0 );
1641  if ( ISyms.size() == 31 ) { settings->setRecommendedSymmetry ( "I" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( ISyms.size() ); it++ ) { settings->setDetectedSymmetry ( ISyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, ISyms.at(it) ); } }
1642  else { settings->setRecommendedSymmetry ( "" ); }
1643  }
1644 
1645  if ( ( settings->requestedSymmetryType != "" ) && ( settings->requestedSymmetryType != "C" ) && ( settings->requestedSymmetryType != "D" ) && ( settings->requestedSymmetryType != "T" ) && ( settings->requestedSymmetryType != "O" ) && ( settings->requestedSymmetryType != "I" ) )
1646  {
1647  throw ProSHADE_exception ( "Requested symmetry supplied, but not recognised.", "ES00032", __FILE__, __LINE__, __func__, "There are only the following value allowed for the\n : symmetry type request: \"C\", \"D\", \"T\", \"O\" and \"I\". Any\n : other value will result in this error." );
1648  }
1649 
1650  //================================================ Save C symmetries to argument and if different from settings, to the settings as well
1651  bool isArgSameAsSettings = true;
1652  for ( proshade_unsign cIt = 0; cIt < static_cast<proshade_unsign> ( CSyms.size() ); cIt++ )
1653  {
1654  std::vector< proshade_double > nextSym;
1655  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[0] );
1656  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[1] );
1657  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[2] );
1658  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[3] );
1659  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[4] );
1660  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms.at(cIt)[5] );
1662 
1663  if ( ( cIt == 0 ) && ( settings->allDetectedCAxes.size() == 0 ) ) { isArgSameAsSettings = false; }
1664  if ( !isArgSameAsSettings ) { ProSHADE_internal_misc::addToDoubleVectorVector ( &settings->allDetectedCAxes, nextSym ); }
1665 
1666  nextSym.clear ( );
1667  }
1668 
1669  //================================================ Release memory
1670  for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( CSyms.size() ); it++ ) { delete[] CSyms.at(it); }
1671 
1672  //================================================ Done
1673  return ;
1674 
1675 }
1676 
1685 {
1686  //================================================ Run the algorithm
1687  this->detectSymmetryInStructure ( settings, &settings->detectedSymmetry, &settings->allDetectedCAxes );
1688 
1689  //================================================ Done
1690  return ;
1691 
1692 }
1693 
1707 void ProSHADE_internal_data::ProSHADE_data::detectSymmetryFromAngleAxisSpace ( ProSHADE_settings* settings, std::vector< proshade_double* >* axes, std::vector < std::vector< proshade_double > >* allCs )
1708 {
1709  //================================================ Modify axis tolerance and matrix tolerance by sampling, if required by user
1710  if ( settings->axisErrToleranceDefault )
1711  {
1712  settings->axisErrTolerance = std::max ( 0.01, ( 2.0 * M_PI ) / this->maxShellBand );
1713  }
1714 
1715  //================================================ If C was requested, we will do it immediately - this allows for a significant speed-up.
1716  if ( settings->requestedSymmetryType == "C" )
1717  {
1718  //============================================ Report progress
1719  std::stringstream hlpSS;
1720  hlpSS << "Starting detection of cyclic point group C" << settings->requestedSymmetryFold;
1721  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, hlpSS.str() );
1722 
1723  //============================================ Do simplified search only in the applicable data
1724  proshade_double symThres = 0.0;
1725  std::vector< proshade_double* > CSyms = this->findRequestedCSymmetryFromAngleAxis ( settings, settings->requestedSymmetryFold, &symThres );
1726 
1727  //============================================ Save the best axis as the recommended one
1728  if ( settings->detectedSymmetry.size() == 0 ) { if ( CSyms.size() > 0 ) { settings->setDetectedSymmetry ( CSyms.at(0) ); } }
1729  if ( CSyms.size() > 0 )
1730  {
1731  settings->setRecommendedSymmetry ( "C" );
1732  settings->setRecommendedFold ( settings->requestedSymmetryFold );
1733 
1735  this->saveDetectedSymmetries ( settings, &CSyms, allCs );
1736  }
1737  else
1738  {
1739  settings->setRecommendedSymmetry ( "" );
1740  settings->setRecommendedFold ( 0 );
1741  }
1742 
1743  //============================================ Done
1744  return ;
1745  }
1746 
1747  //============================================ Report progress
1748  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Starting C symmetry detection." );
1749 
1750  //================================================ Initialise variables
1751  std::vector< proshade_double* > CSyms = getCyclicSymmetriesListFromAngleAxis ( settings );
1752 
1753  //================================================ Sanity check - was the rotation function mapped properly?
1754  if ( this->sphereMappedRotFun.size() < 1 )
1755  {
1756  throw ProSHADE_exception ( "Rotation function was not converted into angle-axis space.", "ES00062", __FILE__, __LINE__, __func__, "It seems that the convertRotationFunction() function was\n : not yet called. Therefore, there are no data to detect the\n : symmetry from; please call the convertRotationFunction()\n : function before the detectSymmetryFromAngleAxisSpace()\n : function." );
1757  }
1758 
1759  //================================================ Sanity check - was any symmetry requested?
1760  if ( ( settings->requestedSymmetryType != "" ) && ( settings->requestedSymmetryType != "C" ) && ( settings->requestedSymmetryType != "D" ) && ( settings->requestedSymmetryType != "T" ) && ( settings->requestedSymmetryType != "O" ) && ( settings->requestedSymmetryType != "I" ) )
1761  {
1762  throw ProSHADE_exception ( "Requested symmetry supplied, but not recognised.", "ES00032", __FILE__, __LINE__, __func__, "There are only the following value allowed for the\n : symmetry type request: \"C\", \"D\", \"T\", \"O\" and \"I\". Any\n : other value will result in this error." );
1763  }
1764 
1765  //================================================ Are we doing general search?
1766  if ( settings->requestedSymmetryType == "" )
1767  {
1768  //============================================ Run the symmetry detection functions for C, D, T, O and I symmetries
1769  std::vector< proshade_double* > DSyms = this->getDihedralSymmetriesList ( settings, &CSyms );
1770  std::vector< proshade_double* > ISyms = this->getPredictedIcosahedralSymmetriesList ( settings, &CSyms );
1771  std::vector< proshade_double* > OSyms; std::vector< proshade_double* > TSyms;
1772  if ( ISyms.size() < 31 ) { OSyms = this->getPredictedOctahedralSymmetriesList ( settings, &CSyms );
1773  if ( OSyms.size() < 13 ) { TSyms = this->getPredictedTetrahedralSymmetriesList ( settings, &CSyms ); } }
1774 
1775  //============================================ Decide on recommended symmetry
1776  this->saveRecommendedSymmetry ( settings, &CSyms, &DSyms, &TSyms, &OSyms, &ISyms, axes );
1777  }
1778 
1779  if ( settings->requestedSymmetryType == "D" )
1780  {
1781  //============================================ Run only the D symmetry detection and search for requested fold
1782  std::vector< proshade_double* > DSyms = this->getDihedralSymmetriesList ( settings, &CSyms );
1783  this->saveRequestedSymmetryD ( settings, &DSyms, axes );
1784  }
1785 
1786  if ( settings->requestedSymmetryType == "T" )
1787  {
1788  //============================================ Run only the T symmetry detection
1789  std::vector< proshade_double* > TSyms = this->getPredictedTetrahedralSymmetriesList ( settings, &CSyms );
1790  if ( TSyms.size() == 7 ) { settings->setRecommendedSymmetry ( "T" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( TSyms.size() ); it++ ) { settings->setDetectedSymmetry ( TSyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, TSyms.at(it) ); } }
1791  else { settings->setRecommendedSymmetry ( "" ); }
1792  }
1793 
1794  if ( settings->requestedSymmetryType == "O" )
1795  {
1796  //============================================ Run only the O symmetry detection
1797  std::vector< proshade_double* > OSyms = this->getPredictedOctahedralSymmetriesList ( settings, &CSyms );
1798  if ( OSyms.size() == 13 ) { settings->setRecommendedSymmetry ( "O" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( OSyms.size() ); it++ ) { settings->setDetectedSymmetry ( OSyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, OSyms.at(it) ); } }
1799  else { settings->setRecommendedSymmetry ( "" ); }
1800  }
1801 
1802  if ( settings->requestedSymmetryType == "I" )
1803  {
1804  //============================================ Run only the I symmetry detection
1805  std::vector< proshade_double* > ISyms = this->getPredictedIcosahedralSymmetriesList ( settings, &CSyms );
1806  if ( ISyms.size() == 31 ) { settings->setRecommendedSymmetry ( "I" ); for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( ISyms.size() ); it++ ) { settings->setDetectedSymmetry ( ISyms.at(it) ); ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, ISyms.at(it) ); } }
1807  else { settings->setRecommendedSymmetry ( "" ); }
1808  }
1809 
1810  //================================================ Save C symmetries to argument and if different from settings, to the settings as well
1811  this->saveDetectedSymmetries ( settings, &CSyms, allCs );
1812 
1813  //================================================ Done
1814  return ;
1815 
1816 }
1817 
1831 void ProSHADE_internal_data::ProSHADE_data::saveDetectedSymmetries ( ProSHADE_settings* settings, std::vector< proshade_double* >* CSyms, std::vector < std::vector< proshade_double > >* allCs )
1832 {
1833  //================================================ Initialise variables
1834  bool isArgSameAsSettings = true;
1835 
1836  //================================================ For each detected point group
1837  for ( proshade_unsign cIt = 0; cIt < static_cast<proshade_unsign> ( CSyms->size() ); cIt++ )
1838  {
1839  //============================================ Create vector to replace the pointer
1840  std::vector< proshade_double > nextSym;
1841  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[0] );
1842  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[1] );
1843  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[2] );
1844  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[3] );
1845  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[4] );
1846  ProSHADE_internal_misc::addToDoubleVector ( &nextSym, CSyms->at(cIt)[5] );
1848 
1849  //============================================ Copy the vector to output variable and if different, then also to settings object
1850  if ( ( cIt == 0 ) && ( settings->allDetectedCAxes.size() == 0 ) ) { isArgSameAsSettings = false; }
1851  if ( !isArgSameAsSettings ) { ProSHADE_internal_misc::addToDoubleVectorVector ( &settings->allDetectedCAxes, nextSym ); }
1852 
1853  //============================================ Release memory
1854  nextSym.clear ( );
1855  delete[] CSyms->at(cIt);
1856  }
1857 
1858  //================================================ Done
1859  return ;
1860 
1861 }
1862 
1863 
1873 proshade_double ProSHADE_internal_data::ProSHADE_data::findBestCScore ( std::vector< proshade_double* >* CSym, proshade_unsign* symInd )
1874 {
1875  //================================================ Sanity check
1876  if ( CSym->size() == 0 ) { *symInd = 0; return ( 0.0 ); }
1877 
1878  //================================================ Initalise variables
1879  proshade_double ret = CSym->at(0)[5];
1880  *symInd = 0;
1881  proshade_double frac = 0.0;
1882 
1883  //================================================ Check all other axes
1884 // THIS NEEDS TO BE IMPROVED USING THE MAXIMUM LIKELIHOOD FOR THIS FOLD
1885  for ( proshade_unsign ind = 1; ind < static_cast<proshade_unsign>( CSym->size() ); ind++ )
1886  {
1887  //============================================ If higher fold than already leading one (do not care for lower fold and lower average height axes)
1888  if ( CSym->at(ind)[0] > CSym->at(*symInd)[0] )
1889  {
1890  //======================================== How much higher fold is it? Also, adding some protection against large syms supported only by a subset and a minimum requirement.
1891  frac = ( std::abs( CSym->at(ind)[5]- 0.5 ) / std::abs( CSym->at(*symInd)[5] - 0.5 ) ) / ( CSym->at(*symInd)[0] / CSym->at(ind)[0] );
1892 
1893  //======================================== Check if the new is "better" according to this criteria.
1894  if ( frac >= 1.0 && ( ( CSym->at(*symInd)[5] * 0.85 ) < CSym->at(ind)[5] ) )
1895  {
1896  //==================================== And it is! Save and try next one.
1897  *symInd = ind;
1898  ret = CSym->at(ind)[5];
1899  }
1900  }
1901  }
1902 
1903  //================================================ Done
1904  return ( ret );
1905 
1906 }
1907 
1917 proshade_double ProSHADE_internal_data::ProSHADE_data::findBestDScore ( std::vector< proshade_double* >* DSym, proshade_unsign* symInd )
1918 {
1919  //================================================ Sort the vector
1920  std::sort ( DSym->begin(), DSym->end(), ProSHADE_internal_misc::sortDSymHlpInv );
1921 
1922  //================================================ Initalise variables
1923  proshade_double ret = 0.0;
1924  proshade_double frac = 0.0;
1925  if ( DSym->size() > 0 )
1926  {
1927  ret = ( ( DSym->at(0)[0] * DSym->at(0)[5] ) + ( DSym->at(0)[6] * DSym->at(0)[11] ) ) / ( DSym->at(0)[0] + DSym->at(0)[6] );
1928  *symInd = 0;
1929  }
1930  else { return ( ret ); }
1931 
1932  //================================================ Check all other axes
1933 // THIS NEEDS TO BE IMPROVED USING THE MAXIMUM LIKELIHOOD FOR THIS FOLD
1934  for ( proshade_unsign ind = 1; ind < static_cast<proshade_unsign>( DSym->size() ); ind++ )
1935  {
1936  //============================================ If higher fold than already leading one (do not care for lower fold and lower average height axes)
1937  if ( ( DSym->at(ind)[0] + DSym->at(ind)[6] ) > ( DSym->at(*symInd)[0] + DSym->at(*symInd)[6] ) )
1938  {
1939  //======================================== How much higher fold is it? Also, adding some protection against large syms supported only by a subset and a minimum requirement.
1940  frac = std::max ( std::min ( ( ( DSym->at(*symInd)[0] + DSym->at(*symInd)[6] ) / ( DSym->at(ind)[0] + DSym->at(ind)[6] ) ) * 1.5, 0.9 ), 0.6 );
1941 
1942  //======================================== Check if the new is "better" according to this criteria.
1943  if ( ( ( ( DSym->at(*symInd)[0] * DSym->at(*symInd)[5] ) + ( DSym->at(*symInd)[6] * DSym->at(*symInd)[11] ) ) / ( DSym->at(*symInd)[0] + DSym->at(*symInd)[6] ) * frac ) < ( ( DSym->at(ind)[0] * DSym->at(ind)[5] ) + ( DSym->at(ind)[6] * DSym->at(ind)[11] ) ) / ( DSym->at(ind)[0] + DSym->at(ind)[6] ) )
1944  {
1945  //==================================== And it is! Save and try next one.
1946  *symInd = ind;
1947  ret = ( ( DSym->at(ind)[0] * DSym->at(ind)[5] ) + ( DSym->at(ind)[6] * DSym->at(ind)[11] ) ) / ( DSym->at(ind)[0] + DSym->at(ind)[6] );
1948  }
1949  }
1950  }
1951 
1952  //================================================ Done
1953  return ( ret );
1954 
1955 }
1956 
1965 proshade_double ProSHADE_internal_data::ProSHADE_data::findTScore ( std::vector< proshade_double* >* TSym )
1966 {
1967  //================================================ Initialise variables
1968  proshade_double ret = 0.0;
1969  proshade_double foldSum = 0.0;
1970 
1971  //================================================ Check the T symmetry for being complete
1972  if ( TSym->size() == 7 )
1973  {
1974  //============================================ Compute the weighted fold
1975  for ( proshade_unsign cIt = 0; cIt < static_cast<proshade_unsign> ( TSym->size() ); cIt++ )
1976  {
1977  ret += TSym->at(cIt)[0] * TSym->at(cIt)[5];
1978  foldSum += TSym->at(cIt)[0];
1979  }
1980 
1981  //============================================ Weight
1982  ret /= foldSum;
1983  }
1984 
1985  //================================================ Done
1986  return ( ret );
1987 
1988 }
1989 
1998 proshade_double ProSHADE_internal_data::ProSHADE_data::findOScore ( std::vector< proshade_double* >* OSym )
1999 {
2000  //================================================ Initialise variables
2001  proshade_double ret = 0.0;
2002  proshade_double foldSum = 0.0;
2003 
2004  //================================================ Check the O symmetry for being complete
2005  if ( OSym->size() == 13 )
2006  {
2007  //============================================ Compute the weighted fold
2008  for ( proshade_unsign cIt = 0; cIt < static_cast<proshade_unsign> ( OSym->size() ); cIt++ )
2009  {
2010  ret += OSym->at(cIt)[0] * OSym->at(cIt)[5];
2011  foldSum += OSym->at(cIt)[0];
2012  }
2013 
2014  //============================================ Weight
2015  ret /= foldSum;
2016  }
2017 
2018  //================================================ Done
2019  return ( ret );
2020 
2021 }
2022 
2031 proshade_double ProSHADE_internal_data::ProSHADE_data::findIScore ( std::vector< proshade_double* >* ISym )
2032 {
2033  //================================================ Initialise variables
2034  proshade_double ret = 0.0;
2035  proshade_double foldSum = 0.0;
2036 
2037  //================================================ Check the T symmetry for being complete
2038  if ( ISym->size() == 31 )
2039  {
2040  //============================================ Compute the weighted fold
2041  for ( proshade_unsign cIt = 0; cIt < static_cast<proshade_unsign> ( ISym->size() ); cIt++ )
2042  {
2043  ret += ISym->at(cIt)[0] * ISym->at(cIt)[5];
2044  foldSum += ISym->at(cIt)[0];
2045  }
2046 
2047  //============================================ Weight
2048  ret /= foldSum;
2049  }
2050 
2051  //================================================ Done
2052  return ( ret );
2053 
2054 }
2055 
2070 void ProSHADE_internal_data::ProSHADE_data::saveRecommendedSymmetry ( ProSHADE_settings* settings, std::vector< proshade_double* >* CSym, std::vector< proshade_double* >* DSym, std::vector< proshade_double* >* TSym, std::vector< proshade_double* >* OSym, std::vector< proshade_double* >* ISym, std::vector< proshade_double* >* axes )
2071 {
2072  //================================================ Initialise variables
2073  proshade_double cScore = 0.0, dScore = 0.0, tScore = 0.0, oScore = 0.0, iScore = 0.0;
2074  proshade_unsign bestCIndex, bestDIndex;
2075 
2076  //================================================ Find a score for each input symmetry type.
2077  cScore = this->findBestCScore ( CSym, &bestCIndex );
2078  dScore = this->findBestDScore ( DSym, &bestDIndex );
2079  tScore = this->findTScore ( TSym );
2080  oScore = this->findOScore ( OSym );
2081  iScore = this->findIScore ( ISym );
2082 
2083  //================================================ Find the best available score - !!! Modified weights for the predicted symmetries as they have heights 0.0 (predicted) ...
2084  proshade_double bestWeightedScore = std::max ( cScore, std::max ( dScore * 1.1, std::max ( tScore * 3000.0, std::max ( oScore * 4000.0, iScore * 5000.0 ) ) ) );
2085 
2086  //================================================ No score? Well, no symmetry.
2087  if ( bestWeightedScore < 0.05 ) { settings->setRecommendedSymmetry ( "" ); return; }
2088 
2089  if ( bestWeightedScore == cScore )
2090  {
2091  settings->setRecommendedSymmetry ( "C" );
2092  settings->setRecommendedFold ( CSym->at(bestCIndex)[0] );
2093  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, CSym->at(bestCIndex) );
2094  if ( settings->detectedSymmetry.size() == 0 ) { settings->setDetectedSymmetry ( CSym->at(bestCIndex) ); }
2095 
2096  //============================================ Warn if resolution does not really support this fold
2097  if ( ( ( 360.0 / static_cast<double> ( CSym->at(bestCIndex)[0] ) ) - ( 360.0 / static_cast<double> ( CSym->at(bestCIndex)[0] + 1 ) ) ) <
2098  ( 360.0 / static_cast<double> ( settings->maxBandwidth * 4.0 ) ) )
2099  {
2100  std::stringstream hlpSS;
2101  hlpSS << "!!! ProSHADE WARNING !!! Reporting symmetry C" << CSym->at(bestCIndex)[0] << ", however, the grid sampling does not provide reasonable accuracy for symmetry with such high fold and therefore ProSHADE cannot responsibly claim this symmetry to be correct. It is suggested that the grid sampling is increased for more accurate symmetry detection. (Set higher resolution using -r).";
2102  ProSHADE_internal_messages::printWarningMessage ( settings->verbose, hlpSS.str(), "WS00054" );
2103  }
2104  }
2105  if ( bestWeightedScore == dScore * 1.1 )
2106  {
2107  settings->setRecommendedSymmetry ( "D" );
2108  settings->setRecommendedFold ( std::max ( DSym->at(bestDIndex)[0], DSym->at(bestDIndex)[6] ) );
2109  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, DSym->at(bestDIndex) );
2110  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, &DSym->at(bestDIndex)[6] );
2111  if ( settings->detectedSymmetry.size() == 0 )
2112  {
2113  settings->setDetectedSymmetry ( DSym->at(bestDIndex) );
2114  settings->setDetectedSymmetry ( &DSym->at(bestDIndex)[6] );
2115  }
2116 
2117  //============================================ Warn if resolution does not really support this fold
2118  if ( ( ( 360.0 / static_cast<double> ( std::max ( DSym->at(bestDIndex)[0], DSym->at(bestDIndex)[6] ) ) ) - ( 360.0 / static_cast<double> ( std::max ( DSym->at(bestDIndex)[0], DSym->at(bestDIndex)[6] ) + 1 ) ) ) <
2119  ( 360.0 / static_cast<double> ( settings->maxBandwidth * 4.0 ) ) )
2120  {
2121  std::stringstream hlpSS;
2122  hlpSS << "!!! ProSHADE WARNING !!! Reporting symmetry D" << std::max ( DSym->at(bestDIndex)[0], DSym->at(bestDIndex)[6] ) << ", however, the grid sampling does not provide reasonable accuracy for symmetry with such high fold and therefore ProSHADE cannot responsibly claim this symmetry to be correct. It is suggested that the grid sampling is increased for more accurate symmetry detection. (Set higher resolution using -r).";
2123  ProSHADE_internal_messages::printWarningMessage ( settings->verbose, hlpSS.str(), "WS00054" );
2124  }
2125  }
2126  if ( bestWeightedScore == tScore * 3000.0 )
2127  {
2128  settings->setRecommendedSymmetry ( "T" );
2129  settings->setRecommendedFold ( 0 );
2130  for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( TSym->size() ); it++ ) { ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, TSym->at(it) ); }
2131  if ( settings->detectedSymmetry.size() == 0 ) { for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( TSym->size() ); it++ ) { settings->setDetectedSymmetry ( TSym->at(it) ); } }
2132  }
2133  if ( bestWeightedScore == oScore * 4000.0 )
2134  {
2135  settings->setRecommendedSymmetry ( "O" );
2136  settings->setRecommendedFold ( 0 );
2137  for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( OSym->size() ); it++ ) { ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, OSym->at(it) ); }
2138  if ( settings->detectedSymmetry.size() == 0 ) { for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( OSym->size() ); it++ ) { settings->setDetectedSymmetry ( OSym->at(it) ); } }
2139  }
2140  if ( bestWeightedScore == iScore * 5000.0 )
2141  {
2142  settings->setRecommendedSymmetry ( "I" );
2143  settings->setRecommendedFold ( 0 );
2144  for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( ISym->size() ); it++ ) { ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, ISym->at(it) ); }
2145  if ( settings->detectedSymmetry.size() == 0 ) { for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( ISym->size() ); it++ ) { settings->setDetectedSymmetry ( ISym->at(it) ); } }
2146  }
2147 
2148  //================================================ Done
2149  return ;
2150 
2151 }
2152 
2164 void ProSHADE_internal_data::ProSHADE_data::saveRequestedSymmetryC ( ProSHADE_settings* settings, std::vector< proshade_double* >* CSym, std::vector< proshade_double* >* axes )
2165 {
2166  //================================================ Initialise variables
2167  proshade_unsign bestIndex = 0;
2168  proshade_double highestSym = 0.0;
2169 
2170  //================================================ Search for best fold
2171  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( CSym->size() ); iter++ )
2172  {
2173  //============================================ Check if it is tbe correct fold
2174  if ( CSym->at(iter)[0] != settings->requestedSymmetryFold ) { continue; }
2175 
2176  //============================================ If correct, is it the highest found?
2177  if ( CSym->at(iter)[5] > highestSym )
2178  {
2179  highestSym = CSym->at(iter)[5];
2180  bestIndex = iter;
2181  }
2182  }
2183 
2184  //================================================ Found?
2185  if ( highestSym > 0.0 )
2186  {
2187  settings->setRecommendedSymmetry ( "C" );
2188  settings->setRecommendedFold ( CSym->at(bestIndex)[0] );
2189  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, CSym->at(bestIndex) );
2190 
2191  if ( settings->detectedSymmetry.size() == 0 ) { settings->setDetectedSymmetry ( CSym->at(bestIndex) ); }
2192  }
2193  else
2194  {
2195  settings->setRecommendedSymmetry ( "" );
2196  settings->setRecommendedFold ( 0 );
2197  }
2198 
2199  //================================================ Done
2200  return ;
2201 
2202 }
2203 
2215 void ProSHADE_internal_data::ProSHADE_data::saveRequestedSymmetryD ( ProSHADE_settings* settings, std::vector< proshade_double* >* DSym, std::vector< proshade_double* >* axes )
2216 {
2217  //================================================ Initialise variables
2218  proshade_unsign bestIndex = 0;
2219  proshade_double highestSym = 0.0;
2220 
2221  //================================================ Search for best fold
2222  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( DSym->size() ); iter++ )
2223  {
2224  //============================================ Check if it is tbe correct fold
2225  if ( std::max ( DSym->at(iter)[0], DSym->at(iter)[6] ) != settings->requestedSymmetryFold ) { continue; }
2226 
2227  //============================================ If correct, is it the highest found?
2228  if ( ( DSym->at(iter)[5] + DSym->at(iter)[11] ) > highestSym )
2229  {
2230  highestSym = ( DSym->at(iter)[5] + DSym->at(iter)[11] );
2231  bestIndex = iter;
2232  }
2233  }
2234 
2235  //================================================ Found?
2236  if ( highestSym > 0.0 )
2237  {
2238  settings->setRecommendedSymmetry ( "D" );
2239  settings->setRecommendedFold ( std::max ( DSym->at(bestIndex)[0], DSym->at(bestIndex)[6] ) );
2240  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, DSym->at(bestIndex) );
2241  ProSHADE_internal_misc::deepCopyAxisToDblPtrVector ( axes, &DSym->at(bestIndex)[6] );
2242 
2243  if ( settings->detectedSymmetry.size() == 0 )
2244  {
2245  settings->setDetectedSymmetry ( DSym->at(bestIndex) );
2246  settings->setDetectedSymmetry ( &DSym->at(bestIndex)[6] );
2247  }
2248  }
2249  else
2250  {
2251  settings->setRecommendedSymmetry ( "" );
2252  settings->setRecommendedFold ( 0 );
2253  }
2254 
2255  //================================================ Done
2256  return ;
2257 
2258 }
2259 
2268 std::vector<std::vector< proshade_double > > ProSHADE_internal_data::computeGroupElementsForGroup ( proshade_double xAx, proshade_double yAx, proshade_double zAx, proshade_signed fold )
2269 {
2270  //================================================ Initialise variables
2271  std::vector< proshade_double > angList;
2272  std::vector<std::vector< proshade_double > > ret;
2273 
2274  //================================================ Allocate memory
2275  proshade_double* rotMat = new proshade_double[9];
2276  ProSHADE_internal_misc::checkMemoryAllocation ( rotMat, __FILE__, __LINE__, __func__ );
2277 
2278 
2279  //================================================ Normalise the axis to have magnitude of 1.0
2280  proshade_double normF = std::sqrt( std::pow ( xAx, 2.0 ) + std::pow ( yAx, 2.0 ) + std::pow ( zAx, 2.0 ) );
2281  xAx /= normF;
2282  yAx /= normF;
2283  zAx /= normF;
2284 
2285  //================================================ Determine the list of angles
2286  if ( fold % 2 == 0 )
2287  {
2288  //============================================ If fold is even, add the negative angles
2289  for ( proshade_double iter = static_cast < proshade_double > ( -( ( fold / 2 ) - 1 ) ); iter <= static_cast < proshade_double > ( fold / 2 ); iter++ )
2290  {
2291  ProSHADE_internal_misc::addToDoubleVector ( &angList, ( ( 2.0 * M_PI ) / static_cast<proshade_double> ( fold ) ) * iter );
2292  }
2293  }
2294  else
2295  {
2296  //============================================ If fold is odd, do the same as for even, but start one index earlier
2297  for ( proshade_double iter = static_cast < proshade_double > ( -fold / 2 ); iter <= static_cast < proshade_double > ( fold / 2 ); iter++ )
2298  {
2299  ProSHADE_internal_misc::addToDoubleVector ( &angList, ( ( 2.0 * M_PI ) / static_cast<proshade_double> ( fold ) ) * iter );
2300  }
2301  }
2302 
2303  //================================================ For each detected angle
2304  for ( proshade_unsign iter = 0; iter < static_cast < proshade_unsign > ( angList.size() ); iter++ )
2305  {
2306  //============================================ Compute the rotation matrix
2307  ProSHADE_internal_maths::getRotationMatrixFromAngleAxis ( rotMat, xAx, yAx, zAx, angList.at(iter) );
2308 
2309  //============================================ Convert to vector of vectors of doubles and save to ret
2310  std::vector < proshade_double > retEl;
2311  for ( proshade_unsign matIt = 0; matIt < 9; matIt++ )
2312  {
2313  ProSHADE_internal_misc::addToDoubleVector ( &retEl, rotMat[matIt] );
2314  }
2316  }
2317 
2318  //================================================ Release memory
2319  delete[] rotMat;
2320 
2321  //================================================ Done
2322  return ( ret );
2323 
2324 }
2325 
2332 void axesToGroupTypeSanityCheck ( proshade_unsign requiredAxes, proshade_unsign obtainedAxes, std::string groupType )
2333 {
2334  //================================================ Sanity check
2335  if ( obtainedAxes != requiredAxes )
2336  {
2337  std::stringstream hlpSS;
2338  hlpSS << "The supplied number of axes for group element\n : detection ( >" << obtainedAxes << "< ) does not match the group type ( >" << groupType << "< ).";
2339  throw ProSHADE_exception ( "Mismatch between supplied number of axes and\n : symmetry type.", "ES00059", __FILE__, __LINE__, __func__, hlpSS.str() );
2340  }
2341 
2342  //================================================ Done
2343  return ;
2344 
2345 }
2346 
2354 bool checkElementAlreadyExists ( std::vector<std::vector< proshade_double > >* elements, std::vector< proshade_double >* elem, proshade_double matrixTolerance )
2355 {
2356  //================================================ Initialise variables
2357  bool elementFound = false;
2358 
2359  //================================================ For each existing element
2360  for ( proshade_unsign elIt = 0; elIt < static_cast<proshade_unsign> ( elements->size() ); elIt++ )
2361  {
2362  if ( ProSHADE_internal_maths::rotationMatrixSimilarity ( &elements->at(elIt), elem, matrixTolerance ) )
2363  {
2364  elementFound = true;
2365  break;
2366  }
2367  }
2368 
2369  //================================================ Done
2370  return ( elementFound );
2371 
2372 }
2373 
2380 bool checkElementsFormGroup ( std::vector<std::vector< proshade_double > >* elements, proshade_double matrixTolerance )
2381 {
2382  //================================================ Initialise variables
2383  bool isGroup = true;
2384 
2385  //================================================ Multiply all group element pairs
2386  for ( proshade_unsign gr1 = 0; gr1 < static_cast<proshade_unsign> ( elements->size() ); gr1++ )
2387  {
2388  for ( proshade_unsign gr2 = 1; gr2 < static_cast<proshade_unsign> ( elements->size() ); gr2++ )
2389  {
2390  //======================================== Use unique pairs only
2391  if ( gr1 >= gr2 ) { continue; }
2392 
2393  //======================================== Multiply the two rotation matrices
2394  std::vector< proshade_double > product = ProSHADE_internal_maths::multiplyGroupElementMatrices ( &elements->at(gr1), &elements->at(gr2) );
2395 
2396  //======================================== Check the group already contains the produces as an element
2397  if ( !checkElementAlreadyExists ( elements, &product, matrixTolerance ) )
2398  {
2399  isGroup = false;
2400  break;
2401  }
2402  }
2403 
2404  //============================================ Stop if problem was found
2405  if ( !isGroup ) { break; }
2406  }
2407 
2408  //================================================ Done
2409  return ( isGroup );
2410 
2411 }
2412 
2421 std::vector<std::vector< proshade_double > > ProSHADE_internal_data::joinElementsFromDifferentGroups ( std::vector<std::vector< proshade_double > >* first, std::vector<std::vector< proshade_double > >* second, proshade_double matrixTolerance, bool combine )
2422 {
2423  //================================================ Initialise variables
2424  std::vector< std::vector< proshade_double > > ret;
2425 
2426  //================================================ Add the first list to ret, checking for uniqueness
2427  for ( proshade_unsign elIt = 0; elIt < static_cast<proshade_unsign> ( first->size() ); elIt++ )
2428  {
2429  if ( !checkElementAlreadyExists( &ret, &first->at(elIt), matrixTolerance ) )
2430  {
2431  ProSHADE_internal_misc::addToDoubleVectorVector ( &ret, first->at(elIt) );
2432  }
2433  }
2434 
2435  //================================================ Add the second list to ret, checking for uniqueness
2436  for ( proshade_unsign elIt = 0; elIt < static_cast<proshade_unsign> ( second->size() ); elIt++ )
2437  {
2438  if ( !checkElementAlreadyExists( &ret, &second->at(elIt), matrixTolerance ) )
2439  {
2440  ProSHADE_internal_misc::addToDoubleVectorVector ( &ret, second->at(elIt) );
2441  }
2442  }
2443 
2444  //================================================ Multiply all combinations of first and second and check for uniqueness
2445  if ( combine )
2446  {
2447  for ( proshade_unsign gr1 = 0; gr1 < static_cast<proshade_unsign> ( first->size() ); gr1++ )
2448  {
2449  for ( proshade_unsign gr2 = 0; gr2 < static_cast<proshade_unsign> ( second->size() ); gr2++ )
2450  {
2451  //==================================== Multiply the two rotation matrices
2452  std::vector< proshade_double > product = ProSHADE_internal_maths::multiplyGroupElementMatrices ( &first->at(gr1), &second->at(gr2) );
2453 
2454  //==================================== Add
2455  if ( !checkElementAlreadyExists( &ret, &product, matrixTolerance ) )
2456  {
2458  }
2459 
2460  }
2461  }
2462  }
2463 
2464  //================================================ Done
2465  return ( ret );
2466 
2467 }
2468 
2487 std::vector<std::vector< proshade_double > > ProSHADE_internal_data::ProSHADE_data::getAllGroupElements ( ProSHADE_settings* settings, std::vector< proshade_unsign > axesList, std::string groupType, proshade_double matrixTolerance )
2488 {
2489  //================================================ Initialise variables
2490  std::vector<std::vector< proshade_double > > ret;
2491 
2492  //================================================ Select which symmetry type are we computing for
2493  if ( groupType == "C" )
2494  {
2495  //============================================ Sanity check
2496  axesToGroupTypeSanityCheck ( 1, static_cast<proshade_unsign> ( axesList.size() ), groupType );
2497 
2498  //============================================ Generate elements
2499  ret = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(0)).at(1),
2500  settings->allDetectedCAxes.at(axesList.at(0)).at(2),
2501  settings->allDetectedCAxes.at(axesList.at(0)).at(3),
2502  settings->allDetectedCAxes.at(axesList.at(0)).at(0) );
2503 
2504  //============================================ Check the element to form a group
2505  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2506  else
2507  {
2508  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2509  }
2510  }
2511  else if ( groupType == "D" )
2512  {
2513  //============================================ Sanity check
2514  axesToGroupTypeSanityCheck ( 2, static_cast<proshade_unsign> ( axesList.size() ), groupType );
2515 
2516  //============================================ Generate elements for both axes
2517  std::vector<std::vector< proshade_double > > first = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(0)).at(1),
2518  settings->allDetectedCAxes.at(axesList.at(0)).at(2),
2519  settings->allDetectedCAxes.at(axesList.at(0)).at(3),
2520  settings->allDetectedCAxes.at(axesList.at(0)).at(0) );
2521  std::vector<std::vector< proshade_double > > second = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(1)).at(1),
2522  settings->allDetectedCAxes.at(axesList.at(1)).at(2),
2523  settings->allDetectedCAxes.at(axesList.at(1)).at(3),
2524  settings->allDetectedCAxes.at(axesList.at(1)).at(0) );
2525 
2526  //============================================ Join the element lists
2527  ret = joinElementsFromDifferentGroups ( &first, &second, matrixTolerance, true );
2528 
2529  //============================================ Check the element to form a group
2530  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2531  else
2532  {
2533  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2534  }
2535  }
2536  else if ( groupType == "T" )
2537  {
2538  //============================================ Sanity check
2539  axesToGroupTypeSanityCheck ( 7, static_cast<proshade_unsign> ( axesList.size() ), groupType );
2540 
2541  //============================================ Generate elements for all four C3 axes first
2542  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2543  {
2544  //======================================== If this is a C3 axis
2545  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 3 )
2546  {
2547  //==================================== Generate the elements
2548  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2549  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2550  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2551  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2552 
2553  //==================================== Join the elements to any already found
2554  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2555  }
2556  }
2557 
2558  //============================================ Generate elements for all three C2 axes second
2559  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2560  {
2561  //======================================== If this is a C3 axis
2562  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 2 )
2563  {
2564  //==================================== Generate the elements
2565  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2566  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2567  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2568  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2569 
2570  //==================================== Join the elements to any already found
2571  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2572  }
2573  }
2574 
2575  //============================================ Check the element to form a group
2576  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2577  else
2578  {
2579  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2580  }
2581  }
2582  else if ( groupType == "O" )
2583  {
2584  //============================================ Sanity check
2585  axesToGroupTypeSanityCheck ( 13, static_cast<proshade_unsign> ( axesList.size() ), groupType );
2586 
2587  //============================================ Generate elements for all three C4 axes first
2588  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2589  {
2590  //======================================== If this is a C3 axis
2591  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 4 )
2592  {
2593  //==================================== Generate the elements
2594  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2595  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2596  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2597  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2598 
2599  //==================================== Join the elements to any already found
2600  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2601  }
2602  }
2603 
2604  //============================================ Generate elements for all four C3 axes first
2605  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2606  {
2607  //======================================== If this is a C3 axis
2608  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 3 )
2609  {
2610  //==================================== Generate the elements
2611  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2612  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2613  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2614  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2615 
2616  //==================================== Join the elements to any already found
2617  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2618  }
2619  }
2620 
2621  //============================================ Generate elements for all six C2 axes next
2622  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2623  {
2624  //======================================== If this is a C3 axis
2625  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 2 )
2626  {
2627  //==================================== Generate the elements
2628  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2629  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2630  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2631  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2632 
2633  //==================================== Join the elements to any already found
2634  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2635  }
2636  }
2637 
2638  //============================================ Check the element to form a group
2639  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2640  else
2641  {
2642  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2643  }
2644  }
2645  else if ( groupType == "I" )
2646  {
2647  //============================================ Sanity check
2648  axesToGroupTypeSanityCheck ( 31, static_cast<proshade_unsign> ( axesList.size() ), groupType );
2649 
2650  //============================================ Generate elements for all six C5 axes first
2651  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2652  {
2653  //======================================== If this is a C5 axis
2654  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 5 )
2655  {
2656  //==================================== Generate the elements
2657  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2658  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2659  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2660  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2661 
2662  //==================================== Join the elements to any already found
2663  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2664  }
2665  }
2666 
2667  //============================================ Generate elements for all ten C3 axes next
2668  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2669  {
2670  //======================================== If this is a C3 axis
2671  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 3 )
2672  {
2673  //==================================== Generate the elements
2674  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2675  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2676  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2677  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2678 
2679  //==================================== Join the elements to any already found
2680  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2681  }
2682  }
2683 
2684  //============================================ Generate elements for all fifteen C2 axes lastly
2685  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2686  {
2687  //======================================== If this is a C3 axis
2688  if ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) == 2 )
2689  {
2690  //==================================== Generate the elements
2691  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2692  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2693  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2694  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2695 
2696  //==================================== Join the elements to any already found
2697  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, false );
2698  }
2699  }
2700 
2701  //============================================ Check the element to form a group
2702  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2703  else
2704  {
2705  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2706  }
2707  }
2708  else if ( groupType == "X" )
2709  {
2710  //============================================ User forced no checking for unspecified symmetry
2711  for ( proshade_unsign grIt = 0; grIt < static_cast<proshade_unsign> ( axesList.size() ); grIt++ )
2712  {
2713  //======================================== Compute group elements
2714  std::vector<std::vector< proshade_double > > els = computeGroupElementsForGroup ( settings->allDetectedCAxes.at(axesList.at(grIt)).at(1),
2715  settings->allDetectedCAxes.at(axesList.at(grIt)).at(2),
2716  settings->allDetectedCAxes.at(axesList.at(grIt)).at(3),
2717  settings->allDetectedCAxes.at(axesList.at(grIt)).at(0) );
2718 
2719  //======================================== Join the elements to any already found
2720  ret = joinElementsFromDifferentGroups ( &els, &ret, matrixTolerance, true );
2721  }
2722 
2723  //============================================ Check the element to form a group
2724  if ( checkElementsFormGroup ( &ret, matrixTolerance ) ) { return ( ret ); }
2725  else
2726  {
2727  throw ProSHADE_exception ( "Computed point group elements do not form a group.", "ES00060", __FILE__, __LINE__, __func__, "The supplied cyclic groups list does not form a group and\n : therefore such group's elements cannot be obtained. Please\n : check the cyclic groups list supplied to the\n : getAllGroupElements() function." );
2728  }
2729  }
2730  else
2731  {
2732  std::stringstream hlpSS;
2733  hlpSS << "Unknown symmetry type: >" << groupType << "<";
2734  throw ProSHADE_exception ( hlpSS.str().c_str(), "ES00058", __FILE__, __LINE__, __func__, "Function getAllGroupElements was called with symmetry type\n : value outside of the allowed values C, D, T, O, I\n : or empty for using all supplied axes." );
2735  }
2736 
2737  //================================================ Done
2738  return ( ret );
2739 
2740 }
2741 
2749 void ProSHADE_internal_data::ProSHADE_data::deepCopyMap ( proshade_double*& saveTo, proshade_unsign verbose )
2750 {
2751  //================================================ Sanity check
2752  if ( saveTo != NULL )
2753  {
2754  ProSHADE_internal_messages::printWarningMessage ( verbose, "!!! ProSHADE WARNING !!! The deep copy pointer is not set to NULL. Cannot proceed and returning unmodified pointer.", "WB00040" );
2755  return ;
2756  }
2757 
2758  //================================================ Allocate the memory
2759  saveTo = new proshade_double[this->xDimIndices * this->yDimIndices * this->zDimIndices];
2760 
2761  //================================================ Check memory allocation
2762  ProSHADE_internal_misc::checkMemoryAllocation ( saveTo, __FILE__, __LINE__, __func__ );
2763 
2764  //================================================ Copy internal map to the new pointer
2765  for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
2766  {
2767  saveTo[iter] = this->internalMap[iter];
2768  }
2769 
2770  //================================================ Done
2771  return ;
2772 
2773 }
2774 
2782 {
2783  //================================================ Improve this!
2784  if ( settings->recommendedSymmetryType == "" )
2785  {
2786  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, "Did not detect any symmetry!" );
2787  }
2788  else
2789  {
2790  std::stringstream ssHlp;
2791  ssHlp << std::endl << "Detected " << settings->recommendedSymmetryType << " symmetry with fold " << settings->recommendedSymmetryFold << " .";
2792  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2793 
2794  if ( settings->detectedSymmetry.size() > 0 )
2795  {
2796  ssHlp.clear(); ssHlp.str ( "" );
2797  ssHlp << " Fold X Y Z Angle Height";
2798  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2799  }
2800  for ( proshade_unsign symIt = 0; symIt < static_cast<proshade_unsign> ( settings->detectedSymmetry.size() ); symIt++ )
2801  {
2802  ssHlp.clear(); ssHlp.str ( "" );
2803  ssHlp << std::showpos << std::fixed << std::setprecision(0) << " " << settings->detectedSymmetry.at(symIt)[0] << std::setprecision(5) << " " << settings->detectedSymmetry.at(symIt)[1] << " " << settings->detectedSymmetry.at(symIt)[2] << " " << settings->detectedSymmetry.at(symIt)[3] << " " << settings->detectedSymmetry.at(symIt)[4] << " " << settings->detectedSymmetry.at(symIt)[5];
2804  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2805  }
2806 
2807  std::stringstream hlpSS3;
2808  ssHlp.clear(); ssHlp.str ( "" );
2809  hlpSS3 << std::endl << "However, since the selection of the recommended symmetry needs improvement, here is a list of all detected C symmetries:";
2810  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, hlpSS3.str() );
2811 
2812  if ( settings->allDetectedCAxes.size() > 0 )
2813  {
2814  ssHlp.clear(); ssHlp.str ( "" );
2815  ssHlp << " Fold X Y Z Angle Height";
2816  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2817  }
2818  for ( proshade_unsign symIt = 0; symIt < static_cast<proshade_unsign> ( settings->allDetectedCAxes.size() ); symIt++ )
2819  {
2820  ssHlp.clear(); ssHlp.str ( "" );
2821  ssHlp << std::showpos << std::fixed << std::setprecision(0) << " " << settings->allDetectedCAxes.at(symIt)[0] << std::setprecision(5) << " " << settings->allDetectedCAxes.at(symIt)[1] << " " << settings->allDetectedCAxes.at(symIt)[2] << " " << settings->allDetectedCAxes.at(symIt)[3] << " " << settings->allDetectedCAxes.at(symIt)[4] << " " << settings->allDetectedCAxes.at(symIt)[5];
2822  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2823  }
2824 
2825  hlpSS3.clear(); hlpSS3.str ( "" );
2826  hlpSS3 << std::endl << "Also, for the same reason, here is a list of all detected D symmetries:";
2827  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, hlpSS3.str() );
2828 
2829  if ( settings->allDetectedDAxes.size() > 0 )
2830  {
2831  ssHlp.clear(); ssHlp.str ( "" );
2832  ssHlp << " Fold X Y Z Angle Height";
2833  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2834  }
2835  for ( proshade_unsign symIt = 0; symIt < static_cast<proshade_unsign> ( settings->allDetectedDAxes.size() ); symIt++ )
2836  {
2837  ssHlp.clear(); ssHlp.str ( "" );
2838  ssHlp << std::showpos << std::fixed << std::setprecision(0) << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[0] << std::setprecision(5) << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[1] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[2] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[3] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[4] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(0))[5];
2839  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2840 
2841  for ( proshade_unsign axIt = 1; axIt < static_cast<proshade_unsign> ( settings->allDetectedDAxes.at(symIt).size() ); axIt++ )
2842  {
2843  ssHlp.clear(); ssHlp.str ( "" );
2844  ssHlp << std::showpos << std::fixed << std::setprecision(0) << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[0] << std::setprecision(5) << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[1] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[2] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[3] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[4] << " " << settings->allDetectedCAxes.at(settings->allDetectedDAxes.at(symIt).at(axIt))[5];
2845  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2846  }
2847 
2848  ssHlp.clear(); ssHlp.str ( "" );
2849  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, ssHlp.str() );
2850  }
2851 
2852  }
2853 
2854  //================================================ Done
2855  return ;
2856 
2857 }
2858 
2864 {
2865  //================================================ Initialise variables
2866  this->xCom = 0.0;
2867  this->yCom = 0.0;
2868  this->zCom = 0.0;
2869  proshade_double totNonZeroPoints = 0.0;
2870  proshade_signed mapIt = 0;
2871 
2872  //================================================ Compute COM from 0 ; 0 ; 0
2873  for ( proshade_signed xIt = 0; xIt < static_cast<proshade_signed> ( this->xDimIndices ); xIt++ )
2874  {
2875  for ( proshade_signed yIt = 0; yIt < static_cast<proshade_signed> ( this->yDimIndices ); yIt++ )
2876  {
2877  for ( proshade_signed zIt = 0; zIt < static_cast<proshade_signed> ( this->zDimIndices ); zIt++ )
2878  {
2879  //==================================== Find map index
2880  mapIt = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
2881 
2882  //==================================== Use only positive density
2883  if ( this->internalMap[mapIt] <= 0.0 ) { continue; }
2884 
2885  //==================================== Compute Index COM
2886  this->xCom += this->internalMap[mapIt] * static_cast<proshade_double> ( xIt + this->xFrom );
2887  this->yCom += this->internalMap[mapIt] * static_cast<proshade_double> ( yIt + this->yFrom );
2888  this->zCom += this->internalMap[mapIt] * static_cast<proshade_double> ( zIt + this->zFrom );
2889  totNonZeroPoints += this->internalMap[mapIt];
2890  }
2891  }
2892  }
2893 
2894  this->xCom /= totNonZeroPoints;
2895  this->yCom /= totNonZeroPoints;
2896  this->zCom /= totNonZeroPoints;
2897 
2898  //================================================ Convert to real world
2899  this->xCom = ( static_cast<proshade_double> ( this->xFrom ) * ( this->xDimSizeOriginal / static_cast<proshade_double> ( this->xDimIndicesOriginal ) ) ) +
2900  ( ( this->xCom - static_cast<proshade_double> ( this->xFrom ) ) *
2901  ( this->xDimSizeOriginal / static_cast<proshade_double> ( this->xDimIndicesOriginal ) ) );
2902  this->yCom = ( static_cast<proshade_double> ( this->yFrom ) * ( this->yDimSizeOriginal / static_cast<proshade_double> ( this->yDimIndicesOriginal ) ) ) +
2903  ( ( this->yCom - static_cast<proshade_double> ( this->yFrom ) ) *
2904  ( this->yDimSizeOriginal / static_cast<proshade_double> ( this->yDimIndicesOriginal ) ) );
2905  this->zCom = ( static_cast<proshade_double> ( this->zFrom ) * ( this->zDimSizeOriginal / static_cast<proshade_double> ( this->zDimIndicesOriginal ) ) ) +
2906  ( ( this->zCom - static_cast<proshade_double> ( this->zFrom ) ) *
2907  ( this->zDimSizeOriginal / static_cast<proshade_double> ( this->zDimIndicesOriginal ) ) );
2908 
2909  //================================================ Done
2910  return ;
2911 
2912 }
2913 
2919 {
2920  //================================================ Return the value
2921  return ( this->noSpheres );
2922 }
2923 
2929 proshade_double ProSHADE_internal_data::ProSHADE_data::getMapValue ( proshade_unsign pos )
2930 {
2931  //================================================ Return the value
2932  return ( this->internalMap[pos] );
2933 }
2934 
2940 {
2941  //================================================ Return the value
2942  return ( this->maxShellBand );
2943 }
2944 
2949 proshade_double ProSHADE_internal_data::ProSHADE_data::getRRPValue ( proshade_unsign band, proshade_unsign sh1, proshade_unsign sh2 )
2950 {
2951  //================================================ Return the value
2952  return ( this->rrpMatrices[band][sh1][sh2] );
2953 }
2954 
2965 bool ProSHADE_internal_data::ProSHADE_data::shellBandExists ( proshade_unsign shell, proshade_unsign bandVal )
2966 {
2967  if ( this->spheres[shell]->getLocalBandwidth( ) >= bandVal )
2968  {
2969  return ( true );
2970  }
2971  else
2972  {
2973  return ( false );
2974  }
2975 }
2976 
2986 {
2987  //================================================ Report function start
2988  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 1, "Centering map onto its COM." );
2989 
2990  //================================================ Copy map for processing
2991  fftw_complex* mapCoeffs = new fftw_complex[this->xDimIndices * this->yDimIndices * this->zDimIndices];
2992  fftw_complex* pattersonMap = new fftw_complex[this->xDimIndices * this->yDimIndices * this->zDimIndices];
2993 
2994  //================================================ Check memory allocation
2995  ProSHADE_internal_misc::checkMemoryAllocation ( mapCoeffs, __FILE__, __LINE__, __func__ );
2996  ProSHADE_internal_misc::checkMemoryAllocation ( pattersonMap, __FILE__, __LINE__, __func__ );
2997 
2998  //================================================ Copy data to mask
2999  for ( proshade_unsign iter = 0; iter < (this->xDimIndices * this->yDimIndices * this->zDimIndices); iter++ )
3000  {
3001  pattersonMap[iter][0] = this->internalMap[iter];
3002  pattersonMap[iter][1] = 0.0;
3003  }
3004 
3005  //================================================ Prepare FFTW plans
3006  fftw_plan forward = fftw_plan_dft_3d ( this->xDimIndices, this->yDimIndices, this->zDimIndices,
3007  pattersonMap, mapCoeffs, FFTW_FORWARD, FFTW_ESTIMATE );
3008  fftw_plan inverse = fftw_plan_dft_3d ( this->xDimIndices, this->yDimIndices, this->zDimIndices,
3009  mapCoeffs, pattersonMap, FFTW_BACKWARD, FFTW_ESTIMATE );
3010 
3011  //================================================ Run forward Fourier
3012  fftw_execute ( forward );
3013 
3014  //================================================ Remove the phase
3015  ProSHADE_internal_mapManip::removeMapPhase ( mapCoeffs, this->xDimIndices, this->yDimIndices, this->zDimIndices );
3016 
3017  //================================================ Run inverse Fourier
3018  fftw_execute ( inverse );
3019 
3020  //================================================ Save the results
3021  proshade_signed mapIt, patIt, patX, patY, patZ;
3022  for ( proshade_signed xIt = 0; xIt < static_cast<proshade_signed> ( this->xDimIndices ); xIt++ )
3023  {
3024  for ( proshade_signed yIt = 0; yIt < static_cast<proshade_signed> ( this->yDimIndices ); yIt++ )
3025  {
3026  for ( proshade_signed zIt = 0; zIt < static_cast<proshade_signed> ( this->zDimIndices ); zIt++ )
3027  {
3028  //==================================== Centre patterson map
3029  patX = xIt - ( static_cast<proshade_signed> ( this->xDimIndices ) / 2 ); if ( patX < 0 ) { patX += this->xDimIndices; }
3030  patY = yIt - ( static_cast<proshade_signed> ( this->yDimIndices ) / 2 ); if ( patY < 0 ) { patY += this->yDimIndices; }
3031  patZ = zIt - ( static_cast<proshade_signed> ( this->zDimIndices ) / 2 ); if ( patZ < 0 ) { patZ += this->zDimIndices; }
3032 
3033  //==================================== Find indices
3034  mapIt = zIt + this->zDimIndices * ( yIt + this->yDimIndices * xIt );
3035  patIt = patZ + this->zDimIndices * ( patY + this->yDimIndices * patX );
3036 
3037  //==================================== Copy
3038  this->internalMap[mapIt] = pattersonMap[patIt][0];
3039  }
3040  }
3041  }
3042 
3043  //================================================ Release memory
3044  delete[] pattersonMap;
3045  delete[] mapCoeffs;
3046 
3047  //================================================ Delete FFTW plans
3048  fftw_destroy_plan ( forward );
3049  fftw_destroy_plan ( inverse );
3050 
3051  //================================================ Report function completion
3052  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Phase information removed." );
3053 
3054  //================================================ Done
3055  return ;
3056 
3057 }
3058 
3063 proshade_double* ProSHADE_internal_data::ProSHADE_data::getRealSphHarmValue ( proshade_unsign band, proshade_unsign order, proshade_unsign shell )
3064 {
3065  //================================================ Done
3066  return ( &this->sphericalHarmonics[shell][seanindex ( static_cast<proshade_signed> ( order ) - static_cast<proshade_signed> ( band ),
3067  band,
3068  this->spheres[shell]->getLocalBandwidth() )][0] );
3069 
3070 }
3071 
3076 proshade_double* ProSHADE_internal_data::ProSHADE_data::getImagSphHarmValue ( proshade_unsign band, proshade_unsign order, proshade_unsign shell )
3077 {
3078  //================================================ Done
3079  return ( &this->sphericalHarmonics[shell][seanindex ( static_cast<proshade_signed> ( order ) - static_cast<proshade_signed> ( band ),
3080  band,
3081  this->spheres[shell]->getLocalBandwidth() )][1] );
3082 
3083 }
3084 
3089 proshade_double ProSHADE_internal_data::ProSHADE_data::getAnySphereRadius ( proshade_unsign shell )
3090 {
3091  //================================================ Done
3092  return ( this->spheres[shell]->getShellRadius() );
3093 
3094 }
3095 
3101 {
3102  //================================================ Done
3103  return ( this->integrationWeight );
3104 
3105 }
3106 
3112 proshade_unsign ProSHADE_internal_data::ProSHADE_data::getShellBandwidth ( proshade_unsign shell )
3113 {
3114  //================================================ Done
3115  return ( this->spheres[shell]->getLocalBandwidth ( ) );
3116 
3117 }
3118 
3124 proshade_double ProSHADE_internal_data::ProSHADE_data::getSpherePosValue ( proshade_unsign shell )
3125 {
3126  //================================================ Done
3127  return ( this->spherePos.at(shell) );
3128 
3129 }
3130 
3136 proshade_complex** ProSHADE_internal_data::ProSHADE_data::getEMatrixByBand ( proshade_unsign band )
3137 {
3138  //================================================ Done
3139  return ( this->eMatrices[band] );
3140 
3141 }
3142 
3151 void ProSHADE_internal_data::ProSHADE_data::getEMatrixValue ( proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double* valueReal, proshade_double* valueImag )
3152 {
3153  //================================================ Set pointer
3154  *valueReal = this->eMatrices[band][order1][order2][0];
3155  *valueImag = this->eMatrices[band][order1][order2][1];
3156 
3157  //================================================ Done
3158  return ;
3159 
3160 }
3161 
3167 {
3168  //================================================ Done
3169  return ( this->so3CoeffsInverse );
3170 
3171 }
3172 
3178 {
3179  //================================================ Done
3180  return ( this->so3Coeffs );
3181 
3182 }
3183 
3189 {
3190  //================================================ Done
3191  return ( this->maxCompBand );
3192 
3193 }
3194 
3203 void ProSHADE_internal_data::ProSHADE_data::getWignerMatrixValue ( proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double* valueReal, proshade_double* valueImag )
3204 {
3205  //================================================ Set pointer
3206  *valueReal = this->wignerMatrices[band][order1][order2][0];
3207  *valueImag = this->wignerMatrices[band][order1][order2][1];
3208 
3209  //================================================ Done
3210  return ;
3211 
3212 }
3213 
3219 {
3220  //================================================ Return the requested value
3221  return ( this->xDimSize );
3222 }
3223 
3229 {
3230  //================================================ Return the requested value
3231  return ( this->yDimSize );
3232 }
3233 
3239 {
3240  //================================================ Return the requested value
3241  return ( this->zDimSize );
3242 }
3243 
3249 {
3250  //================================================ Return the requested value
3251  return ( this->xDimIndices );
3252 }
3253 
3259 {
3260  //================================================ Return the requested value
3261  return ( this->yDimIndices );
3262 }
3263 
3269 {
3270  //================================================ Return the requested value
3271  return ( this->zDimIndices );
3272 }
3273 
3279 {
3280  //================================================ Return the requested value
3281  return ( &this->xFrom );
3282 }
3283 
3289 {
3290  //================================================ Return the requested value
3291  return ( &this->yFrom );
3292 }
3293 
3299 {
3300  //================================================ Return the requested value
3301  return ( &this->zFrom );
3302 }
3303 
3309 {
3310  //================================================ Return the requested value
3311  return ( &this->xTo );
3312 }
3313 
3319 {
3320  //================================================ Return the requested value
3321  return ( &this->yTo );
3322 }
3323 
3329 {
3330  //================================================ Return the requested value
3331  return ( &this->zTo );
3332 }
3333 
3339 {
3340  //================================================ Return the requested value
3341  return ( &this->xAxisOrigin );
3342 }
3343 
3349 {
3350  //================================================ Return the requested value
3351  return ( &this->yAxisOrigin );
3352 }
3353 
3359 {
3360  //================================================ Return the requested value
3361  return ( &this->zAxisOrigin );
3362 }
3363 
3369 {
3370  //================================================ Return the requested value
3371  return ( this->internalMap );
3372 }
3373 
3379 {
3380  //================================================ Return the requested value
3381  return ( this->translationMap );
3382 }
3383 
3389 {
3390  //================================================ Mutate
3391  this->integrationWeight = intW;
3392 
3393  //================================================ Done
3394  return ;
3395 
3396 }
3397 
3403 {
3404  //================================================ Mutate
3405  this->integrationWeight += intW;
3406 
3407  //================================================ Done
3408  return ;
3409 
3410 }
3411 
3419 void ProSHADE_internal_data::ProSHADE_data::setEMatrixValue ( proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_complex val )
3420 {
3421  //================================================ Mutate
3422  this->eMatrices[band][order1][order2][0] = val[0];
3423  this->eMatrices[band][order1][order2][1] = val[1];
3424 
3425  //================================================ Done
3426  return ;
3427 
3428 }
3429 
3437 void ProSHADE_internal_data::ProSHADE_data::normaliseEMatrixValue ( proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double normF )
3438 {
3439  //================================================ Mutate
3440  this->eMatrices[band][order1][order2][0] /= normF;
3441  this->eMatrices[band][order1][order2][1] /= normF;
3442 
3443  //================================================ Done
3444  return ;
3445 
3446 }
3447 
3453 void ProSHADE_internal_data::ProSHADE_data::setSO3CoeffValue ( proshade_unsign position, proshade_complex val )
3454 {
3455  //================================================ Mutate
3456  this->so3Coeffs[position][0] = val[0];
3457  this->so3Coeffs[position][1] = val[1];
3458 
3459  //================================================ Done
3460  return ;
3461 
3462 }
3463 
3471 void ProSHADE_internal_data::ProSHADE_data::setWignerMatrixValue ( proshade_complex val, proshade_unsign band, proshade_unsign order1, proshade_unsign order2 )
3472 {
3473  //================================================ Mutate
3474  this->wignerMatrices[band][order1][order2][0] = val[0];
3475  this->wignerMatrices[band][order1][order2][1] = val[1];
3476 
3477  //================================================ Done
3478  return ;
3479 
3480 }
3481 
3489 void ProSHADE_internal_data::ProSHADE_data::getRealEMatrixValuesForLM ( proshade_signed band, proshade_signed order1, double *eMatsLMReal, int len )
3490 {
3491  //================================================ Save the data into the output array
3492  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3493  {
3494  eMatsLMReal[iter] = static_cast<double> ( this->eMatrices[band][order1][iter][0] );
3495  }
3496 
3497  //================================================ Done
3498  return ;
3499 
3500 }
3501 
3509 void ProSHADE_internal_data::ProSHADE_data::getImagEMatrixValuesForLM ( proshade_signed band, proshade_signed order1, double *eMatsLMImag, int len )
3510 {
3511  //================================================ Save the data into the output array
3512  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3513  {
3514  eMatsLMImag[iter] = static_cast<double> ( this->eMatrices[band][order1][iter][1] );
3515  }
3516 
3517  //================================================ Done
3518  return ;
3519 
3520 }
3521 
3527 void ProSHADE_internal_data::ProSHADE_data::getRealSO3Coeffs ( double *so3CoefsReal, int len )
3528 {
3529  //================================================ Save the data into the output array
3530  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3531  {
3532  so3CoefsReal[iter] = static_cast<double> ( this->so3Coeffs[iter][0] );
3533  }
3534 
3535  //================================================ Done
3536  return ;
3537 
3538 }
3539 
3545 void ProSHADE_internal_data::ProSHADE_data::getImagSO3Coeffs ( double *so3CoefsImag, int len )
3546 {
3547  //================================================ Save the data into the output array
3548  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3549  {
3550  so3CoefsImag[iter] = static_cast<double> ( this->so3Coeffs[iter][1] );
3551  }
3552 
3553  //================================================ Done
3554  return ;
3555 
3556 }
3557 
3567 int ProSHADE_internal_data::ProSHADE_data::so3CoeffsArrayIndex ( proshade_signed order1, proshade_signed order2, proshade_signed band )
3568 {
3569  //================================================ Return the value
3570  return ( static_cast<int> ( so3CoefLoc ( order1, order2, band, this->getMaxBand() ) ) );
3571 }
3572 
3579 {
3580  //================================================ Save the data into the output array
3581  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3582  {
3583  rotFunReal[iter] = static_cast<double> ( this->so3CoeffsInverse[iter][0] );
3584  }
3585 
3586  //================================================ Done
3587  return ;
3588 
3589 }
3590 
3597 {
3598  //================================================ Save the data into the output array
3599  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3600  {
3601  rotFunImag[iter] = static_cast<double> ( this->so3CoeffsInverse[iter][1] );
3602  }
3603 
3604  //================================================ Done
3605  return ;
3606 
3607 }
3608 
3615 {
3616  //================================================ Save the data into the output array
3617  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3618  {
3619  trsFunReal[iter] = static_cast<double> ( this->translationMap[iter][0] );
3620  }
3621 
3622  //================================================ Done
3623  return ;
3624 
3625 }
3626 
3633 {
3634  //================================================ Save the data into the output array
3635  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3636  {
3637  trsFunImag[iter] = static_cast<double> ( this->translationMap[iter][1] );
3638  }
3639 
3640  //================================================ Done
3641  return ;
3642 
3643 }
3644 
3653 void ProSHADE_internal_data::ProSHADE_data::getRotMatrixFromRotFunInds ( proshade_signed aI, proshade_signed bI, proshade_signed gI, double *rotMat, int len )
3654 {
3655  //================================================ Get Euler angles
3656  proshade_double eA, eB, eG;
3657  ProSHADE_internal_maths::getEulerZXZFromSOFTPosition ( this->getMaxBand(), aI, bI, gI, &eA, &eB, &eG );
3658 
3659  //================================================ Prepare internal rotation matrix memory
3660  proshade_double* rMat = NULL;
3661  rMat = new proshade_double[9];
3662  ProSHADE_internal_misc::checkMemoryAllocation ( rMat, __FILE__, __LINE__, __func__ );
3663 
3664  //================================================ Convert to rotation matrix
3666 
3667  //================================================ Copy to output
3668  for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( len ); iter++ )
3669  {
3670  rotMat[iter] = static_cast<double> ( rMat[iter] );
3671  }
3672 
3673  //================================================ Release internal memory
3674  delete[] rMat;
3675 
3676  //================================================ Done
3677  return ;
3678 
3679 }
3680 
3686 {
3687  //================================================ Return the value
3688  return ( settings->recommendedSymmetryType );
3689 
3690 }
3691 
3697 {
3698  //================================================ Return the value
3699  return ( settings->recommendedSymmetryFold );
3700 
3701 }
3702 
3709 {
3710  //================================================ Return the value
3711  return ( static_cast<proshade_unsign> ( settings->detectedSymmetry.size() ) );
3712 }
3713 
3720 std::vector< std::string > ProSHADE_internal_data::ProSHADE_data::getSymmetryAxis ( ProSHADE_settings* settings, proshade_unsign axisNo )
3721 {
3722  //================================================ Sanity checks
3723  if ( static_cast<proshade_unsign> ( settings->detectedSymmetry.size() ) <= axisNo )
3724  {
3725  ProSHADE_internal_messages::printWarningMessage ( settings->verbose, "!!! ProSHADE WARNING !!! Requested symmetry index does not exist. Returning empty vector.", "WS00039" );
3726  return ( std::vector< std::string > ( ) );
3727  }
3728 
3729  //================================================ Initialise local variables
3730  std::vector< std::string > ret;
3731 
3732  //================================================ Input the axis data as strings
3733  std::stringstream ssHlp;
3734  ssHlp << settings->detectedSymmetry.at(axisNo)[0];
3735  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3736  ssHlp.str ( "" );
3737 
3738  ssHlp << settings->detectedSymmetry.at(axisNo)[1];
3739  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3740  ssHlp.str ( "" );
3741 
3742  ssHlp << settings->detectedSymmetry.at(axisNo)[2];
3743  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3744  ssHlp.str ( "" );
3745 
3746  ssHlp << settings->detectedSymmetry.at(axisNo)[3];
3747  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3748  ssHlp.str ( "" );
3749 
3750  ssHlp << settings->detectedSymmetry.at(axisNo)[4];
3751  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3752  ssHlp.str ( "" );
3753 
3754  ssHlp << settings->detectedSymmetry.at(axisNo)[5];
3755  ProSHADE_internal_misc::addToStringVector ( &ret, ssHlp.str() );
3756  ssHlp.str ( "" );
3757 
3758  //================================================ Done
3759  return ( ret );
3760 
3761 }
3762 
3775 void ProSHADE_internal_data::ProSHADE_data::writeOutOverlayFiles ( ProSHADE_settings* settings, proshade_double eulA, proshade_double eulB, proshade_double eulG, std::vector< proshade_double >* rotCentre, std::vector< proshade_double >* ultimateTranslation )
3776 {
3777  //================================================ Write out rotated map
3778  std::stringstream fNameHlp;
3779  fNameHlp << settings->overlayStructureName << ".map";
3780  this->writeMap ( fNameHlp.str() );
3781 
3782  //================================================ Write out rotated co-ordinates if possible
3783  if ( ProSHADE_internal_io::isFilePDB ( this->fileName ) )
3784  {
3785  fNameHlp.str("");
3786  fNameHlp << settings->overlayStructureName << ".pdb";
3787  this->writePdb ( fNameHlp.str(), eulA, eulB, eulG, ultimateTranslation->at(0), ultimateTranslation->at(1), ultimateTranslation->at(2), settings->firstModelOnly );
3788  }
3789 
3790  //================================================ Write out the json file with the results
3791  ProSHADE_internal_io::writeRotationTranslationJSON ( rotCentre->at(0), rotCentre->at(1), rotCentre->at(2),
3792  eulA, eulB, eulG,
3793  ultimateTranslation->at(0), ultimateTranslation->at(1), ultimateTranslation->at(2),
3794  settings->rotTrsJSONFile );
3795 
3796  //================================================ Done
3797  return ;
3798 
3799 }
3800 
3809 void ProSHADE_internal_data::ProSHADE_data::reportOverlayResults ( ProSHADE_settings* settings, std::vector < proshade_double >* rotationCentre, std::vector < proshade_double >* eulerAngles, std::vector < proshade_double >* finalTranslation )
3810 {
3811  //================================================ Empty line
3813 
3814  //================================================ Write out rotation centre translation results
3815  std::stringstream rotCen; rotCen << std::setprecision (3) << std::showpos << "The rotation centre to origin translation vector is: " << -rotationCentre->at(0) << " " << -rotationCentre->at(1) << " " << -rotationCentre->at(2);
3816  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, rotCen.str() );
3817 
3818  //================================================ Write out rotation matrix about origin
3819  proshade_double* rotMat = new proshade_double[9];
3820  ProSHADE_internal_misc::checkMemoryAllocation ( rotMat, __FILE__, __LINE__, __func__ );
3821  ProSHADE_internal_maths::getRotationMatrixFromEulerZXZAngles ( eulerAngles->at(0), eulerAngles->at(1), eulerAngles->at(2), rotMat );
3822 
3823  std::stringstream rotMatSS;
3824  rotMatSS << std::setprecision (3) << std::showpos << "The rotation matrix about origin is : " << rotMat[0] << " " << rotMat[1] << " " << rotMat[2] << std::endl;
3825  rotMatSS << std::setprecision (3) << std::showpos << " : " << rotMat[3] << " " << rotMat[4] << " " << rotMat[5] << std::endl;
3826  rotMatSS << std::setprecision (3) << std::showpos << " : " << rotMat[6] << " " << rotMat[7] << " " << rotMat[8];
3827  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, rotMatSS.str() );
3828 
3829  delete[] rotMat;
3830 
3831  //================================================ Write out origin to overlay translation results
3832  std::stringstream finTrs; finTrs << std::setprecision (3) << std::showpos << "The rotation centre to overlay translation vector is: " << finalTranslation->at(0) << " " << finalTranslation->at(1) << " " << finalTranslation->at(2);
3833  ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 0, finTrs.str() );
3834 
3835  //================================================ Done
3836  return ;
3837 
3838 }
ProSHADE_internal_data::ProSHADE_data::originalMapYCom
proshade_double originalMapYCom
The COM of the first map to be loaded/computed without any furhter changes being reflacted along the ...
Definition: ProSHADE_data.hpp:92
ProSHADE_settings::maxBandwidth
proshade_unsign maxBandwidth
The bandwidth of spherical harmonics decomposition for the largest sphere.
Definition: ProSHADE_settings.hpp:113
ProSHADE_internal_mapManip::addExtraBoundSpace
void addExtraBoundSpace(proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed *&bounds, proshade_single extraSpace)
This function takes a set of bounds and adds a given number of Angstroms to them.
Definition: ProSHADE_mapManip.cpp:1122
ProSHADE_internal_data::ProSHADE_data::computeSphericalHarmonics
void computeSphericalHarmonics(ProSHADE_settings *settings)
This function computes the spherical harmonics decomposition for the whole structure.
Definition: ProSHADE_data.cpp:1542
ProSHADE_internal_data::ProSHADE_data::mapMovFromsChangeX
proshade_double mapMovFromsChangeX
When the map is translated, the xFrom and xTo values are changed. This variable holds how much they h...
Definition: ProSHADE_data.hpp:94
ProSHADE_settings::recommendedSymmetryType
std::string recommendedSymmetryType
The symmetry type that ProSHADE finds the best fitting for the structure. Possible values are "" for ...
Definition: ProSHADE_settings.hpp:179
ProSHADE_internal_data::ProSHADE_data::getEMatrixByBand
proshade_complex ** getEMatrixByBand(proshade_unsign band)
This function allows access to E matrix for a particular band.
Definition: ProSHADE_data.cpp:3136
ProSHADE_internal_mapManip::determinePDBRanges
void determinePDBRanges(gemmi::Structure pdbFile, proshade_single *xFrom, proshade_single *xTo, proshade_single *yFrom, proshade_single *yTo, proshade_single *zFrom, proshade_single *zTo, bool firstModel)
Function for finding the PDB file ranges.
Definition: ProSHADE_mapManip.cpp:57
ProSHADE_internal_data::ProSHADE_data::fileName
std::string fileName
This is the original file from which the data were obtained.
Definition: ProSHADE_data.hpp:52
ProSHADE_internal_data::ProSHADE_data::zFrom
proshade_signed zFrom
This is the starting index along the z axis.
Definition: ProSHADE_data.hpp:112
ProSHADE_settings::rotTrsJSONFile
std::string rotTrsJSONFile
The filename to which the rotation and translation operations are to be saved into.
Definition: ProSHADE_settings.hpp:189
ProSHADE_internal_data::ProSHADE_data::xDimIndices
proshade_unsign xDimIndices
This is the size of the map cell x dimension in indices.
Definition: ProSHADE_data.hpp:65
ProSHADE_internal_data::ProSHADE_data::getZDimSize
proshade_single getZDimSize(void)
This function allows access to the map size in angstroms along the Z axis.
Definition: ProSHADE_data.cpp:3238
ProSHADE_internal_mapManip::changePDBBFactors
void changePDBBFactors(gemmi::Structure *pdbFile, proshade_double newBFactorValue, bool firstModel)
Function for changing the PDB B-factor values to a specific single value.
Definition: ProSHADE_mapManip.cpp:425
ProSHADE_internal_data::ProSHADE_data::zDimSizeOriginal
proshade_single zDimSizeOriginal
This is the size of the map cell z dimension in Angstroms.
Definition: ProSHADE_data.hpp:84
ProSHADE_internal_maths::vectorMeanAndSD
void vectorMeanAndSD(std::vector< proshade_double > *vec, proshade_double *&ret)
Function to get vector mean and standard deviation.
Definition: ProSHADE_maths.cpp:121
ProSHADE_internal_data::ProSHADE_data::createNewMapFromBounds
void createNewMapFromBounds(ProSHADE_settings *settings, ProSHADE_data *&newStr, proshade_signed *newBounds)
This function creates a new structure from the calling structure and new bounds values.
Definition: ProSHADE_data.cpp:1090
ProSHADE_settings::determineAllSHValues
void determineAllSHValues(proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim)
This function determines all the required values for spherical harmonics computation.
Definition: ProSHADE.cpp:1314
ProSHADE_internal_io::isFilePDB
bool isFilePDB(std::string fName)
Function determining if the input data type is PDB.
Definition: ProSHADE_io.cpp:32
ProSHADE_internal_data::ProSHADE_data::xGridIndices
proshade_unsign xGridIndices
As far as I know, this is identical to the xDimIndices.
Definition: ProSHADE_data.hpp:68
ProSHADE_internal_data::ProSHADE_data::translationMap
proshade_complex * translationMap
This is where the translation map will be held, if at all used.
Definition: ProSHADE_data.hpp:133
ProSHADE_internal_data::joinElementsFromDifferentGroups
std::vector< std::vector< proshade_double > > joinElementsFromDifferentGroups(std::vector< std::vector< proshade_double > > *first, std::vector< std::vector< proshade_double > > *second, proshade_double matrixTolerance, bool combine)
This function joins two group element lists using only unique elements.
Definition: ProSHADE_data.cpp:2421
ProSHADE_internal_data::ProSHADE_data::xAxisOrder
proshade_unsign xAxisOrder
This is the order of the x axis.
Definition: ProSHADE_data.hpp:71
ProSHADE_internal_data::ProSHADE_data::rotSphericalHarmonics
proshade_complex ** rotSphericalHarmonics
A set of rotated spherical harmonics values arrays for each sphere, used only if map rotation is requ...
Definition: ProSHADE_data.hpp:122
ProSHADE_internal_data::ProSHADE_data::getReBoxBoundaries
void getReBoxBoundaries(ProSHADE_settings *settings, proshade_signed *&ret)
This function finds the boundaries enclosing positive map values and adds some extra space.
Definition: ProSHADE_data.cpp:1035
ProSHADE_internal_data::ProSHADE_data::findIScore
proshade_double findIScore(std::vector< proshade_double * > *ISym)
This function takes the list of icosahedral axes and returns a score for deciding whether I symmetry ...
Definition: ProSHADE_data.cpp:2031
ProSHADE_internal_data::ProSHADE_data::getComparisonBand
proshade_unsign getComparisonBand(void)
This function allows access to the maximum band for the comparison.
Definition: ProSHADE_data.cpp:3188
ProSHADE_internal_data::ProSHADE_data::getRecommendedSymmetryFold
proshade_unsign getRecommendedSymmetryFold(ProSHADE_settings *settings)
This function simply returns the detected recommended symmetry fold.
Definition: ProSHADE_data.cpp:3696
ProSHADE_internal_data::ProSHADE_data::sphericalHarmonics
proshade_complex ** sphericalHarmonics
A set of spherical harmonics values arrays for each sphere.
Definition: ProSHADE_data.hpp:121
ProSHADE_internal_data::ProSHADE_data::setIntegrationWeight
void setIntegrationWeight(proshade_double intW)
This function allows setting the integration weight for the object.
Definition: ProSHADE_data.cpp:3388
ProSHADE_internal_data::ProSHADE_data::cAngle
proshade_single cAngle
This is the angle c of the map cell in degrees.
Definition: ProSHADE_data.hpp:64
ProSHADE_internal_data::ProSHADE_data::so3CoeffsInverse
proshade_complex * so3CoeffsInverse
The inverse coefficients obtained by inverse SO(3) Fourier Transform (SOFT) - i.e....
Definition: ProSHADE_data.hpp:130
ProSHADE_internal_data::ProSHADE_data::saveRequestedSymmetryD
void saveRequestedSymmetryD(ProSHADE_settings *settings, std::vector< proshade_double * > *DSym, std::vector< proshade_double * > *axes)
This function takes the D symmetries and searched for the requested symmetry.
Definition: ProSHADE_data.cpp:2215
ProSHADE_internal_data::ProSHADE_data::getXAxisOrigin
proshade_signed * getXAxisOrigin(void)
This function allows access to the map X axis origin value.
Definition: ProSHADE_data.cpp:3338
ProSHADE_internal_data::ProSHADE_data::normaliseEMatrixValue
void normaliseEMatrixValue(proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double normF)
This function allows normalising the E matrix value.
Definition: ProSHADE_data.cpp:3437
ProSHADE_internal_data::ProSHADE_data::yCom
proshade_double yCom
The COM of the map after processing along the Y-axis.
Definition: ProSHADE_data.hpp:78
ProSHADE_settings::boundsExtraSpace
proshade_single boundsExtraSpace
The number of extra angstroms to be added to all re-boxing bounds just for safety.
Definition: ProSHADE_settings.hpp:144
ProSHADE_exception
This class is the representation of ProSHADE exception.
Definition: ProSHADE_exceptions.hpp:37
ProSHADE_internal_data::ProSHADE_data::getImagTranslationFunction
void getImagTranslationFunction(double *trsFunImag, int len)
This function fills the input array with the imaginary translation function values.
Definition: ProSHADE_data.cpp:3632
ProSHADE_internal_data::ProSHADE_data::setWignerMatrixValue
void setWignerMatrixValue(proshade_complex val, proshade_unsign band, proshade_unsign order1, proshade_unsign order2)
This function allows setting the Wigner D matrix value by its band, order1 and order2 co-ordinate.
Definition: ProSHADE_data.cpp:3471
ProSHADE_settings::allDetectedDAxes
std::vector< std::vector< proshade_unsign > > allDetectedDAxes
The vector of all detected dihedral symmetry axes indices in allDetectedCAxes.
Definition: ProSHADE_settings.hpp:198
ProSHADE_settings::blurFactor
proshade_single blurFactor
This is the amount by which B-factors should be increased to create the blurred map for masking.
Definition: ProSHADE_settings.hpp:133
ProSHADE_internal_data::ProSHADE_data::saveDetectedSymmetries
void saveDetectedSymmetries(ProSHADE_settings *settings, std::vector< proshade_double * > *CSyms, std::vector< std::vector< proshade_double > > *allCs)
This function takes the results of point group searches and saves then into the output variables.
Definition: ProSHADE_data.cpp:1831
ProSHADE_settings::maskMap
bool maskMap
Should the map be masked from noise?
Definition: ProSHADE_settings.hpp:135
ProSHADE_settings::requestedSymmetryFold
proshade_unsign requestedSymmetryFold
The fold of the requested symmetry (only applicable to C and D symmetry types).
Definition: ProSHADE_settings.hpp:182
ProSHADE_settings::requestedSymmetryType
std::string requestedSymmetryType
The symmetry type requested by the user. Allowed values are C, D, T, O and I.
Definition: ProSHADE_settings.hpp:181
ProSHADE_internal_data::ProSHADE_data::getEMatrixValue
void getEMatrixValue(proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double *valueReal, proshade_double *valueImag)
This function allows access to E matrix by knowing the band, order1 and order2 indices.
Definition: ProSHADE_data.cpp:3151
ProSHADE_internal_data::ProSHADE_data::getXDimSize
proshade_single getXDimSize(void)
This function allows access to the map size in angstroms along the X axis.
Definition: ProSHADE_data.cpp:3218
ProSHADE_internal_data::ProSHADE_data::getInternalMap
proshade_double *& getInternalMap(void)
This function allows access to the first map array value address.
Definition: ProSHADE_data.cpp:3368
ProSHADE_internal_data::ProSHADE_data
This class contains all inputed and derived data for a single structure.
Definition: ProSHADE_data.hpp:49
ProSHADE_internal_data::ProSHADE_data::noSpheres
proshade_unsign noSpheres
The number of spheres with map projected onto them.
Definition: ProSHADE_data.hpp:119
ProSHADE_internal_data::ProSHADE_data::getYDimSize
proshade_single getYDimSize(void)
This function allows access to the map size in angstroms along the Y axis.
Definition: ProSHADE_data.cpp:3228
ProSHADE_internal_mapManip::getMaskFromBlurr
void getMaskFromBlurr(proshade_double *&blurMap, proshade_double *&outMap, proshade_unsign xDimS, proshade_unsign yDimS, proshade_unsign zDimS, proshade_single noIQRs)
Function for computing mask from blurred map.
Definition: ProSHADE_mapManip.cpp:1012
ProSHADE_internal_data::ProSHADE_data::zDimSize
proshade_single zDimSize
This is the size of the map cell z dimension in Angstroms.
Definition: ProSHADE_data.hpp:61
ProSHADE_internal_data::ProSHADE_data::so3Coeffs
proshade_complex * so3Coeffs
The coefficients obtained by SO(3) Fourier Transform (SOFT), in this case derived from the E matrices...
Definition: ProSHADE_data.hpp:129
ProSHADE_internal_data::ProSHADE_data::getMaxSpheres
proshade_unsign getMaxSpheres(void)
This function returns the number of spheres which contain the whole object.
Definition: ProSHADE_data.cpp:2918
ProSHADE_internal_data::ProSHADE_data::setSO3CoeffValue
void setSO3CoeffValue(proshade_unsign position, proshade_complex val)
This function allows setting the SOFT coefficient values using array position and value.
Definition: ProSHADE_data.cpp:3453
ProSHADE_settings::saveMask
bool saveMask
Should the mask be saved?
Definition: ProSHADE_settings.hpp:139
ProSHADE_settings::requestedResolution
proshade_single requestedResolution
The resolution to which the calculations are to be done.
Definition: ProSHADE_settings.hpp:105
ProSHADE_internal_data::ProSHADE_data::mapCOMProcessChangeX
proshade_double mapCOMProcessChangeX
The change in X axis between the creation of the structure (originalMapXCom) and just before rotation...
Definition: ProSHADE_data.hpp:97
ProSHADE_internal_mapManip::findMAPCOMValues
void findMAPCOMValues(proshade_double *map, proshade_double *xCom, proshade_double *yCom, proshade_double *zCom, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xFrom, proshade_signed xTo, proshade_signed yFrom, proshade_signed yTo, proshade_signed zFrom, proshade_signed zTo)
This function finds the Centre of Mass for a map.
Definition: ProSHADE_mapManip.cpp:225
ProSHADE_internal_mapManip::blurSharpenMap
void blurSharpenMap(proshade_double *&map, proshade_double *&maskedMap, proshade_unsign xDimS, proshade_unsign yDimS, proshade_unsign zDimS, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_single blurringFactor)
Function for blurring/sharpening maps.
Definition: ProSHADE_mapManip.cpp:912
ProSHADE_internal_data::ProSHADE_data::originalMapXCom
proshade_double originalMapXCom
The COM of the first map to be loaded/computed without any furhter changes being reflacted along the ...
Definition: ProSHADE_data.hpp:91
ProSHADE_internal_data::ProSHADE_data::getRotMatrixFromRotFunInds
void getRotMatrixFromRotFunInds(proshade_signed aI, proshade_signed bI, proshade_signed gI, double *rotMat, int len)
This function takes rotation function indices, converts them to Euler angles and these to rotation ma...
Definition: ProSHADE_data.cpp:3653
ProSHADE_settings::setDetectedSymmetry
void setDetectedSymmetry(proshade_double *sym)
Sets the final detected symmetry axes information.
Definition: ProSHADE.cpp:1077
ProSHADE_internal_data::ProSHADE_data::xDimIndicesOriginal
proshade_unsign xDimIndicesOriginal
This is the size of the map cell x dimension in indices.
Definition: ProSHADE_data.hpp:85
ProSHADE_internal_mapManip::moveMapByFourier
void moveMapByFourier(proshade_double *&map, proshade_single xMov, proshade_single yMov, proshade_single zMov, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xDim, proshade_signed yDim, proshade_signed zDim)
Function for moving map back to original PDB location by using Fourier transformation.
Definition: ProSHADE_mapManip.cpp:792
ProSHADE_internal_data::ProSHADE_data::getAnySphereRadius
proshade_double getAnySphereRadius(proshade_unsign shell)
This function allows access to the radius of any particular sphere.
Definition: ProSHADE_data.cpp:3089
ProSHADE_settings::progressiveSphereMapping
bool progressiveSphereMapping
If true, each shell will have its own angular resolution dependent on the actual number of map points...
Definition: ProSHADE_settings.hpp:156
ProSHADE_internal_mapManip::movePDBForMapCalc
void movePDBForMapCalc(gemmi::Structure *pdbFile, proshade_single xMov, proshade_single yMov, proshade_single zMov, bool firstModel)
Function for moving co-ordinate atoms to better suit theoretical map computation.
Definition: ProSHADE_mapManip.cpp:554
ProSHADE_internal_data::ProSHADE_data::getSO3Coeffs
proshade_complex * getSO3Coeffs(void)
This function allows access to the SO(3) coefficients array.
Definition: ProSHADE_data.cpp:3177
ProSHADE_settings::maxSphereDists
proshade_single maxSphereDists
The distance between spheres in spherical mapping for the largest sphere.
Definition: ProSHADE_settings.hpp:120
ProSHADE_internal_data::ProSHADE_data::maxShellBand
proshade_unsign maxShellBand
The maximum band for any shell of the object.
Definition: ProSHADE_data.hpp:123
ProSHADE_internal_data::ProSHADE_data::originalPdbRotCenY
proshade_double originalPdbRotCenY
The centre of rotation as it relates to the original PDB positions (and not the ProSHADE internal map...
Definition: ProSHADE_data.hpp:103
ProSHADE_internal_data::ProSHADE_data::getSpherePositions
void getSpherePositions(ProSHADE_settings *settings)
This function determines the sphere positions (radii) for sphere mapping.
Definition: ProSHADE_data.cpp:1442
ProSHADE_internal_data::ProSHADE_data::invertMirrorMap
void invertMirrorMap(ProSHADE_settings *settings)
Function for inverting the map to its mirror image.
Definition: ProSHADE_data.cpp:894
ProSHADE_internal_maths::getRotationMatrixFromEulerZXZAngles
void getRotationMatrixFromEulerZXZAngles(proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double *matrix)
Function to find the rotation matrix from Euler angles (ZXZ convention).
Definition: ProSHADE_maths.cpp:1005
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.
Definition: ProSHADE_data.cpp:2380
ProSHADE_internal_data::ProSHADE_data::getSpherePosValue
proshade_double getSpherePosValue(proshade_unsign shell)
This function allows access to sphere positions.
Definition: ProSHADE_data.cpp:3124
ProSHADE_internal_data::ProSHADE_data::findBestCScore
proshade_double findBestCScore(std::vector< proshade_double * > *CSym, proshade_unsign *symInd)
This function locates the best scoring C symmetry axis, returning the score and best symmetry index.
Definition: ProSHADE_data.cpp:1873
ProSHADE_internal_data::ProSHADE_data::mapCOMProcessChangeZ
proshade_double mapCOMProcessChangeZ
The change in Z axis between the creation of the structure (originalMapZCom) and just before rotation...
Definition: ProSHADE_data.hpp:99
ProSHADE_settings::maskingThresholdIQRs
proshade_single maskingThresholdIQRs
Number of inter-quartile ranges from the median to be used for thresholding the blurred map for maski...
Definition: ProSHADE_settings.hpp:134
ProSHADE_settings::usePhase
bool usePhase
If true, the full data will be used, if false, Patterson maps will be used instead and phased data wi...
Definition: ProSHADE_settings.hpp:117
ProSHADE_internal_data::ProSHADE_data::deepCopyMap
void deepCopyMap(proshade_double *&saveTo, proshade_unsign verbose)
This function copies the internal map into the supplied pointer, which it also allocates.
Definition: ProSHADE_data.cpp:2749
ProSHADE_internal_data::ProSHADE_data::xDimSizeOriginal
proshade_single xDimSizeOriginal
This is the size of the map cell x dimension in Angstroms.
Definition: ProSHADE_data.hpp:82
ProSHADE_internal_messages::printWarningMessage
void printWarningMessage(proshade_signed verbose, std::string message, std::string warnCode)
General stderr message printing (used for warnings).
Definition: ProSHADE_messages.cpp:101
ProSHADE_internal_data::ProSHADE_data::getIntegrationWeight
proshade_double getIntegrationWeight(void)
This function allows access to the integration weight for the object.
Definition: ProSHADE_data.cpp:3100
ProSHADE_internal_io::figureDataType
InputType figureDataType(std::string fName)
Function determining input data type.
Definition: ProSHADE_io.cpp:292
ProSHADE_internal_data::ProSHADE_data::setIntegrationWeightCumul
void setIntegrationWeightCumul(proshade_double intW)
This function allows setting the cumulative integration weight for the object.
Definition: ProSHADE_data.cpp:3402
ProSHADE_internal_mapManip::reSampleMapToResolutionTrilinear
void reSampleMapToResolutionTrilinear(proshade_double *&map, proshade_single resolution, proshade_unsign xDimS, proshade_unsign yDimS, proshade_unsign zDimS, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_single *&corrs)
This function re-samples a map to conform to given resolution using tri-linear interpolation.
Definition: ProSHADE_mapManip.cpp:1158
ProSHADE_internal_data::ProSHADE_data::zAxisOriginOriginal
proshade_signed zAxisOriginOriginal
This is the origin position along the z axis.
Definition: ProSHADE_data.hpp:90
ProSHADE_internal_spheres::ProSHADE_sphere
This class contains all inputed and derived data for a single sphere.
Definition: ProSHADE_spheres.hpp:49
ProSHADE_internal_data::ProSHADE_data::getSymmetryAxis
std::vector< std::string > getSymmetryAxis(ProSHADE_settings *settings, proshade_unsign axisNo)
This function returns a single symmetry axis as a vector of strings from the recommended symmetry axe...
Definition: ProSHADE_data.cpp:3720
ProSHADE_settings::maskFileName
std::string maskFileName
The filename to which mask should be saved.
Definition: ProSHADE_settings.hpp:140
ProSHADE_internal_data::ProSHADE_data::eMatrices
proshade_complex *** eMatrices
The trace sigma and full rotation function c*conj(c) integral tables.
Definition: ProSHADE_data.hpp:127
ProSHADE_internal_data::ProSHADE_data::centreMapOnCOM
void centreMapOnCOM(ProSHADE_settings *settings)
This function shits the map so that its COM is in the centre of the map.
Definition: ProSHADE_data.cpp:1228
ProSHADE_internal_data::ProSHADE_data::getXFromPtr
proshade_signed * getXFromPtr(void)
This function allows access to the map start along the X axis.
Definition: ProSHADE_data.cpp:3278
ProSHADE_settings::verbose
proshade_signed verbose
Should the software report on the progress, or just be quiet? Value between -1 (nothing) and 4 (loud)
Definition: ProSHADE_settings.hpp:192
ProSHADE_internal_mapManip::beautifyBoundaries
void beautifyBoundaries(proshade_signed *&bounds, proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim, proshade_signed boundsDiffThres, proshade_signed verbose)
Function for modifying boundaries to a mathematically more pleasant values.
Definition: ProSHADE_mapManip.cpp:1897
ProSHADE_internal_data::ProSHADE_data::yDimIndices
proshade_unsign yDimIndices
This is the size of the map cell y dimension in indices.
Definition: ProSHADE_data.hpp:66
ProSHADE_internal_data::ProSHADE_data::xAxisOriginOriginal
proshade_signed xAxisOriginOriginal
This is the origin position along the x axis.
Definition: ProSHADE_data.hpp:88
ProSHADE_internal_data::ProSHADE_data::saveRecommendedSymmetry
void saveRecommendedSymmetry(ProSHADE_settings *settings, std::vector< proshade_double * > *CSym, std::vector< proshade_double * > *DSym, std::vector< proshade_double * > *TSym, std::vector< proshade_double * > *OSym, std::vector< proshade_double * > *ISym, std::vector< proshade_double * > *axes)
This function takes all the detected symmetry results and decides on which are to be recommended for ...
Definition: ProSHADE_data.cpp:2070
ProSHADE_internal_data::ProSHADE_data::getWignerMatrixValue
void getWignerMatrixValue(proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_double *valueReal, proshade_double *valueImag)
This function allows access to the Wigner D matrix by knowing the band, order1 and order2 indices.
Definition: ProSHADE_data.cpp:3203
ProSHADE_internal_data::ProSHADE_data::getShellBandwidth
proshade_unsign getShellBandwidth(proshade_unsign shell)
This function allows access to the bandwidth of a particular shell.
Definition: ProSHADE_data.cpp:3112
ProSHADE_internal_data::ProSHADE_data::yGridIndices
proshade_unsign yGridIndices
As far as I know, this is identical to the yDimIndices.
Definition: ProSHADE_data.hpp:69
ProSHADE_settings::changeMapResolutionTriLinear
bool changeMapResolutionTriLinear
Should maps be re-sampled to obtain the required resolution?
Definition: ProSHADE_settings.hpp:107
ProSHADE_internal_data::ProSHADE_data::zAxisOrigin
proshade_signed zAxisOrigin
This is the origin position along the z axis.
Definition: ProSHADE_data.hpp:76
ProSHADE_internal_misc::addToDoubleVector
void addToDoubleVector(std::vector< proshade_double > *vecToAddTo, proshade_double elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:77
ProSHADE_internal_data::ProSHADE_data::getNoRecommendedSymmetryAxes
proshade_unsign getNoRecommendedSymmetryAxes(ProSHADE_settings *settings)
This function returns the number of detected recommended symmetry axes.
Definition: ProSHADE_data.cpp:3708
ProSHADE_internal_data::ProSHADE_data::setPDBMapValues
void setPDBMapValues(void)
Function for determining iterator start and stop positions.
Definition: ProSHADE_data.cpp:678
ProSHADE_internal_data::ProSHADE_data::findMapCOM
void findMapCOM(void)
This function finds the centre of mass of the internal map representation.
Definition: ProSHADE_data.cpp:2863
ProSHADE_internal_data::ProSHADE_data::getRealRotFunction
void getRealRotFunction(double *rotFunReal, int len)
This function fills the input array with the real rotation function values.
Definition: ProSHADE_data.cpp:3578
ProSHADE_internal_data::ProSHADE_data::yDimIndicesOriginal
proshade_unsign yDimIndicesOriginal
This is the size of the map cell y dimension in indices.
Definition: ProSHADE_data.hpp:86
ProSHADE_internal_data::ProSHADE_data::getXDim
proshade_unsign getXDim(void)
This function allows access to the map size in indices along the X axis.
Definition: ProSHADE_data.cpp:3248
ProSHADE_internal_mapManip::removeWaters
void removeWaters(gemmi::Structure *pdbFile, bool firstModel)
This function removed all waters from PDB input file.
Definition: ProSHADE_mapManip.cpp:485
ProSHADE_internal_data::ProSHADE_data::originalPdbTransX
proshade_double originalPdbTransX
The optimal translation vector as it relates to the original PDB positions (and not the ProSHADE inte...
Definition: ProSHADE_data.hpp:105
ProSHADE_data.hpp
This is the header file containing internal data representation and manipulation structures and funct...
ProSHADE_internal_data::ProSHADE_data::zTo
proshade_signed zTo
This is the final index along the z axis.
Definition: ProSHADE_data.hpp:115
ProSHADE_internal_data::ProSHADE_data::xTo
proshade_signed xTo
This is the final index along the x axis.
Definition: ProSHADE_data.hpp:113
ProSHADE_internal_data::ProSHADE_data::writeMask
void writeMask(std::string fName, proshade_double *mask)
Function for writing out a mask in MRC MAP format.
Definition: ProSHADE_data.cpp:857
ProSHADE_internal_data::ProSHADE_data::ProSHADE_data
ProSHADE_data(ProSHADE_settings *settings)
Constructor for getting empty ProSHADE_data class.
Definition: ProSHADE_data.cpp:39
ProSHADE_internal_data::ProSHADE_data::integrationWeight
proshade_double integrationWeight
The Pearson's c.c. type weighting for the integration.
Definition: ProSHADE_data.hpp:128
ProSHADE_internal_data::ProSHADE_data::saveRequestedSymmetryC
void saveRequestedSymmetryC(ProSHADE_settings *settings, std::vector< proshade_double * > *CSym, std::vector< proshade_double * > *axes)
This function takes the C symmetries and searched for the requested symmetry.
Definition: ProSHADE_data.cpp:2164
ProSHADE_internal_data::ProSHADE_data::mapToSpheres
void mapToSpheres(ProSHADE_settings *settings)
This function converts the internal map onto a set of concentric spheres.
Definition: ProSHADE_data.cpp:1499
ProSHADE_internal_data::ProSHADE_data::xAxisOrigin
proshade_signed xAxisOrigin
This is the origin position along the x axis.
Definition: ProSHADE_data.hpp:74
ProSHADE_internal_data::ProSHADE_data::originalPdbTransY
proshade_double originalPdbTransY
The optimal translation vector as it relates to the original PDB positions (and not the ProSHADE inte...
Definition: ProSHADE_data.hpp:106
ProSHADE_internal_data::ProSHADE_data::rrpMatrices
proshade_double *** rrpMatrices
The energy levels descriptor shell correlation tables.
Definition: ProSHADE_data.hpp:126
ProSHADE_internal_data::ProSHADE_data::yTo
proshade_signed yTo
This is the final index along the y axis.
Definition: ProSHADE_data.hpp:114
ProSHADE_settings::forceP1
bool forceP1
Should the P1 spacegroup be forced on the input PDB files?
Definition: ProSHADE_settings.hpp:100
ProSHADE_internal_data::ProSHADE_data::xDimSize
proshade_single xDimSize
This is the size of the map cell x dimension in Angstroms.
Definition: ProSHADE_data.hpp:59
ProSHADE_internal_mapManip::findPDBCOMValues
void findPDBCOMValues(gemmi::Structure pdbFile, proshade_double *xCom, proshade_double *yCom, proshade_double *zCom, bool firstModel)
This function finds the Centre of Mass for the co-ordinate file.
Definition: ProSHADE_mapManip.cpp:142
ProSHADE_internal_data::ProSHADE_data::mapMovFromsChangeY
proshade_double mapMovFromsChangeY
When the map is translated, the yFrom and yTo values are changed. This variable holds how much they h...
Definition: ProSHADE_data.hpp:95
ProSHADE_internal_misc::sortDSymHlpInv
bool sortDSymHlpInv(const proshade_double *a, const proshade_double *b)
This function compares two arrays of the ProSHADE dihedral symmetry list based on combination of axes...
Definition: ProSHADE_misc.cpp:256
ProSHADE_internal_data::ProSHADE_data::yAxisOrigin
proshade_signed yAxisOrigin
This is the origin position along the y axis.
Definition: ProSHADE_data.hpp:75
ProSHADE_internal_misc::deepCopyAxisToDblPtrVector
void deepCopyAxisToDblPtrVector(std::vector< proshade_double * > *dblPtrVec, proshade_double *axis)
Does a deep copy of a double array to a vector of double arrays.
Definition: ProSHADE_misc.cpp:287
ProSHADE_internal_data::ProSHADE_data::yAxisOrder
proshade_unsign yAxisOrder
This is the order of the y axis.
Definition: ProSHADE_data.hpp:72
ProSHADE_internal_data::ProSHADE_data::getRealSphHarmValue
proshade_double * getRealSphHarmValue(proshade_unsign band, proshade_unsign order, proshade_unsign shell)
This function allows access to the private internal real spherical harmonics values.
Definition: ProSHADE_data.cpp:3063
ProSHADE_internal_data::ProSHADE_data::detectSymmetryInStructurePython
void detectSymmetryInStructurePython(ProSHADE_settings *settings)
This function runs the symmetry detection algorithms on this structure saving the axes in the setting...
Definition: ProSHADE_data.cpp:1684
ProSHADE_internal_data::ProSHADE_data::internalMap
proshade_double * internalMap
The internal map data representation, which may be amended as the run progresses.
Definition: ProSHADE_data.hpp:56
ProSHADE_internal_data::ProSHADE_data::zDimIndicesOriginal
proshade_unsign zDimIndicesOriginal
This is the size of the map cell z dimension in indices.
Definition: ProSHADE_data.hpp:87
ProSHADE_internal_data::ProSHADE_data::reportOverlayResults
void reportOverlayResults(ProSHADE_settings *settings, std::vector< proshade_double > *rotationCentre, std::vector< proshade_double > *eulerAngles, std::vector< proshade_double > *finalTranslation)
This function reports the results of the overlay mode.
Definition: ProSHADE_data.cpp:3809
ProSHADE_internal_data::ProSHADE_data::xFrom
proshade_signed xFrom
This is the starting index along the x axis.
Definition: ProSHADE_data.hpp:110
ProSHADE_internal_maths::getRotationMatrixFromAngleAxis
void getRotationMatrixFromAngleAxis(proshade_double *rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang)
This function converts the axis-angle representation to the rotation matrix representation.
Definition: ProSHADE_maths.cpp:1343
ProSHADE_internal_data::ProSHADE_data::writeMap
void writeMap(std::string fName, std::string title="Created by ProSHADE and written by GEMMI", int mode=2)
Function for writing out the internal structure representation in MRC MAP format.
Definition: ProSHADE_data.cpp:741
ProSHADE_internal_data::ProSHADE_data::shellBandExists
bool shellBandExists(proshade_unsign shell, proshade_unsign bandVal)
This function checks if particular shell has a particular band.
Definition: ProSHADE_data.cpp:2965
ProSHADE_internal_data::ProSHADE_data::getMaxBand
proshade_unsign getMaxBand(void)
This function returns the maximum band value for the object.
Definition: ProSHADE_data.cpp:2939
ProSHADE_settings::normaliseMap
bool normaliseMap
Should the map be normalised to mean 0 sd 1?
Definition: ProSHADE_settings.hpp:127
ProSHADE_settings::addExtraSpace
proshade_single addExtraSpace
If this value is non-zero, this many angstroms of empty space will be added to the internal map.
Definition: ProSHADE_settings.hpp:153
ProSHADE_internal_mapManip::getNonZeroBounds
void getNonZeroBounds(proshade_double *map, proshade_signed xDim, proshade_signed yDim, proshade_signed zDim, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed *&ret)
Function for finding the map boundaries enclosing positive only values.
Definition: ProSHADE_mapManip.cpp:1065
ProSHADE_internal_data::ProSHADE_data::getYDim
proshade_unsign getYDim(void)
This function allows access to the map size in indices along the Y axis.
Definition: ProSHADE_data.cpp:3258
ProSHADE_internal_data::ProSHADE_data::maxCompBand
proshade_unsign maxCompBand
The largest comparison band - this variable tells how large arrays will be allocated for the comparis...
Definition: ProSHADE_data.hpp:132
ProSHADE_internal_data::ProSHADE_data::getImagEMatrixValuesForLM
void getImagEMatrixValuesForLM(proshade_signed band, proshade_signed order1, double *eMatsLMImag, int len)
This function fills the input array with the imaginary E matrix values for particular band and order1...
Definition: ProSHADE_data.cpp:3509
ProSHADE_internal_data::ProSHADE_data::maskMap
void maskMap(ProSHADE_settings *settings)
Function for computing the map mask using blurring and X IQRs from median.
Definition: ProSHADE_data.cpp:995
ProSHADE_internal_data::ProSHADE_data::~ProSHADE_data
~ProSHADE_data(void)
Destructor for the ProSHADE_data class.
Definition: ProSHADE_data.cpp:295
ProSHADE_settings
This class stores all the settings and is passed to the executive classes instead of a multitude of p...
Definition: ProSHADE_settings.hpp:93
ProSHADE_internal_data::ProSHADE_data::xCom
proshade_double xCom
The COM of the map after processing along the X-axis.
Definition: ProSHADE_data.hpp:77
ProSHADE_internal_mapManip::copyMapByBounds
void copyMapByBounds(proshade_signed xFrom, proshade_signed xTo, proshade_signed yFrom, proshade_signed yTo, proshade_signed zFrom, proshade_signed zTo, proshade_signed origXFrom, proshade_signed origYFrom, proshade_signed origZFrom, proshade_signed yDimIndices, proshade_signed zDimIndices, proshade_signed origXDimIndices, proshade_signed origYDimIndices, proshade_signed origZDimIndices, proshade_double *&newMap, proshade_double *origMap)
This function copies an old map to a new map with different boundaries.
Definition: ProSHADE_mapManip.cpp:2063
ProSHADE_internal_data::ProSHADE_data::getRealTranslationFunction
void getRealTranslationFunction(double *trsFunReal, int len)
This function fills the input array with the real translation function values.
Definition: ProSHADE_data.cpp:3614
ProSHADE_internal_data::ProSHADE_data::getImagSphHarmValue
proshade_double * getImagSphHarmValue(proshade_unsign band, proshade_unsign order, proshade_unsign shell)
This function allows access to the private internal imaginary spherical harmonics values.
Definition: ProSHADE_data.cpp:3076
ProSHADE_internal_data::ProSHADE_data::originalPdbTransZ
proshade_double originalPdbTransZ
The optimal translation vector as it relates to the original PDB positions (and not the ProSHADE inte...
Definition: ProSHADE_data.hpp:107
ProSHADE_internal_data::ProSHADE_data::writeOutOverlayFiles
void writeOutOverlayFiles(ProSHADE_settings *settings, proshade_double eulA, proshade_double eulB, proshade_double eulG, std::vector< proshade_double > *rotCentre, std::vector< proshade_double > *ultimateTranslation)
This function writes out the rotated map, co-ordinates and transformation JSON file.
Definition: ProSHADE_data.cpp:3775
ProSHADE_internal_data::ProSHADE_data::findBestDScore
proshade_double findBestDScore(std::vector< proshade_double * > *DSym, proshade_unsign *symInd)
This function locates the best scoring D symmetry axis, returning the score and best symmetry index.
Definition: ProSHADE_data.cpp:1917
ProSHADE_internal_data::ProSHADE_data::getImagRotFunction
void getImagRotFunction(double *rotFunImag, int len)
This function fills the input array with the imaginary rotation function values.
Definition: ProSHADE_data.cpp:3596
ProSHADE_internal_data::ProSHADE_data::processInternalMap
void processInternalMap(ProSHADE_settings *settings)
This function simply clusters several other functions which should be called together.
Definition: ProSHADE_data.cpp:1398
ProSHADE_internal_io::readInMapData
void readInMapData(gemmi::Ccp4< float > *gemmiMap, proshade_double *&map, proshade_unsign xDimInds, proshade_unsign yDimInds, proshade_unsign zDimInds, proshade_unsign xAxOrder, proshade_unsign yAxOrder, proshade_unsign zAxOrder)
This function converts the gemmi Ccp4 object data to ProSHADE internal map representation.
Definition: ProSHADE_io.cpp:172
ProSHADE_internal_data::ProSHADE_data::getTranslationFnPointer
proshade_complex * getTranslationFnPointer(void)
This function allows access to the translation function through a pointer.
Definition: ProSHADE_data.cpp:3378
ProSHADE_settings::setRecommendedSymmetry
void setRecommendedSymmetry(std::string val)
Sets the ProSHADE detected symmetry type.
Definition: ProSHADE.cpp:1009
ProSHADE_internal_data::ProSHADE_data::zCom
proshade_double zCom
The COM of the map after processing along the Z-axis.
Definition: ProSHADE_data.hpp:79
ProSHADE_internal_data::ProSHADE_data::spherePos
std::vector< proshade_single > spherePos
Vector of sphere radii from the centre of the map.
Definition: ProSHADE_data.hpp:118
ProSHADE_settings::invertMap
bool invertMap
Should the map be inverted? Only use this if you think you have the wrong hand in your map.
Definition: ProSHADE_settings.hpp:130
ProSHADE_internal_data::ProSHADE_data::getZDim
proshade_unsign getZDim(void)
This function allows access to the map size in indices along the Z axis.
Definition: ProSHADE_data.cpp:3268
ProSHADE_internal_data::ProSHADE_data::findOScore
proshade_double findOScore(std::vector< proshade_double * > *OSym)
This function takes the list of octahedral axes and returns a score for deciding whether O symmetry s...
Definition: ProSHADE_data.cpp:1998
ProSHADE_internal_mapManip::removeMapPhase
void removeMapPhase(fftw_complex *&mapCoeffs, proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim)
This function removes the phase from reciprocal (frequency) map.
Definition: ProSHADE_mapManip.cpp:1611
ProSHADE_settings::boundsSimilarityThreshold
proshade_signed boundsSimilarityThreshold
Number of indices which can be added just to make sure same size in indices is achieved.
Definition: ProSHADE_settings.hpp:145
ProSHADE_internal_data::ProSHADE_data::writePdb
void writePdb(std::string fName, proshade_double euA=0.0, proshade_double euB=0.0, proshade_double euG=0.0, proshade_double trsX=0.0, proshade_double trsY=0.0, proshade_double trsZ=0.0, bool firstModel=true)
This function writes out the PDB formatted file coresponding to the structure so that its COM is at s...
Definition: ProSHADE_data.cpp:806
ProSHADE_settings::changeMapResolution
bool changeMapResolution
Should maps be re-sampled to obtain the required resolution?
Definition: ProSHADE_settings.hpp:106
ProSHADE_internal_data::ProSHADE_data::getRRPValue
proshade_double getRRPValue(proshade_unsign band, proshade_unsign sh1, proshade_unsign sh2)
This function allows access to the priva internal RRP matrices.
Definition: ProSHADE_data.cpp:2949
ProSHADE_internal_io::writeRotationTranslationJSON
void writeRotationTranslationJSON(proshade_double trsX1, proshade_double trsY1, proshade_double trsZ1, proshade_double eulA, proshade_double eulB, proshade_double eulG, proshade_double trsX2, proshade_double trsY2, proshade_double trsZ2, std::string fileName)
Function for writing out the optimal rotation and translation into a JSON file.
Definition: ProSHADE_io.cpp:334
ProSHADE_internal_data::ProSHADE_data::mapMovFromsChangeZ
proshade_double mapMovFromsChangeZ
When the map is translated, the zFrom and zTo values are changed. This variable holds how much they h...
Definition: ProSHADE_data.hpp:96
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 th...
Definition: ProSHADE_data.cpp:2332
ProSHADE_settings::overlayStructureName
std::string overlayStructureName
The filename to which the rotated and translated moving structure is to be saved.
Definition: ProSHADE_settings.hpp:188
ProSHADE_internal_data::ProSHADE_data::getMapValue
proshade_double getMapValue(proshade_unsign pos)
This function returns the internal map representation value of a particular array position.
Definition: ProSHADE_data.cpp:2929
ProSHADE_internal_data::ProSHADE_data::getImagSO3Coeffs
void getImagSO3Coeffs(double *so3CoefsImag, int len)
This function fills the input array with the imaginary SO(3) coefficient values.
Definition: ProSHADE_data.cpp:3545
ProSHADE_internal_data::ProSHADE_data::getYToPtr
proshade_signed * getYToPtr(void)
This function allows access to the map last position along the Y axis.
Definition: ProSHADE_data.cpp:3318
ProSHADE_settings::moveToCOM
bool moveToCOM
Logical value stating whether the structure should be moved to have its Centre Of Mass (COM) in the m...
Definition: ProSHADE_settings.hpp:150
ProSHADE_internal_data::ProSHADE_data::readInMAP
void readInMAP(ProSHADE_settings *settings)
Function for reading map data using gemmi library.
Definition: ProSHADE_data.cpp:501
ProSHADE_internal_data::ProSHADE_data::wignerMatrices
proshade_complex *** wignerMatrices
These matrices are computed for a particular rotation to be done in spherical harmonics.
Definition: ProSHADE_data.hpp:131
ProSHADE_internal_data::ProSHADE_data::detectSymmetryInStructure
void detectSymmetryInStructure(ProSHADE_settings *settings, std::vector< proshade_double * > *axes, std::vector< std::vector< proshade_double > > *allCs)
This function runs the symmetry detection algorithms on this structure and saves the results in the s...
Definition: ProSHADE_data.cpp:1587
ProSHADE_internal_data::ProSHADE_data::fileType
ProSHADE_internal_io::InputType fileType
This is the type of the input file.
Definition: ProSHADE_data.hpp:53
ProSHADE_internal_data::ProSHADE_data::getZAxisOrigin
proshade_signed * getZAxisOrigin(void)
This function allows access to the map Z axis origin value.
Definition: ProSHADE_data.cpp:3358
ProSHADE_internal_io::writeOutMapHeader
void writeOutMapHeader(gemmi::Ccp4< float > *map, proshade_unsign xDimInds, proshade_unsign yDimInds, proshade_unsign zDimInds, proshade_single xDim, proshade_single yDim, proshade_single zDim, proshade_single aAng, proshade_single bAng, proshade_single cAng, proshade_signed xFrom, proshade_signed yFrom, proshade_signed zFrom, proshade_signed xAxOrigin, proshade_signed yAxOrigin, proshade_signed zAxOrigin, proshade_unsign xAxOrder, proshade_unsign yAxOrder, proshade_unsign zAxOrder, proshade_unsign xGridInds, proshade_unsign yGridInds, proshade_unsign zGridInds, std::string title, int mode)
This function parses the CCP4 MAP file header as read in by gemmi.
Definition: ProSHADE_io.cpp:242
ProSHADE_internal_mapManip::myRound
proshade_signed myRound(proshade_double x)
Calls the appropriate version of round function depending on compiler version.
Definition: ProSHADE_mapManip.cpp:31
ProSHADE_internal_data::ProSHADE_data::yDimSizeOriginal
proshade_single yDimSizeOriginal
This is the size of the map cell y dimension in Angstroms.
Definition: ProSHADE_data.hpp:83
ProSHADE_internal_data::ProSHADE_data::zAxisOrder
proshade_unsign zAxisOrder
This is the order of the z axis.
Definition: ProSHADE_data.hpp:73
ProSHADE_internal_data::ProSHADE_data::reSampleMap
void reSampleMap(ProSHADE_settings *settings)
This function changes the internal map sampling to conform to particular resolution value.
Definition: ProSHADE_data.cpp:1156
ProSHADE_internal_mapManip::rotatePDBCoordinates
void rotatePDBCoordinates(gemmi::Structure *pdbFile, proshade_double euA, proshade_double euB, proshade_double euG, proshade_double xCom, proshade_double yCom, proshade_double zCom, bool firstModel)
Function for rotating the PDB file co-ordinates by Euler angles.
Definition: ProSHADE_mapManip.cpp:277
ProSHADE_internal_mapManip::generateMapFromPDB
void generateMapFromPDB(gemmi::Structure pdbFile, proshade_double *&map, proshade_single requestedResolution, proshade_single xCell, proshade_single yCell, proshade_single zCell, proshade_signed *xTo, proshade_signed *yTo, proshade_signed *zTo, bool forceP1, bool firstModel)
This function generates a theoretical map from co-ordinate input files.
Definition: ProSHADE_mapManip.cpp:625
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:2195
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:65
ProSHADE_internal_data::ProSHADE_data::getXToPtr
proshade_signed * getXToPtr(void)
This function allows access to the map last position along the X axis.
Definition: ProSHADE_data.cpp:3308
ProSHADE_internal_data::ProSHADE_data::getYFromPtr
proshade_signed * getYFromPtr(void)
This function allows access to the map start along the Y axis.
Definition: ProSHADE_data.cpp:3288
ProSHADE_internal_mapManip::translatePDBCoordinates
void translatePDBCoordinates(gemmi::Structure *pdbFile, proshade_double transX, proshade_double transY, proshade_double transZ, bool firstModel)
Function for translating the PDB file co-ordinates by given distances in Angstroms.
Definition: ProSHADE_mapManip.cpp:362
ProSHADE_internal_data::ProSHADE_data::mapCOMProcessChangeY
proshade_double mapCOMProcessChangeY
The change in Y axis between the creation of the structure (originalMapYCom) and just before rotation...
Definition: ProSHADE_data.hpp:98
ProSHADE_internal_data::ProSHADE_data::bAngle
proshade_single bAngle
This is the angle b of the map cell in degrees.
Definition: ProSHADE_data.hpp:63
ProSHADE_internal_maths::getEulerZXZFromSOFTPosition
void getEulerZXZFromSOFTPosition(proshade_signed band, proshade_signed x, proshade_signed y, proshade_signed z, proshade_double *eulerAlpha, proshade_double *eulerBeta, proshade_double *eulerGamma)
Function to find Euler angles (ZXZ convention) from index position in the inverse SOFT map.
Definition: ProSHADE_maths.cpp:961
ProSHADE_internal_data::ProSHADE_data::yAxisOriginOriginal
proshade_signed yAxisOriginOriginal
This is the origin position along the y axis.
Definition: ProSHADE_data.hpp:89
ProSHADE_internal_data::ProSHADE_data::aAngle
proshade_single aAngle
This is the angle a of the map cell in degrees.
Definition: ProSHADE_data.hpp:62
ProSHADE_internal_misc::addToDoubleVectorVector
void addToDoubleVectorVector(std::vector< std::vector< proshade_double > > *vecToAddTo, std::vector< proshade_double > elementToAdd)
Adds the element to the vector of vectors.
Definition: ProSHADE_misc.cpp:210
ProSHADE_internal_data::ProSHADE_data::reportSymmetryResults
void reportSymmetryResults(ProSHADE_settings *settings)
This function takes prints the report for symmetry detection.
Definition: ProSHADE_data.cpp:2781
ProSHADE_internal_data::ProSHADE_data::findTScore
proshade_double findTScore(std::vector< proshade_double * > *TSym)
This function takes the list of tetrahedral axes and returns a score for deciding whether T symmetry ...
Definition: ProSHADE_data.cpp:1965
ProSHADE_internal_data::ProSHADE_data::figureIndexStartStop
void figureIndexStartStop(void)
Function for determining iterator start and stop positions.
Definition: ProSHADE_data.cpp:719
ProSHADE_internal_data::ProSHADE_data::isEmpty
bool isEmpty
This variable stated whether the class contains any information.
Definition: ProSHADE_data.hpp:139
ProSHADE_internal_data::ProSHADE_data::getInvSO3Coeffs
proshade_complex * getInvSO3Coeffs(void)
This function allows access to the inverse SO(3) coefficients array.
Definition: ProSHADE_data.cpp:3166
ProSHADE_settings::forceBounds
proshade_signed * forceBounds
These will be the boundaries to be forced upon the map.
Definition: ProSHADE_settings.hpp:147
ProSHADE_settings::detectedSymmetry
std::vector< proshade_double * > detectedSymmetry
The vector of detected symmetry axes.
Definition: ProSHADE_settings.hpp:196
ProSHADE_internal_data::ProSHADE_data::yFrom
proshade_signed yFrom
This is the starting index along the y axis.
Definition: ProSHADE_data.hpp:111
ProSHADE_settings::recommendedSymmetryFold
proshade_unsign recommendedSymmetryFold
The fold of the recommended symmetry C or D type, 0 otherwise.
Definition: ProSHADE_settings.hpp:180
ProSHADE_internal_mapManip::reSampleMapToResolutionFourier
void reSampleMapToResolutionFourier(proshade_double *&map, proshade_single resolution, proshade_unsign xDimS, proshade_unsign yDimS, proshade_unsign zDimS, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_single *&corrs)
This function re-samples a map to conform to given resolution using Fourier.
Definition: ProSHADE_mapManip.cpp:1359
ProSHADE_internal_data::ProSHADE_data::getYAxisOrigin
proshade_signed * getYAxisOrigin(void)
This function allows access to the map Y axis origin value.
Definition: ProSHADE_data.cpp:3348
ProSHADE_internal_data::ProSHADE_data::originalPdbRotCenZ
proshade_double originalPdbRotCenZ
The centre of rotation as it relates to the original PDB positions (and not the ProSHADE internal map...
Definition: ProSHADE_data.hpp:104
ProSHADE_internal_misc::addToSingleVector
void addToSingleVector(std::vector< proshade_single > *vecToAddTo, proshade_single elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:55
ProSHADE_settings::firstModelOnly
bool firstModelOnly
Shoud only the first PDB model be used, or should all models be used?
Definition: ProSHADE_settings.hpp:102
ProSHADE_settings::axisErrTolerance
proshade_double axisErrTolerance
Allowed error on vector axis in in dot product ( acos ( 1 - axErr ) is the allowed difference in radi...
Definition: ProSHADE_settings.hpp:176
ProSHADE_settings::useSameBounds
bool useSameBounds
Switch to say that the same boundaries as used for the first should be used for all input maps.
Definition: ProSHADE_settings.hpp:146
ProSHADE_internal_data::ProSHADE_data::zDimIndices
proshade_unsign zDimIndices
This is the size of the map cell z dimension in indices.
Definition: ProSHADE_data.hpp:67
ProSHADE_internal_data::computeGroupElementsForGroup
std::vector< std::vector< proshade_double > > computeGroupElementsForGroup(proshade_double xAx, proshade_double yAx, proshade_double zAx, proshade_signed fold)
This function computes the group elements as rotation matrices (except for the identity element) for ...
Definition: ProSHADE_data.cpp:2268
ProSHADE_settings::pdbBFactorNewVal
proshade_double pdbBFactorNewVal
Change all PDB B-factors to this value (for smooth maps).
Definition: ProSHADE_settings.hpp:110
ProSHADE_internal_data::ProSHADE_data::getRecommendedSymmetryType
std::string getRecommendedSymmetryType(ProSHADE_settings *settings)
This function simply returns the detected recommended symmetry type.
Definition: ProSHADE_data.cpp:3685
ProSHADE_internal_data::ProSHADE_data::zGridIndices
proshade_unsign zGridIndices
As far as I know, this is identical to the zDimIndices.
Definition: ProSHADE_data.hpp:70
ProSHADE_settings::setRecommendedFold
void setRecommendedFold(proshade_unsign val)
Sets the ProSHADE detected symmetry fold.
Definition: ProSHADE.cpp:1028
ProSHADE_settings::setVariablesLeftOnAuto
void setVariablesLeftOnAuto(void)
Function to determine general values that the user left on auto-determination.
Definition: ProSHADE.cpp:316
ProSHADE_internal_data::ProSHADE_data::setEMatrixValue
void setEMatrixValue(proshade_unsign band, proshade_unsign order1, proshade_unsign order2, proshade_complex val)
This function allows setting the E matrix value.
Definition: ProSHADE_data.cpp:3419
ProSHADE_settings::removeWaters
bool removeWaters
Should all waters be removed from input PDB files?
Definition: ProSHADE_settings.hpp:101
ProSHADE_internal_data::ProSHADE_data::spheres
ProSHADE_internal_spheres::ProSHADE_sphere ** spheres
The set of concentric spheres to which the intermal density map has been projected.
Definition: ProSHADE_data.hpp:120
ProSHADE_internal_data::ProSHADE_data::normaliseMap
void normaliseMap(ProSHADE_settings *settings)
Function for normalising the map values to mean 0 and sd 1..
Definition: ProSHADE_data.cpp:948
ProSHADE_internal_data::ProSHADE_data::detectSymmetryFromAngleAxisSpace
void detectSymmetryFromAngleAxisSpace(ProSHADE_settings *settings, std::vector< proshade_double * > *axes, std::vector< std::vector< proshade_double > > *allCs)
This function runs the symmetry detection algorithms on this structure using the angle-axis space and...
Definition: ProSHADE_data.cpp:1707
ProSHADE_internal_data::ProSHADE_data::originalPdbRotCenX
proshade_double originalPdbRotCenX
The centre of rotation as it relates to the original PDB positions (and not the ProSHADE internal map...
Definition: ProSHADE_data.hpp:102
ProSHADE_internal_data::ProSHADE_data::originalMapZCom
proshade_double originalMapZCom
The COM of the first map to be loaded/computed without any furhter changes being reflacted along the ...
Definition: ProSHADE_data.hpp:93
ProSHADE_internal_messages::printProgressMessage
void printProgressMessage(proshade_signed verbose, proshade_signed messageLevel, std::string message)
General stdout message printing.
Definition: ProSHADE_messages.cpp:70
ProSHADE_internal_data::ProSHADE_data::getRealSO3Coeffs
void getRealSO3Coeffs(double *so3CoefsReal, int len)
This function fills the input array with the real SO(3) coefficient values.
Definition: ProSHADE_data.cpp:3527
ProSHADE_internal_data::ProSHADE_data::yDimSize
proshade_single yDimSize
This is the size of the map cell y dimension in Angstroms.
Definition: ProSHADE_data.hpp:60
ProSHADE_settings::setResolution
void setResolution(proshade_single resolution)
Sets the requested resolution in the appropriate variable.
Definition: ProSHADE.cpp:357
ProSHADE_settings::allDetectedCAxes
std::vector< std::vector< proshade_double > > allDetectedCAxes
The vector of all detected cyclic symmetry axes.
Definition: ProSHADE_settings.hpp:197
ProSHADE_internal_data::ProSHADE_data::removePhaseInormation
void removePhaseInormation(ProSHADE_settings *settings)
This function removes phase from the map, effectively converting it to Patterson map.
Definition: ProSHADE_data.cpp:2985
ProSHADE_internal_mapManip::moveMapByIndices
void moveMapByIndices(proshade_single *xMov, proshade_single *yMov, proshade_single *zMov, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed *xFrom, proshade_signed *xTo, proshade_signed *yFrom, proshade_signed *yTo, proshade_signed *zFrom, proshade_signed *zTo, proshade_signed *xOrigin, proshade_signed *yOrigin, proshade_signed *zOrigin)
Function for moving map back to original PDB location by changing the indices.
Definition: ProSHADE_mapManip.cpp:744
ProSHADE_internal_io::readInMapHeader
void readInMapHeader(gemmi::Ccp4< float > *map, proshade_unsign *xDimInds, proshade_unsign *yDimInds, proshade_unsign *zDimInds, proshade_single *xDim, proshade_single *yDim, proshade_single *zDim, proshade_single *aAng, proshade_single *bAng, proshade_single *cAng, proshade_signed *xFrom, proshade_signed *yFrom, proshade_signed *zFrom, proshade_signed *xAxOrigin, proshade_signed *yAxOrigin, proshade_signed *zAxOrigin, proshade_unsign *xAxOrder, proshade_unsign *yAxOrder, proshade_unsign *zAxOrder, proshade_unsign *xGridInds, proshade_unsign *yGridInds, proshade_unsign *zGridInds)
This function parses the CCP4 MAP file header as read in by gemmi.
Definition: ProSHADE_io.cpp:103
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:2141
ProSHADE_internal_data::ProSHADE_data::readInStructure
void readInStructure(std::string fName, proshade_unsign inputO, ProSHADE_settings *settings)
This function initialises the basic ProSHADE_data variables and reads in a single structure.
Definition: ProSHADE_data.cpp:447
ProSHADE_internal_data::ProSHADE_data::getAllGroupElements
std::vector< std::vector< proshade_double > > getAllGroupElements(ProSHADE_settings *settings, std::vector< proshade_unsign > axesList, std::string groupType="", proshade_double matrixTolerance=0.05)
This function returns the group elements as rotation matrices of any defined point group.
Definition: ProSHADE_data.cpp:2487
ProSHADE_internal_data::ProSHADE_data::addExtraSpace
void addExtraSpace(ProSHADE_settings *settings)
This function increases the size of the map so that it can add empty space around it.
Definition: ProSHADE_data.cpp:1289
ProSHADE_internal_data::ProSHADE_data::getRealEMatrixValuesForLM
void getRealEMatrixValuesForLM(proshade_signed band, proshade_signed order1, double *eMatsLMReal, int len)
This function fills the input array with the real E matrix values for particular band and order1 (l a...
Definition: ProSHADE_data.cpp:3489
ProSHADE_internal_misc::addToStringVector
void addToStringVector(std::vector< std::string > *vecToAddTo, std::string elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:33
ProSHADE_internal_sphericalHarmonics::computeSphericalHarmonics
void computeSphericalHarmonics(proshade_unsign band, proshade_double *sphereMappedData, proshade_complex *&shArray)
This function computes the spherical harmonics of a aingle shell, saving them in supplied pointer.
Definition: ProSHADE_sphericalHarmonics.cpp:395
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:2354
ProSHADE_internal_data::ProSHADE_data::readInPDB
void readInPDB(ProSHADE_settings *settings)
Function for reading pdb data.
Definition: ProSHADE_data.cpp:574
ProSHADE_internal_data::ProSHADE_data::getZFromPtr
proshade_signed * getZFromPtr(void)
This function allows access to the map start along the Z axis.
Definition: ProSHADE_data.cpp:3298
ProSHADE_internal_data::ProSHADE_data::getZToPtr
proshade_signed * getZToPtr(void)
This function allows access to the map last position along the Z axis.
Definition: ProSHADE_data.cpp:3328
ProSHADE_internal_data::ProSHADE_data::so3CoeffsArrayIndex
int so3CoeffsArrayIndex(proshade_signed order1, proshade_signed order2, proshade_signed band)
This function gets the SO(3) coefficients array index for a particular so(3) band,...
Definition: ProSHADE_data.cpp:3567