ProSHADE  0.6.5 (NOV 2018)
Protein Shape Descriptors and Symmetry Detection
ProSHADE_saveLoad.cpp
Go to the documentation of this file.
1 
21 //============================================ RVAPI
22 #include <rvapi_interface.h>
23 
24 //============================================ ProSHADE
25 #include "ProSHADE.h"
26 #include "ProSHADE_internal.h"
27 #include "ProSHADE_misc.h"
28 
41 {
42  //======================================== Sanity checks
43  if ( settings->databaseName == "" )
44  {
45  std::cerr << "!!! ProSHADE ERROR !!! Tried to build a database of files, but the filename to which it should be saved is empty. Terminating ..." << std::endl;
46 
47  if ( settings->htmlReport )
48  {
49  std::stringstream hlpSS;
50  hlpSS << "<font color=\"red\">" << "Missing the database name for building database." << "</font>";
51  rvapi_set_text ( hlpSS.str().c_str(),
52  "ProgressSection",
53  settings->htmlReportLineProgress,
54  1,
55  1,
56  1 );
57  settings->htmlReportLineProgress += 1;
58  rvapi_flush ( );
59  }
60 
61  exit ( -1 );
62  }
63 
64  if ( settings->structFiles.size() < 1 )
65  {
66  std::cerr << "!!! ProSHADE ERROR !!! Tried to build a database of files, but the supplied no files. Terminating ..." << std::endl;
67 
68  if ( settings->htmlReport )
69  {
70  std::stringstream hlpSS;
71  hlpSS << "<font color=\"red\">" << "There are no files to be saved into the database." << "</font>";
72  rvapi_set_text ( hlpSS.str().c_str(),
73  "ProgressSection",
74  settings->htmlReportLineProgress,
75  1,
76  1,
77  1 );
78  settings->htmlReportLineProgress += 1;
79  rvapi_flush ( );
80  }
81 
82  exit ( -1 );
83  }
84 
85  if ( settings->verbose > 3 )
86  {
87  std::cout << ">> Sanity check passed." << std::endl;
88  }
89 
90  //======================================== Open file for output
91  std::ofstream dbFile ( settings->databaseName, std::ios::out | std::ios::binary);
92 
93  //======================================== Check file for output
94  if ( dbFile.fail () )
95  {
96  std::cerr << "!!! ProSHADE ERROR !!! Canno open the database file " << settings->databaseName << " . Terminating..." << std::endl;
97 
98  if ( settings->htmlReport )
99  {
100  std::stringstream hlpSS;
101  hlpSS << "<font color=\"red\">" << "Cannot open database with name " << settings->databaseName << ". Could you have no permissions to write to the requested database location?" << "</font>";
102  rvapi_set_text ( hlpSS.str().c_str(),
103  "ProgressSection",
104  settings->htmlReportLineProgress,
105  1,
106  1,
107  1 );
108  settings->htmlReportLineProgress += 1;
109  rvapi_flush ( );
110  }
111 
112  exit ( -1 );
113  }
114 
115  //======================================== Save the settings
116  this->mapResolution = settings->mapResolution;
117  this->bandwidth = settings->bandwidth;
118  this->glIntegOrder = settings->glIntegOrder;
119  this->theta = settings->theta;
120  this->phi = settings->phi;
121  this->bFactorValue = settings->bFactorValue;
122  this->bFactorChange = settings->bFactorChange;
123  this->noIQRsFromMap = settings->noIQRsFromMap;
124  this->shellSpacing = settings->shellSpacing;
125  this->manualShells = settings->manualShells;
126  this->useCOM = settings->useCOM;
127  this->firstLineCOM = settings->firstLineCOM;
128  this->extraSpace = settings->extraSpace;
129  this->alpha = settings->alpha;
130  this->mPower = settings->mPower;
131  this->ignoreLs = settings->ignoreLs;
132  this->energyLevelDist = settings->energyLevelDist;
133  this->traceSigmaDist = settings->traceSigmaDist;
134  this->fullRotFnDist = settings->fullRotFnDist;
135  this->usePhase = settings->usePhase;
136  this->saveWithAndWithout = settings->saveWithAndWithout;
137  this->enLevelsThreshold = settings->enLevelsThreshold;
138  this->trSigmaThreshold = settings->trSigmaThreshold;
139  this->structFiles = settings->structFiles;
140 
141  if ( settings->htmlReport )
142  {
143  //==================================== Create section
144  rvapi_add_section ( "DBSettingsSection",
145  "Database Settings",
146  "body",
147  settings->htmlReportLine,
148  0,
149  1,
150  1,
151  false );
152  settings->htmlReportLine += 1;
153 
154  std::stringstream hlpSS;
155  hlpSS << "<pre>" << "Map resolution: ";
156  int hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
157  for ( int iter = 0; iter < hlpIt; iter++ )
158  {
159  hlpSS << ".";
160  }
161 
162  std::stringstream hlpSS2;
163  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mapResolution * 1000.0 ) / 1000.0;
164  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
165  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
166  hlpSS << " " << hlpSS2.str() << "</pre>";
167 
168  rvapi_set_text ( hlpSS.str().c_str(),
169  "DBSettingsSection",
170  0,
171  0,
172  1,
173  1 );
174 
175  hlpSS.str ( std::string ( ) );
176  hlpSS << "<pre>" << "Bandwidth: ";
177  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
178  for ( int iter = 0; iter < hlpIt; iter++ )
179  {
180  hlpSS << ".";
181  }
182 
183  hlpSS2.str ( std::string ( ) );
184  if ( this->bandwidth == 0 ) { hlpSS2 << " AUTO"; }
185  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bandwidth * 1000.0 ) / 1000.0; }
186  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
187  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
188  hlpSS << " " << hlpSS2.str() << "</pre>";
189 
190  rvapi_set_text ( hlpSS.str().c_str(),
191  "DBSettingsSection",
192  1,
193  0,
194  1,
195  1 );
196 
197  hlpSS.str ( std::string ( ) );
198  hlpSS << "<pre>" << "Gauss-Legendre Integration order: ";
199  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
200  for ( int iter = 0; iter < hlpIt; iter++ )
201  {
202  hlpSS << ".";
203  }
204 
205  hlpSS2.str ( std::string ( ) );
206  if ( this->glIntegOrder == 0 ) { hlpSS2 << " AUTO"; }
207  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->glIntegOrder * 1000.0 ) / 1000.0; }
208  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
209  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
210  hlpSS << " " << hlpSS2.str() << "</pre>";
211 
212  rvapi_set_text ( hlpSS.str().c_str(),
213  "DBSettingsSection",
214  2,
215  0,
216  1,
217  1 );
218 
219  hlpSS.str ( std::string ( ) );
220  hlpSS << "<pre>" << "Theta angle sampling: ";
221  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
222  for ( int iter = 0; iter < hlpIt; iter++ )
223  {
224  hlpSS << ".";
225  }
226 
227  hlpSS2.str ( std::string ( ) );
228  if ( this->theta == 0 ) { hlpSS2 << " AUTO"; }
229  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->theta * 1000.0 ) / 1000.0; }
230  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
231  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
232  hlpSS << " " << hlpSS2.str() << "</pre>";
233 
234  rvapi_set_text ( hlpSS.str().c_str(),
235  "DBSettingsSection",
236  3,
237  0,
238  1,
239  1 );
240 
241  hlpSS.str ( std::string ( ) );
242  hlpSS << "<pre>" << "Phi angle sampling: ";
243  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
244  for ( int iter = 0; iter < hlpIt; iter++ )
245  {
246  hlpSS << ".";
247  }
248 
249  hlpSS2.str ( std::string ( ) );
250  if ( this->phi == 0 ) { hlpSS2 << " AUTO"; }
251  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->phi * 1000.0 ) / 1000.0; }
252  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
253  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
254  hlpSS << " " << hlpSS2.str() << "</pre>";
255 
256  rvapi_set_text ( hlpSS.str().c_str(),
257  "DBSettingsSection",
258  4,
259  0,
260  1,
261  1 );
262 
263  hlpSS.str ( std::string ( ) );
264  hlpSS << "<pre>" << "Set all PDB file B-factors to: ";
265  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
266  for ( int iter = 0; iter < hlpIt; iter++ )
267  {
268  hlpSS << ".";
269  }
270 
271  hlpSS2.str ( std::string ( ) );
272  if ( this->bFactorValue == 0 ) { hlpSS2 << " AUTO"; }
273  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorValue * 1000.0 ) / 1000.0; }
274  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
275  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
276  hlpSS << " " << hlpSS2.str() << "</pre>";
277 
278  rvapi_set_text ( hlpSS.str().c_str(),
279  "DBSettingsSection",
280  5,
281  0,
282  1,
283  1 );
284 
285  hlpSS.str ( std::string ( ) );
286  hlpSS << "<pre>" << "Change B-factors after map computation by: ";
287  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
288  for ( int iter = 0; iter < hlpIt; iter++ )
289  {
290  hlpSS << ".";
291  }
292 
293  hlpSS2.str ( std::string ( ) );
294  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorChange * 1000.0 ) / 1000.0;
295  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
296  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
297  hlpSS << " " << hlpSS2.str() << "</pre>";
298 
299  rvapi_set_text ( hlpSS.str().c_str(),
300  "DBSettingsSection",
301  6,
302  0,
303  1,
304  1 );
305 
306  hlpSS.str ( std::string ( ) );
307  hlpSS << "<pre>" << "Map IQR from median threshold: ";
308  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
309  for ( int iter = 0; iter < hlpIt; iter++ )
310  {
311  hlpSS << ".";
312  }
313 
314  hlpSS2.str ( std::string ( ) );
315  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->noIQRsFromMap * 1000.0 ) / 1000.0;
316  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
317  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
318  hlpSS << " " << hlpSS2.str() << "</pre>";
319 
320  rvapi_set_text ( hlpSS.str().c_str(),
321  "DBSettingsSection",
322  7,
323  0,
324  1,
325  1 );
326 
327  hlpSS.str ( std::string ( ) );
328  hlpSS << "<pre>" << "Distance between shells: ";
329  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
330  for ( int iter = 0; iter < hlpIt; iter++ )
331  {
332  hlpSS << ".";
333  }
334 
335  hlpSS2.str ( std::string ( ) );
336  if ( this->shellSpacing == 0 ) { hlpSS2 << " AUTO"; }
337  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->shellSpacing * 1000.0 ) / 1000.0; }
338  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
339  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
340  hlpSS << " " << hlpSS2.str() << "</pre>";
341 
342  rvapi_set_text ( hlpSS.str().c_str(),
343  "DBSettingsSection",
344  8,
345  0,
346  1,
347  1 );
348 
349  hlpSS.str ( std::string ( ) );
350  hlpSS << "<pre>" << "Number of shells: ";
351  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
352  for ( int iter = 0; iter < hlpIt; iter++ )
353  {
354  hlpSS << ".";
355  }
356 
357  hlpSS2.str ( std::string ( ) );
358  if ( this->manualShells == 0 ) { hlpSS2 << " AUTO"; }
359  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->manualShells * 1000.0 ) / 1000.0; }
360  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
361  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
362  hlpSS << " " << hlpSS2.str() << "</pre>";
363 
364  rvapi_set_text ( hlpSS.str().c_str(),
365  "DBSettingsSection",
366  9,
367  0,
368  1,
369  1 );
370 
371  hlpSS.str ( std::string ( ) );
372  hlpSS << "<pre>" << "Use Centre of Mass for centering: ";
373  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
374  for ( int iter = 0; iter < hlpIt; iter++ )
375  {
376  hlpSS << ".";
377  }
378 
379  hlpSS2.str ( std::string ( ) );
380  if ( this->useCOM == 0 ) { hlpSS2 << " FALSE"; }
381  else { hlpSS2 << " TRUE"; }
382  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
383  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
384  hlpSS << " " << hlpSS2.str() << "</pre>";
385 
386  rvapi_set_text ( hlpSS.str().c_str(),
387  "DBSettingsSection",
388  10,
389  0,
390  1,
391  1 );
392 
393  hlpSS.str ( std::string ( ) );
394  hlpSS << "<pre>" << "Add extra space to cell: ";
395  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
396  for ( int iter = 0; iter < hlpIt; iter++ )
397  {
398  hlpSS << ".";
399  }
400 
401  hlpSS2.str ( std::string ( ) );
402  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->extraSpace * 1000.0 ) / 1000.0;
403  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
404  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
405  hlpSS << " " << hlpSS2.str() << "</pre>";
406 
407  rvapi_set_text ( hlpSS.str().c_str(),
408  "DBSettingsSection",
409  11,
410  0,
411  1,
412  1 );
413 
414  hlpSS.str ( std::string ( ) );
415  hlpSS << "<pre>" << "Raise Fourier coefficients to power: ";
416  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
417  for ( int iter = 0; iter < hlpIt; iter++ )
418  {
419  hlpSS << ".";
420  }
421 
422  hlpSS2.str ( std::string ( ) );
423  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->alpha * 1000.0 ) / 1000.0;
424  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
425  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
426  hlpSS << " " << hlpSS2.str() << "</pre>";
427 
428  rvapi_set_text ( hlpSS.str().c_str(),
429  "DBSettingsSection",
430  12,
431  0,
432  1,
433  1 );
434 
435  hlpSS.str ( std::string ( ) );
436  hlpSS << "<pre>" << "Weight Energy Level matrix position by: ";
437  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
438  for ( int iter = 0; iter < hlpIt; iter++ )
439  {
440  hlpSS << ".";
441  }
442 
443  hlpSS2.str ( std::string ( ) );
444  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mPower * 1000.0 ) / 1000.0;
445  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
446  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
447  hlpSS << " " << hlpSS2.str() << "</pre>";
448 
449  rvapi_set_text ( hlpSS.str().c_str(),
450  "DBSettingsSection",
451  13,
452  0,
453  1,
454  1 );
455 
456  hlpSS.str ( std::string ( ) );
457  hlpSS << "<pre>" << "Ignore the following bands: ";
458  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
459  for ( int iter = 0; iter < hlpIt; iter++ )
460  {
461  hlpSS << ".";
462  }
463 
464  hlpSS2.str ( std::string ( ) );
465  for ( int iter = 0; iter < static_cast<int> ( this->ignoreLs.size() ); iter++ )
466  {
467  hlpSS2 << std::showpos << this->ignoreLs.at(iter) << " ";
468  }
469  hlpSS << " " << hlpSS2.str() << "</pre>";
470 
471  rvapi_set_text ( hlpSS.str().c_str(),
472  "DBSettingsSection",
473  14,
474  0,
475  1,
476  1 );
477 
478  hlpSS.str ( std::string ( ) );
479  hlpSS << "<pre>" << "Compute Energy Level distances: ";
480  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
481  for ( int iter = 0; iter < hlpIt; iter++ )
482  {
483  hlpSS << ".";
484  }
485 
486  hlpSS2.str ( std::string ( ) );
487  if ( this->energyLevelDist == 0 ) { hlpSS2 << " FALSE"; }
488  else { hlpSS2 << " TRUE"; }
489  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
490  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
491  hlpSS << " " << hlpSS2.str() << "</pre>";
492 
493  rvapi_set_text ( hlpSS.str().c_str(),
494  "DBSettingsSection",
495  15,
496  0,
497  1,
498  1 );
499 
500  hlpSS.str ( std::string ( ) );
501  hlpSS << "<pre>" << "Compute Trace Sigma distances: ";
502  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
503  for ( int iter = 0; iter < hlpIt; iter++ )
504  {
505  hlpSS << ".";
506  }
507 
508  hlpSS2.str ( std::string ( ) );
509  if ( this->traceSigmaDist == 0 ) { hlpSS2 << " FALSE"; }
510  else { hlpSS2 << " TRUE"; }
511  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
512  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
513  hlpSS << " " << hlpSS2.str() << "</pre>";
514 
515  rvapi_set_text ( hlpSS.str().c_str(),
516  "DBSettingsSection",
517  16,
518  0,
519  1,
520  1 );
521 
522  hlpSS.str ( std::string ( ) );
523  hlpSS << "<pre>" << "Compute Rotation Function distances: ";
524  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
525  for ( int iter = 0; iter < hlpIt; iter++ )
526  {
527  hlpSS << ".";
528  }
529 
530  hlpSS2.str ( std::string ( ) );
531  if ( this->fullRotFnDist == 0 ) { hlpSS2 << " FALSE"; }
532  else { hlpSS2 << " TRUE"; }
533  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
534  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
535  hlpSS << " " << hlpSS2.str() << "</pre>";
536 
537  rvapi_set_text ( hlpSS.str().c_str(),
538  "DBSettingsSection",
539  17,
540  0,
541  1,
542  1 );
543 
544  hlpSS.str ( std::string ( ) );
545  hlpSS << "<pre>" << "Use phase information: ";
546  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
547  for ( int iter = 0; iter < hlpIt; iter++ )
548  {
549  hlpSS << ".";
550  }
551 
552  hlpSS2.str ( std::string ( ) );
553  if ( this->usePhase == 0 ) { hlpSS2 << " FALSE"; }
554  else { hlpSS2 << " TRUE"; }
555  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
556  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
557  hlpSS << " " << hlpSS2.str() << "</pre>";
558 
559  rvapi_set_text ( hlpSS.str().c_str(),
560  "DBSettingsSection",
561  18,
562  0,
563  1,
564  1 );
565 
566  rvapi_flush ( );
567  }
568 
569  if ( settings->htmlReport )
570  {
571  //==================================== Create section
572  rvapi_add_section ( "DBFilesSection",
573  "List of files",
574  "body",
575  settings->htmlReportLine,
576  0,
577  1,
578  1,
579  false );
580  settings->htmlReportLine += 1;
581  rvapi_flush ( );
582  }
583 
584  //======================================== First, find sizes
585  if ( settings->verbose > 0 )
586  {
587  std::cout << "Now detecting sizes of structures for database sorting." << std::endl;
588  }
589 
590  if ( settings->htmlReport )
591  {
592  std::stringstream hlpSS;
593  hlpSS << "<font color=\"green\">" << "Database settings saved ." << "</font>";
594  rvapi_set_text ( hlpSS.str().c_str(),
595  "ProgressSection",
596  settings->htmlReportLineProgress,
597  1,
598  1,
599  1 );
600  settings->htmlReportLineProgress += 1;
601 
602  rvapi_flush ( );
603  }
604 
605  std::vector< std::array<double,2> > strSizes;
606  std::array<double,2> hlpArr;
607  std::vector<double> shSpc ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
608  std::vector<unsigned int> bndV ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
609  std::vector<unsigned int> thtV ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
610  std::vector<unsigned int> phV ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
611  std::vector<unsigned int> glIntV ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
612  std::vector<double> exSpV ( static_cast<unsigned int> ( settings->structFiles.size() ), 0.0 );
613  int filesSectionIter = 0;
614  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( settings->structFiles.size() ); iter++ )
615  {
616  if ( settings->verbose > 1 )
617  {
618  std::cout << ">> Now loading file " << iter+1 << " out of " << settings->structFiles.size() << std::endl;
619  }
620 
621  //==================================== Create ProSHADE_data object to hold data and compute information
622  ProSHADE_data* one = new ProSHADE_data ();
623 
624  //=================================== Re-set settings
625  this->bandwidth = settings->bandwidth;
626  this->glIntegOrder = settings->glIntegOrder;
627  this->theta = settings->theta;
628  this->phi = settings->phi;
629  this->extraSpace = settings->extraSpace;
630 
631  //==================================== Read in the structure into one
632  unsigned int fileType = checkFileType ( structFiles.at(iter) );
633  if ( fileType == 2 )
634  {
635  one->getDensityMapFromMAP ( this->structFiles.at(iter),
636  &shSpc.at(iter),
637  this->mapResolution,
638  &bndV.at(iter),
639  &thtV.at(iter),
640  &phV.at(iter),
641  &glIntV.at(iter),
642  &exSpV.at(iter),
643  settings->mapResDefault,
644  settings->rotChangeDefault,
645  settings,
646  settings->overlayDefaults );
647  }
648  else if ( fileType == 1 )
649  {
650  one->getDensityMapFromPDB ( this->structFiles.at(iter),
651  &shSpc.at(iter),
652  this->mapResolution,
653  &bndV.at(iter),
654  &thtV.at(iter),
655  &phV.at(iter),
656  &glIntV.at(iter),
657  &exSpV.at(iter),
658  settings->mapResDefault,
659  settings,
660  this->bFactorValue,
661  this->firstLineCOM );
662  }
663  else
664  {
665  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(iter) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
666 
667  if ( settings->htmlReport )
668  {
669  std::stringstream hlpSS;
670  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(iter) << "." << "</font>";
671  rvapi_set_text ( hlpSS.str().c_str(),
672  "ProgressSection",
673  settings->htmlReportLineProgress,
674  1,
675  1,
676  1 );
677  settings->htmlReportLineProgress += 1;
678  rvapi_flush ( );
679  }
680 
681  exit ( -1 );
682  }
683 
684  //==================================== Get volume
685  hlpArr[0] = (one->_xRange-this->extraSpace) * (one->_yRange-this->extraSpace) * (one->_zRange-this->extraSpace);
686  hlpArr[1] = static_cast<double> ( iter );
687 
688  if ( settings->databaseMaxVolume == 0.0 )
689  {
690  strSizes.emplace_back ( hlpArr );
691  }
692  else
693  {
694  if ( hlpArr[0] < settings->databaseMaxVolume )
695  {
696  strSizes.emplace_back ( hlpArr );
697  }
698  else
699  {
700  if ( settings->verbose > 2 )
701  {
702  std::cout << ">>>>> Excluding file " << this->structFiles.at(iter) << " due to large size (databaseMaxVolume smaller than structure volunme)." << std::endl;
703  }
704 
705  if ( settings->htmlReport )
706  {
707  std::stringstream hlpSS;
708  hlpSS << "<font color=\"red\">" << "Excluding file " << this->structFiles.at(iter) << " from the database due to size constraints." << "</font>";
709  rvapi_set_text ( hlpSS.str().c_str(),
710  "DBFilesSection",
711  filesSectionIter,
712  1,
713  1,
714  1 );
715  filesSectionIter += 1;
716 
717  rvapi_flush ( );
718  }
719  }
720  }
721 
722  //==================================== Clean up
723  delete one;
724  }
725 
726  //======================================== Set identical processing for structures
727  double minSph = 1000000000.0;
728  int minSphPos = 0;
729  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( settings->structFiles.size() ); iter++ )
730  {
731  if ( shSpc.at(iter) < minSph )
732  {
733  minSph = shSpc.at(iter);
734  minSphPos = static_cast<int> ( iter );
735  }
736  }
737 
738  settings->shellSpacing = shSpc.at ( minSphPos );
739  settings->bandwidth = bndV.at ( minSphPos );
740  settings->theta = thtV.at ( minSphPos );
741  settings->phi = phV.at ( minSphPos );
742  settings->glIntegOrder = glIntV.at ( minSphPos );
743  settings->extraSpace = exSpV.at ( minSphPos );
744 
745  //======================================== Sort by volume
746  std::sort ( strSizes.begin(), strSizes.end(), [](const std::array<double,2>& a, const std::array<double,2>& b) { return a[0] < b[0]; });
747 
748  settings->databaseMinVolume = 0.0;
749  if ( strSizes.size() > 0 )
750  {
751  settings->databaseMinVolume = strSizes.at(0)[0];
752  }
753 
754  std::vector<std::string> hlpVec ( strSizes.size() );
755  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( strSizes.size() ); iter++ )
756  {
757  hlpVec.at(iter) = settings->structFiles.at(strSizes.at(iter)[1]);
758  }
759 
760  settings->structFiles.clear ( );
761  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( strSizes.size() ); iter++ )
762  {
763  settings->structFiles.emplace_back ( hlpVec.at(iter) );
764  }
765  hlpVec.clear();
766  strSizes.clear();
767 
768  if ( settings->htmlReport )
769  {
770  std::stringstream hlpSS;
771  hlpSS << "<font color=\"green\">" << "Volume ordering of input structures complete." << "</font>";
772  rvapi_set_text ( hlpSS.str().c_str(),
773  "ProgressSection",
774  settings->htmlReportLineProgress,
775  1,
776  1,
777  1 );
778  settings->htmlReportLineProgress += 1;
779 
780  rvapi_flush ( );
781  }
782 
783  //======================================== Initialise local variables
784  unsigned int hlpUInt;
785 
786  //======================================== Write out the settings used to produce the database
787  dbFile.write ( reinterpret_cast<char*> ( &settings->databaseMinVolume ), sizeof( double ) );
788  dbFile.write ( reinterpret_cast<char*> ( &settings->mapResolution ), sizeof( double ) );
789  dbFile.write ( reinterpret_cast<char*> ( &settings->bandwidth ), sizeof( unsigned int ) );
790  dbFile.write ( reinterpret_cast<char*> ( &settings->glIntegOrder ), sizeof( unsigned int ) );
791  dbFile.write ( reinterpret_cast<char*> ( &settings->theta ), sizeof( unsigned int ) );
792  dbFile.write ( reinterpret_cast<char*> ( &settings->phi ), sizeof( unsigned int ) );
793  dbFile.write ( reinterpret_cast<char*> ( &settings->bFactorValue ), sizeof( double ) );
794  dbFile.write ( reinterpret_cast<char*> ( &settings->bFactorChange ), sizeof( double ) );
795  dbFile.write ( reinterpret_cast<char*> ( &settings->noIQRsFromMap ), sizeof( double ) );
796  dbFile.write ( reinterpret_cast<char*> ( &settings->maskBlurFactor ), sizeof( double ) );
797  dbFile.write ( reinterpret_cast<char*> ( &settings->shellSpacing ), sizeof( double ) );
798  dbFile.write ( reinterpret_cast<char*> ( &settings->manualShells ), sizeof( unsigned int ) );
799  dbFile.write ( reinterpret_cast<char*> ( &settings->usePhase ), sizeof( bool ) );
800  dbFile.write ( reinterpret_cast<char*> ( &settings->saveWithAndWithout ), sizeof( bool ) );
801  dbFile.write ( reinterpret_cast<char*> ( &settings->useCOM ), sizeof( bool ) );
802  dbFile.write ( reinterpret_cast<char*> ( &settings->firstLineCOM ), sizeof( bool ) );
803  dbFile.write ( reinterpret_cast<char*> ( &settings->alpha ), sizeof( double ) );
804  dbFile.write ( reinterpret_cast<char*> ( &settings->mPower ), sizeof( double ) );
805 
806  hlpUInt = static_cast<unsigned int> ( settings->ignoreLs.size() );
807  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
808  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( settings->ignoreLs.size() ); iter++ )
809  {
810  dbFile.write ( reinterpret_cast<char*> ( &settings->ignoreLs.at(iter) ), sizeof( unsigned int ) );
811  }
812 
813  hlpUInt = static_cast<unsigned int> ( settings->structFiles.size() );
814  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
815  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( settings->structFiles.size() ); iter++ )
816  {
817  hlpUInt = settings->structFiles.at(iter).length();
818  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
819  dbFile.write ( settings->structFiles.at(iter).c_str(), sizeof( char ) * hlpUInt );
820  }
821 
822  dbFile.write ( reinterpret_cast<char*> ( &settings->peakHeightNoIQRs ), sizeof( double ) );
823  dbFile.write ( reinterpret_cast<char*> ( &settings->peakDistanceForReal ), sizeof( double ) );
824  dbFile.write ( reinterpret_cast<char*> ( &settings->peakSurroundingPoints ), sizeof( int ) );
825  dbFile.write ( reinterpret_cast<char*> ( &settings->aaErrorTolerance ), sizeof( double ) );
826  dbFile.write ( reinterpret_cast<char*> ( &settings->symGapTolerance ), sizeof( double ) );
827  dbFile.write ( reinterpret_cast<char*> ( &settings->energyLevelDist ), sizeof( bool ) );
828  dbFile.write ( reinterpret_cast<char*> ( &settings->traceSigmaDist ), sizeof( bool ) );
829  dbFile.write ( reinterpret_cast<char*> ( &settings->fullRotFnDist ), sizeof( bool ) );
830  dbFile.write ( reinterpret_cast<char*> ( &settings->enLevelsThreshold ), sizeof( double ) );
831  dbFile.write ( reinterpret_cast<char*> ( &settings->trSigmaThreshold ), sizeof( double ) );
832  dbFile.write ( reinterpret_cast<char*> ( &settings->taskToPerform ), sizeof( ProSHADE::Task ) );
833 
834  hlpUInt = settings->clearMapFile.length();
835  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
836  dbFile.write ( settings->clearMapFile.c_str(), sizeof( char ) * hlpUInt );
837 
838  hlpUInt = settings->mapFragName.length();
839  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
840  dbFile.write ( settings->mapFragName.c_str(), sizeof( char ) * hlpUInt );
841 
842  if ( settings->verbose > 1 )
843  {
844  std::cout << ">> Settings written to " << settings->databaseName << "." << std::endl;
845  }
846 
847  if ( settings->htmlReport )
848  {
849  std::stringstream hlpSS;
850  hlpSS << "<font color=\"green\">" << "Database settings written into the database file." << "</font>";
851  rvapi_set_text ( hlpSS.str().c_str(),
852  "ProgressSection",
853  settings->htmlReportLineProgress,
854  1,
855  1,
856  1 );
857  settings->htmlReportLineProgress += 1;
858 
859  rvapi_flush ( );
860  }
861 
862  if ( settings->verbose > 0 )
863  {
864  std::cout << "Saving files in sorted volume order." << std::endl;
865  }
866 
867  //======================================== For each file submitted for databasing
868  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( settings->structFiles.size() ); iter++ )
869  {
870  if ( settings->verbose > 1 )
871  {
872  std::cout << ">> Now saving file " << iter+1 << " out of " << settings->structFiles.size() << std::endl;
873  }
874  settings->usePhase = this->usePhase;
875 
876  //==================================== Create ProSHADE_data object to hold data and compute information
877  ProSHADE_data* one = new ProSHADE_data ();
878 
879  //==================================== Re-set settings
880  this->bandwidth = settings->bandwidth;
881  this->glIntegOrder = settings->glIntegOrder;
882  this->theta = settings->theta;
883  this->phi = settings->phi;
884  this->extraSpace = settings->extraSpace;
885 
886  //==================================== Read in the structure into one
887  unsigned int fileType = checkFileType ( settings->structFiles.at(iter) );
888  if ( fileType == 2 )
889  {
890  one->getDensityMapFromMAP ( settings->structFiles.at(iter),
891  &this->shellSpacing,
892  this->mapResolution,
893  &this->bandwidth,
894  &this->theta,
895  &this->phi,
896  &this->glIntegOrder,
897  &this->extraSpace,
898  settings->mapResDefault,
899  settings->rotChangeDefault,
900  settings,
901  settings->overlayDefaults );
902  }
903  else if ( fileType == 1 )
904  {
905  one->getDensityMapFromPDB ( settings->structFiles.at(iter),
906  &this->shellSpacing,
907  this->mapResolution,
908  &this->bandwidth,
909  &this->theta,
910  &this->phi,
911  &this->glIntegOrder,
912  &this->extraSpace,
913  settings->mapResDefault,
914  settings,
915  this->bFactorValue,
916  this->firstLineCOM );
917  }
918  else
919  {
920  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(iter) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
921 
922  if ( settings->htmlReport )
923  {
924  std::stringstream hlpSS;
925  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(iter) << "." << "</font>";
926  rvapi_set_text ( hlpSS.str().c_str(),
927  "ProgressSection",
928  settings->htmlReportLineProgress,
929  1,
930  1,
931  1 );
932  settings->htmlReportLineProgress += 1;
933  rvapi_flush ( );
934  }
935 
936  exit ( -1 );
937  }
938 
939  if ( settings->verbose > 3 )
940  {
941  std::cout << ">>>>> Structure loaded." << std::endl;
942  }
943 
944  //==================================== Deal with the centering and MAP data format, if applicable
945  if ( saveWithAndWithout )
946  {
947  one->normaliseMap ( settings );
948  }
949  if ( this->usePhase )
950  {
951  one->keepPhaseInMap ( this->alpha,
952  this->bFactorChange,
953  &this->bandwidth,
954  &this->theta,
955  &this->phi,
956  &this->glIntegOrder,
957  settings,
958  this->useCOM,
959  settings->noIQRsFromMap,
960  settings->verbose,
961  settings->clearMapData,
962  settings->rotChangeDefault,
963  settings->overlayDefaults,
964  settings->maskBlurFactor,
965  false );
966  }
967  else
968  {
969  one->removePhaseFromMap ( this->alpha,
970  this->bFactorChange,
971  settings );
972  }
973 
974  //==================================== Map the density onto spheres
975  if ( saveWithAndWithout )
976  {
977  one->mapPhaselessToSphere ( settings,
978  this->theta,
979  this->phi,
980  this->shellSpacing,
981  this->manualShells,
982  true );
983  }
984  else
985  {
986  one->mapPhaselessToSphere ( settings,
987  this->theta,
988  this->phi,
989  this->shellSpacing,
990  this->manualShells,
991  false );
992  }
993 
994  //==================================== Compute the Spherical Harmonics (SH) coefficients
995  one->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
996  if ( settings->verbose > 3 )
997  {
998  std::cout << ">>>>> Spherical harmonics computed." << std::endl;
999  }
1000 
1001  //==================================== Pre-compute the RRP matrices
1002  one->precomputeRotInvDescriptor ( settings );
1003 
1004  //==================================== Save file settings
1005  dbFile.write ( reinterpret_cast<char*> ( &one->_fromPDB ), sizeof( bool ) );
1006  dbFile.write ( reinterpret_cast<char*> ( &one->_shellSpacing ), sizeof( double ) );
1007  dbFile.write ( reinterpret_cast<char*> ( &one->_maxExtraCellularSpace ), sizeof( double ) );
1008  dbFile.write ( reinterpret_cast<char*> ( &one->_xRange ), sizeof( double ) );
1009  dbFile.write ( reinterpret_cast<char*> ( &one->_yRange ), sizeof( double ) );
1010  dbFile.write ( reinterpret_cast<char*> ( &one->_zRange ), sizeof( double ) );
1011 
1012  hlpUInt = one->_shellPlacement.size();
1013  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
1014  for ( unsigned int it = 0; it < hlpUInt; it++ )
1015  {
1016  dbFile.write ( reinterpret_cast<char*> ( &one->_shellPlacement.at(it) ), sizeof( double ) );
1017  }
1018 
1019  dbFile.write ( reinterpret_cast<char*> ( &one->_mapResolution ), sizeof( double ) );
1020  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapU ), sizeof( unsigned int ) );
1021  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapV ), sizeof( unsigned int ) );
1022  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapW ), sizeof( unsigned int ) );
1023  dbFile.write ( reinterpret_cast<char*> ( &one->_densityMapComputed ), sizeof( bool ) );
1024  dbFile.write ( reinterpret_cast<char*> ( &one->_mapMean ), sizeof( double ) );
1025  dbFile.write ( reinterpret_cast<char*> ( &one->_mapSdev ), sizeof( double ) );
1026  dbFile.write ( reinterpret_cast<char*> ( &one->_fourierCoeffPower ), sizeof( double ) );
1027  dbFile.write ( reinterpret_cast<char*> ( &one->_bFactorChange ), sizeof( double ) );
1028  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapRange ), sizeof( double ) );
1029  dbFile.write ( reinterpret_cast<char*> ( &one->_phaseRemoved ), sizeof( bool ) );
1030  dbFile.write ( reinterpret_cast<char*> ( &one->_usePhase ), sizeof( bool ) );
1031  dbFile.write ( reinterpret_cast<char*> ( &one->_keepOrRemove ), sizeof( bool ) );
1032  dbFile.write ( reinterpret_cast<char*> ( &one->_thetaAngle ), sizeof( double ) );
1033  dbFile.write ( reinterpret_cast<char*> ( &one->_phiAngle ), sizeof( double ) );
1034  dbFile.write ( reinterpret_cast<char*> ( &one->_noShellsWithData ), sizeof( unsigned int ) );
1035  dbFile.write ( reinterpret_cast<char*> ( &one->_xCorrection ), sizeof( unsigned int ) );
1036  dbFile.write ( reinterpret_cast<char*> ( &one->_yCorrection ), sizeof( unsigned int ) );
1037  dbFile.write ( reinterpret_cast<char*> ( &one->_zCorrection ), sizeof( unsigned int ) );
1038  dbFile.write ( reinterpret_cast<char*> ( &one->_xCorrErr ), sizeof( double ) );
1039  dbFile.write ( reinterpret_cast<char*> ( &one->_yCorrErr ), sizeof( double ) );
1040  dbFile.write ( reinterpret_cast<char*> ( &one->_zCorrErr ), sizeof( double ) );
1041  dbFile.write ( reinterpret_cast<char*> ( &one->_sphereMapped ), sizeof( bool ) );
1042  dbFile.write ( reinterpret_cast<char*> ( &one->_firstLineCOM ), sizeof( bool ) );
1043  dbFile.write ( reinterpret_cast<char*> ( &one->_bandwidthLimit ), sizeof( unsigned int ) );
1044  dbFile.write ( reinterpret_cast<char*> ( &one->_oneDimmension ), sizeof( unsigned int ) );
1045  dbFile.write ( reinterpret_cast<char*> ( &one->_sphericalCoefficientsComputed ), sizeof( bool ) );
1046  dbFile.write ( reinterpret_cast<char*> ( &one->_rrpMatricesPrecomputed ), sizeof( bool ) );
1047 
1048  //==================================== Save spherical harmonics values
1049  for ( unsigned int sh = 0; sh < one->_noShellsWithData; sh++ )
1050  {
1051  for ( unsigned int arrIt = 0; arrIt < ( one->_oneDimmension * one->_oneDimmension ); arrIt++ )
1052  {
1053  dbFile.write ( reinterpret_cast<char*> ( &one->_realSHCoeffs[sh][arrIt] ), sizeof( double ) );
1054  dbFile.write ( reinterpret_cast<char*> ( &one->_imagSHCoeffs[sh][arrIt] ), sizeof( double ) );
1055  }
1056  }
1057 
1058  //==================================== Save RRP matrices values
1059  for ( unsigned int bnIt = 0; bnIt < one->_bandwidthLimit; bnIt++ )
1060  {
1061  if ( !one->_keepOrRemove ) { if ( ( bnIt % 2 ) != 0 ) { continue; } }
1062 
1063  for ( unsigned int sh1 = 0; sh1 < one->_noShellsWithData; sh1++ )
1064  {
1065  for ( unsigned int sh2 = 0; sh2 < one->_noShellsWithData; sh2++ )
1066  {
1067  dbFile.write ( reinterpret_cast<char*> ( &one->_rrpMatrices[bnIt][sh1][sh2] ), sizeof( double ) );
1068  }
1069  }
1070  }
1071 
1072  //==================================== If saveWithAndWithout is true, save the other phase option as well
1073  if ( saveWithAndWithout )
1074  {
1075  //================================ Save maps as well as the XYZ from/to values
1076  if ( one->_usePhase )
1077  {
1078  dbFile.write ( reinterpret_cast<char*> ( &one->_xFrom ), sizeof( double ) );
1079  dbFile.write ( reinterpret_cast<char*> ( &one->_xTo ), sizeof( double ) );
1080  dbFile.write ( reinterpret_cast<char*> ( &one->_yFrom ), sizeof( double ) );
1081  dbFile.write ( reinterpret_cast<char*> ( &one->_yTo ), sizeof( double ) );
1082  dbFile.write ( reinterpret_cast<char*> ( &one->_zFrom ), sizeof( double ) );
1083  dbFile.write ( reinterpret_cast<char*> ( &one->_zTo ), sizeof( double ) );
1084 
1085  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( (one->_maxMapU+1) * (one->_maxMapV+1) * (one->_maxMapW+1) ); mIt++ )
1086  {
1087  dbFile.write ( reinterpret_cast<char*> ( &one->_densityMapCor[mIt] ), sizeof( double ) );
1088  }
1089  }
1090 
1091  //================================ Reverse phase
1092  settings->usePhase = !this->usePhase;
1093 
1094  //================================ Create ProSHADE_data object to hold data and compute information
1095  ProSHADE_data* two = new ProSHADE_data ();
1096 
1097  //================================ Re-set settings
1098  this->bandwidth = settings->bandwidth;
1099  this->glIntegOrder = settings->glIntegOrder;
1100  this->theta = settings->theta;
1101  this->phi = settings->phi;
1102  this->extraSpace = settings->extraSpace;
1103 
1104  //==================================== Read in the structure into two
1105  unsigned int fileType = checkFileType ( settings->structFiles.at(iter) );
1106  if ( fileType == 2 )
1107  {
1108  two->getDensityMapFromMAP ( settings->structFiles.at(iter),
1109  &this->shellSpacing,
1110  this->mapResolution,
1111  &this->bandwidth,
1112  &this->theta,
1113  &this->phi,
1114  &this->glIntegOrder,
1115  &this->extraSpace,
1116  settings->mapResDefault,
1117  settings->rotChangeDefault,
1118  settings,
1119  settings->overlayDefaults );
1120  }
1121  else if ( fileType == 1 )
1122  {
1123  two->getDensityMapFromPDB ( settings->structFiles.at(iter),
1124  &this->shellSpacing,
1125  this->mapResolution,
1126  &this->bandwidth,
1127  &this->theta,
1128  &this->phi,
1129  &this->glIntegOrder,
1130  &this->extraSpace,
1131  settings->mapResDefault,
1132  settings,
1133  this->bFactorValue,
1134  this->firstLineCOM );
1135  }
1136  else
1137  {
1138  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(iter) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
1139 
1140  if ( settings->htmlReport )
1141  {
1142  std::stringstream hlpSS;
1143  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(iter) << "." << "</font>";
1144  rvapi_set_text ( hlpSS.str().c_str(),
1145  "ProgressSection",
1146  settings->htmlReportLineProgress,
1147  1,
1148  1,
1149  1 );
1150  settings->htmlReportLineProgress += 1;
1151  rvapi_flush ( );
1152  }
1153 
1154  exit ( -1 );
1155  }
1156 
1157  if ( settings->verbose > 3 )
1158  {
1159  std::cout << ">>>>> Structure loaded." << std::endl;
1160  }
1161 
1162  //================================ Deal with the centering and MAP data format, if applicable
1163  two->normaliseMap ( settings );
1164  if ( settings->usePhase )
1165  {
1166  two->keepPhaseInMap ( this->alpha,
1167  this->bFactorChange,
1168  &this->bandwidth,
1169  &this->theta,
1170  &this->phi,
1171  &this->glIntegOrder,
1172  settings,
1173  this->useCOM,
1174  settings->noIQRsFromMap,
1175  settings->verbose,
1176  settings->clearMapData,
1177  settings->rotChangeDefault,
1178  settings->overlayDefaults,
1179  settings->maskBlurFactor,
1180  false );
1181  }
1182  else
1183  {
1184  two->removePhaseFromMap ( this->alpha,
1185  this->bFactorChange,
1186  settings );
1187  }
1188 
1189  //================================ Map the density onto spheres
1190  two->mapPhaselessToSphere ( settings,
1191  this->theta,
1192  this->phi,
1193  this->shellSpacing,
1194  this->manualShells );
1195 
1196  //================================ Compute the Spherical Harmonics (SH) coefficients
1197  two->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1198  if ( settings->verbose > 3 )
1199  {
1200  std::cout << ">>>>> Spherical harmonics computed (phase reverse)." << std::endl;
1201  }
1202 
1203  //================================ Pre-compute the RRP matrices
1204  two->precomputeRotInvDescriptor ( settings );
1205 
1206  //================================ Save file settings
1207  dbFile.write ( reinterpret_cast<char*> ( &two->_fromPDB ), sizeof( bool ) );
1208  dbFile.write ( reinterpret_cast<char*> ( &two->_shellSpacing ), sizeof( double ) );
1209  dbFile.write ( reinterpret_cast<char*> ( &two->_maxExtraCellularSpace ), sizeof( double ) );
1210  dbFile.write ( reinterpret_cast<char*> ( &two->_xRange ), sizeof( double ) );
1211  dbFile.write ( reinterpret_cast<char*> ( &two->_yRange ), sizeof( double ) );
1212  dbFile.write ( reinterpret_cast<char*> ( &two->_zRange ), sizeof( double ) );
1213 
1214  hlpUInt = two->_shellPlacement.size();
1215  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
1216  for ( unsigned int it = 0; it < hlpUInt; it++ )
1217  {
1218  dbFile.write ( reinterpret_cast<char*> ( &two->_shellPlacement.at(it) ), sizeof( double ) );
1219  }
1220 
1221  dbFile.write ( reinterpret_cast<char*> ( &two->_mapResolution ), sizeof( double ) );
1222  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapU ), sizeof( unsigned int ) );
1223  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapV ), sizeof( unsigned int ) );
1224  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapW ), sizeof( unsigned int ) );
1225  dbFile.write ( reinterpret_cast<char*> ( &two->_densityMapComputed ), sizeof( bool ) );
1226  dbFile.write ( reinterpret_cast<char*> ( &two->_mapMean ), sizeof( double ) );
1227  dbFile.write ( reinterpret_cast<char*> ( &two->_mapSdev ), sizeof( double ) );
1228  dbFile.write ( reinterpret_cast<char*> ( &two->_fourierCoeffPower ), sizeof( double ) );
1229  dbFile.write ( reinterpret_cast<char*> ( &two->_bFactorChange ), sizeof( double ) );
1230  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapRange ), sizeof( double ) );
1231  dbFile.write ( reinterpret_cast<char*> ( &two->_phaseRemoved ), sizeof( bool ) );
1232  dbFile.write ( reinterpret_cast<char*> ( &two->_usePhase ), sizeof( bool ) );
1233  dbFile.write ( reinterpret_cast<char*> ( &two->_keepOrRemove ), sizeof( bool ) );
1234  dbFile.write ( reinterpret_cast<char*> ( &two->_thetaAngle ), sizeof( double ) );
1235  dbFile.write ( reinterpret_cast<char*> ( &two->_phiAngle ), sizeof( double ) );
1236  dbFile.write ( reinterpret_cast<char*> ( &two->_noShellsWithData ), sizeof( unsigned int ) );
1237  dbFile.write ( reinterpret_cast<char*> ( &two->_xCorrection ), sizeof( unsigned int ) );
1238  dbFile.write ( reinterpret_cast<char*> ( &two->_yCorrection ), sizeof( unsigned int ) );
1239  dbFile.write ( reinterpret_cast<char*> ( &two->_zCorrection ), sizeof( unsigned int ) );
1240  dbFile.write ( reinterpret_cast<char*> ( &two->_xCorrErr ), sizeof( double ) );
1241  dbFile.write ( reinterpret_cast<char*> ( &two->_yCorrErr ), sizeof( double ) );
1242  dbFile.write ( reinterpret_cast<char*> ( &two->_zCorrErr ), sizeof( double ) );
1243  dbFile.write ( reinterpret_cast<char*> ( &two->_sphereMapped ), sizeof( bool ) );
1244  dbFile.write ( reinterpret_cast<char*> ( &two->_firstLineCOM ), sizeof( bool ) );
1245  dbFile.write ( reinterpret_cast<char*> ( &two->_bandwidthLimit ), sizeof( unsigned int ) );
1246  dbFile.write ( reinterpret_cast<char*> ( &two->_oneDimmension ), sizeof( unsigned int ) );
1247  dbFile.write ( reinterpret_cast<char*> ( &two->_sphericalCoefficientsComputed ), sizeof( bool ) );
1248  dbFile.write ( reinterpret_cast<char*> ( &two->_rrpMatricesPrecomputed ), sizeof( bool ) );
1249 
1250  //================================ Save spherical harmonics values
1251  for ( unsigned int sh = 0; sh < two->_noShellsWithData; sh++ )
1252  {
1253  for ( unsigned int arrIt = 0; arrIt < ( two->_oneDimmension * two->_oneDimmension ); arrIt++ )
1254  {
1255  dbFile.write ( reinterpret_cast<char*> ( &two->_realSHCoeffs[sh][arrIt] ), sizeof( double ) );
1256  dbFile.write ( reinterpret_cast<char*> ( &two->_imagSHCoeffs[sh][arrIt] ), sizeof( double ) );
1257  }
1258  }
1259 
1260  //================================ Save RRP matrices values
1261  for ( unsigned int bnIt = 0; bnIt < two->_bandwidthLimit; bnIt++ )
1262  {
1263  if ( !two->_keepOrRemove ) { if ( ( bnIt % 2 ) != 0 ) { continue; } }
1264 
1265  for ( unsigned int sh1 = 0; sh1 < two->_noShellsWithData; sh1++ )
1266  {
1267  for ( unsigned int sh2 = 0; sh2 < two->_noShellsWithData; sh2++ )
1268  {
1269  dbFile.write ( reinterpret_cast<char*> ( &two->_rrpMatrices[bnIt][sh1][sh2] ), sizeof( double ) );
1270  }
1271  }
1272  }
1273 
1274  //================================ Save maps as well
1275  if ( two->_usePhase )
1276  {
1277  dbFile.write ( reinterpret_cast<char*> ( &two->_xFrom ), sizeof( double ) );
1278  dbFile.write ( reinterpret_cast<char*> ( &two->_xTo ), sizeof( double ) );
1279  dbFile.write ( reinterpret_cast<char*> ( &two->_yFrom ), sizeof( double ) );
1280  dbFile.write ( reinterpret_cast<char*> ( &two->_yTo ), sizeof( double ) );
1281  dbFile.write ( reinterpret_cast<char*> ( &two->_zFrom ), sizeof( double ) );
1282  dbFile.write ( reinterpret_cast<char*> ( &two->_zTo ), sizeof( double ) );
1283 
1284  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( two->_maxMapU * two->_maxMapV * two->_maxMapW ); mIt++ )
1285  {
1286  dbFile.write ( reinterpret_cast<char*> ( &two->_densityMapCor[mIt] ), sizeof( double ) );
1287  }
1288  }
1289 
1290  //==================================== Clean up
1291  delete two;
1292  }
1293 
1294  if ( settings->verbose > 3 )
1295  {
1296  std::cout << ">>>>> Structure saved." << std::endl;
1297  }
1298 
1299  if ( settings->htmlReport )
1300  {
1301  std::stringstream hlpSS;
1302  hlpSS << "<font color=\"green\">" << "File " << this->structFiles.at(iter) << " successfully saved to the database file." << "</font>";
1303  rvapi_set_text ( hlpSS.str().c_str(),
1304  "DBFilesSection",
1305  filesSectionIter,
1306  1,
1307  1,
1308  1 );
1309  filesSectionIter += 1;
1310 
1311  rvapi_flush ( );
1312  }
1313 
1314  //==================================== Clean up
1315  delete one;
1316  }
1317 
1318  if ( settings->htmlReport )
1319  {
1320  std::stringstream hlpSS;
1321  hlpSS << "<font color=\"green\">" << "File processing complete." << "</font>";
1322  rvapi_set_text ( hlpSS.str().c_str(),
1323  "ProgressSection",
1324  settings->htmlReportLineProgress,
1325  1,
1326  1,
1327  1 );
1328  settings->htmlReportLineProgress += 1;
1329 
1330  rvapi_flush ( );
1331  }
1332 
1333  //======================================== Close output file and done
1334  dbFile.close ( );
1335 
1336  //======================================== Done
1337  return ;
1338 }
1339 
1360  std::vector<std::string>* matchedStrNames )
1361 {
1362  //======================================== Local variables
1363  unsigned int hlpUInt, hlpUInt2;
1364  char* hlpChar;
1365  std::vector<std::string> dbStrNames;
1366  double minVol = 0.0;
1367 
1368  //======================================== Open the database file
1369  std::ifstream dbFile ( settings->databaseName, std::ios::in | std::ios::binary);
1370 
1371  //======================================== Check the database file
1372  if ( dbFile.fail() )
1373  {
1374  std::cerr << "!!! ProSHADE ERROR !!! Cannot open the database file for reading " << settings->databaseName << " . Terminating..." << std::endl;
1375 
1376  if ( settings->htmlReport )
1377  {
1378  std::stringstream hlpSS;
1379  hlpSS << "<font color=\"red\">" << "Cannot open database with name " << settings->databaseName << ". Could you have no permissions to write to the requested database location?" << "</font>";
1380  rvapi_set_text ( hlpSS.str().c_str(),
1381  "ProgressSection",
1382  settings->htmlReportLineProgress,
1383  1,
1384  1,
1385  1 );
1386  settings->htmlReportLineProgress += 1;
1387  rvapi_flush ( );
1388  }
1389 
1390  exit ( -1 );
1391  }
1392 
1393  if ( settings->verbose > 3 )
1394  {
1395  std::cout << ">>>>>>>> Database file opened." << std::endl;
1396  }
1397 
1398  if ( settings->htmlReport )
1399  {
1400  //==================================== Record progress
1401  std::stringstream hlpSS;
1402  hlpSS << "<font color=\"green\">" << "Database reading initiated." << "</font>";
1403  rvapi_set_text ( hlpSS.str().c_str(),
1404  "ProgressSection",
1405  settings->htmlReportLineProgress,
1406  1,
1407  1,
1408  1 );
1409  settings->htmlReportLineProgress += 1;
1410  rvapi_flush ( );
1411  }
1412 
1413  //======================================== Save the user input which is related to comparison and should not be loeaded from the database
1414  this->enLevelsThreshold = settings->enLevelsThreshold;
1415  this->trSigmaThreshold = settings->trSigmaThreshold;
1416 
1417  //======================================== Read in the database settings
1418  dbFile.read ( reinterpret_cast<char*> ( &minVol ), sizeof ( double ) );
1419  if ( minVol == 0.0 )
1420  {
1421  std::cerr << "!!! ProSHADE ERROR !!! The database file seems to be corrupted, or was produced with too small maximum allowed volume, as it is reporting minimal structure volume of 0.0 A. Terminating..." << std::endl;
1422 
1423  if ( settings->htmlReport )
1424  {
1425  std::stringstream hlpSS;
1426  hlpSS << "<font color=\"red\">" << "The database file seems to be corrupted, or was produced with too small maximum allowed volume, as it is reporting minimal structure volume of 0.0 A. If this problem is not solved by decreasing the maximum allowed volume, this could be internal bug, in this case please report it." << "</font>";
1427  rvapi_set_text ( hlpSS.str().c_str(),
1428  "ProgressSection",
1429  settings->htmlReportLineProgress,
1430  1,
1431  1,
1432  1 );
1433  settings->htmlReportLineProgress += 1;
1434  rvapi_flush ( );
1435  }
1436 
1437  exit ( -1 );
1438  }
1439 
1440  dbFile.read ( reinterpret_cast<char*> ( &settings->mapResolution ), sizeof ( double ) );
1441  dbFile.read ( reinterpret_cast<char*> ( &settings->bandwidth ), sizeof ( unsigned int ) );
1442  dbFile.read ( reinterpret_cast<char*> ( &settings->glIntegOrder ), sizeof ( unsigned int ) );
1443  dbFile.read ( reinterpret_cast<char*> ( &settings->theta ), sizeof ( unsigned int ) );
1444  dbFile.read ( reinterpret_cast<char*> ( &settings->phi ), sizeof ( unsigned int ) );
1445  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorValue ), sizeof ( double ) );
1446  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorChange ), sizeof ( double ) );
1447  dbFile.read ( reinterpret_cast<char*> ( &settings->noIQRsFromMap ), sizeof ( double ) );
1448  dbFile.read ( reinterpret_cast<char*> ( &settings->maskBlurFactor ), sizeof ( double ) );
1449  dbFile.read ( reinterpret_cast<char*> ( &settings->shellSpacing ), sizeof ( double ) );
1450  dbFile.read ( reinterpret_cast<char*> ( &settings->manualShells ), sizeof ( unsigned int ) );
1451  dbFile.read ( reinterpret_cast<char*> ( &settings->usePhase ), sizeof ( bool ) );
1452  dbFile.read ( reinterpret_cast<char*> ( &settings->saveWithAndWithout ), sizeof ( bool ) );
1453  dbFile.read ( reinterpret_cast<char*> ( &settings->useCOM ), sizeof ( bool ) );
1454  dbFile.read ( reinterpret_cast<char*> ( &settings->firstLineCOM ), sizeof ( bool ) );
1455  dbFile.read ( reinterpret_cast<char*> ( &settings->alpha ), sizeof ( double ) );
1456  dbFile.read ( reinterpret_cast<char*> ( &settings->mPower ), sizeof ( double ) );
1457 
1458  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1459  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
1460  {
1461  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
1462  settings->ignoreLs.emplace_back ( hlpUInt2 );
1463  }
1464 
1465  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1466  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
1467  {
1468  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
1469  hlpChar = new char[hlpUInt2+1];
1470  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt2 );
1471  hlpChar[hlpUInt2] = '\0';
1472  dbStrNames.emplace_back ( hlpChar );
1473  }
1474  dbFile.read ( reinterpret_cast<char*> ( &settings->peakHeightNoIQRs ), sizeof ( double ) );
1475  dbFile.read ( reinterpret_cast<char*> ( &settings->peakDistanceForReal ), sizeof ( double ) );
1476  dbFile.read ( reinterpret_cast<char*> ( &settings->peakSurroundingPoints ), sizeof ( int ) );
1477  dbFile.read ( reinterpret_cast<char*> ( &settings->aaErrorTolerance ), sizeof ( double ) );
1478  dbFile.read ( reinterpret_cast<char*> ( &settings->symGapTolerance ), sizeof ( double ) );
1479  dbFile.read ( reinterpret_cast<char*> ( &settings->energyLevelDist ), sizeof ( bool ) );
1480  dbFile.read ( reinterpret_cast<char*> ( &settings->traceSigmaDist ), sizeof ( bool ) );
1481  dbFile.read ( reinterpret_cast<char*> ( &settings->fullRotFnDist ), sizeof ( bool ) );
1482  dbFile.read ( reinterpret_cast<char*> ( &settings->enLevelsThreshold ), sizeof ( double ) );
1483  dbFile.read ( reinterpret_cast<char*> ( &settings->trSigmaThreshold ), sizeof ( double ) );
1484  dbFile.read ( reinterpret_cast<char*> ( &settings->taskToPerform ), sizeof ( ProSHADE::Task ) );
1485 
1486  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1487  hlpChar = new char[hlpUInt+1];
1488  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
1489  hlpChar[hlpUInt] = '\0';
1490  settings->clearMapFile = std::string ( hlpChar );
1491 
1492  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1493  hlpChar = new char[hlpUInt+1];
1494  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
1495  hlpChar[hlpUInt] = '\0';
1496  settings->mapFragName = std::string ( hlpChar );
1497 
1498  //======================================== Save the settings
1499  this->mapResolution = settings->mapResolution;
1500  this->bandwidth = settings->bandwidth;
1501  this->glIntegOrder = settings->glIntegOrder;
1502  this->theta = settings->theta;
1503  this->phi = settings->phi;
1504  this->bFactorValue = settings->bFactorValue;
1505  this->bFactorChange = settings->bFactorChange;
1506  this->noIQRsFromMap = settings->noIQRsFromMap;
1507  this->shellSpacing = settings->shellSpacing;
1508  this->manualShells = settings->manualShells;
1509  this->useCOM = settings->useCOM;
1510  this->firstLineCOM = settings->firstLineCOM;
1511  this->extraSpace = settings->extraSpace;
1512  this->alpha = settings->alpha;
1513  this->mPower = settings->mPower;
1514  this->ignoreLs = settings->ignoreLs;
1515  this->energyLevelDist = settings->energyLevelDist;
1516  this->traceSigmaDist = settings->traceSigmaDist;
1517  this->fullRotFnDist = settings->fullRotFnDist;
1518  this->usePhase = settings->usePhase;
1519  this->saveWithAndWithout = settings->saveWithAndWithout;
1520  this->structFiles = settings->structFiles;
1521 
1522  if ( settings->verbose > 3 )
1523  {
1524  std::cout << ">>>>>>>> Database settings loaded." << std::endl;
1525  }
1526 
1527  if ( settings->htmlReport )
1528  {
1529  //==================================== Record progress
1530  std::stringstream hlpSS;
1531  hlpSS << "<font color=\"green\">" << "Database settings read." << "</font>";
1532  rvapi_set_text ( hlpSS.str().c_str(),
1533  "ProgressSection",
1534  settings->htmlReportLineProgress,
1535  1,
1536  1,
1537  1 );
1538  settings->htmlReportLineProgress += 1;
1539  rvapi_flush ( );
1540  }
1541 
1542  //======================================== Now create the one strucutre, so that its dimmensions may be used for reducing the number of read structures
1543  ProSHADE_data* one = new ProSHADE_data ();
1544 
1545  //======================================== Read in into one
1546  matchedStrNames->clear ( );
1547  matchedStrNames->emplace_back ( structFiles.at(0) );
1548  unsigned int fileType = checkFileType ( structFiles.at(0) );
1549  if ( fileType == 2 )
1550  {
1551  one->getDensityMapFromMAP ( this->structFiles.at(0),
1552  &this->shellSpacing,
1553  this->mapResolution,
1554  &this->bandwidth,
1555  &this->theta,
1556  &this->phi,
1557  &this->glIntegOrder,
1558  &this->extraSpace,
1559  settings->mapResDefault,
1560  settings->rotChangeDefault,
1561  settings,
1562  settings->overlayDefaults );
1563  }
1564  else if ( fileType == 1 )
1565  {
1566  one->getDensityMapFromPDB ( this->structFiles.at(0),
1567  &this->shellSpacing,
1568  this->mapResolution,
1569  &this->bandwidth,
1570  &this->theta,
1571  &this->phi,
1572  &this->glIntegOrder,
1573  &this->extraSpace,
1574  settings->mapResDefault,
1575  settings,
1576  this->bFactorValue,
1577  this->firstLineCOM );
1578  }
1579  else
1580  {
1581  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(0) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
1582 
1583  if ( settings->htmlReport )
1584  {
1585  std::stringstream hlpSS;
1586  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(0) << " ." << "</font>";
1587  rvapi_set_text ( hlpSS.str().c_str(),
1588  "ProgressSection",
1589  settings->htmlReportLineProgress,
1590  1,
1591  1,
1592  1 );
1593  settings->htmlReportLineProgress += 1;
1594  rvapi_flush ( );
1595  }
1596 
1597  exit ( -1 );
1598  }
1599  if ( settings->verbose > 0 )
1600  {
1601  std::cout << "Structure 0 loaded." << std::endl;
1602  }
1603 
1604  if ( settings->htmlReport )
1605  {
1606  //==================================== Record progress
1607  std::stringstream hlpSS;
1608  hlpSS << "<font color=\"green\">" << "Sought structure loaded." << "</font>";
1609  rvapi_set_text ( hlpSS.str().c_str(),
1610  "ProgressSection",
1611  settings->htmlReportLineProgress,
1612  1,
1613  1,
1614  1 );
1615  settings->htmlReportLineProgress += 1;
1616  rvapi_flush ( );
1617  }
1618 
1619  //======================================== Deal with the centering and MAP data format, if applicable
1620  one->normaliseMap ( settings );
1621  if ( this->usePhase )
1622  {
1623  one->keepPhaseInMap ( this->alpha,
1624  this->bFactorChange,
1625  &this->bandwidth,
1626  &this->theta,
1627  &this->phi,
1628  &this->glIntegOrder,
1629  settings,
1630  this->useCOM,
1631  settings->noIQRsFromMap,
1632  settings->verbose,
1633  settings->clearMapData,
1634  settings->rotChangeDefault,
1635  settings->overlayDefaults,
1636  settings->maskBlurFactor,
1637  false );
1638  }
1639  else
1640  {
1641  one->removePhaseFromMap ( this->alpha,
1642  this->bFactorChange,
1643  settings );
1644  }
1645 
1646  //======================================== Map the density onto spheres
1647  one->mapPhaselessToSphere ( settings,
1648  this->theta,
1649  this->phi,
1650  this->shellSpacing,
1651  this->manualShells );
1652 
1653  //======================================== Compute the Spherical Harmonics (SH) coefficients
1654  one->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1655 
1656  //======================================== If required, pre-compute the energy levels distance descriptor
1657  if ( this->energyLevelDist )
1658  {
1659  one->precomputeRotInvDescriptor ( settings );
1660  }
1661  if ( settings->verbose > 3 )
1662  {
1663  std::cout << ">>>>>>>> Structure 0 spherical harmonics computed." << std::endl;
1664  }
1665 
1666  int structIterHTML = 0;
1667  if ( settings->htmlReport )
1668  {
1669  //==================================== Create section
1670  rvapi_add_section ( "FilesSection",
1671  "List of structures",
1672  "body",
1673  settings->htmlReportLine,
1674  0,
1675  1,
1676  1,
1677  false );
1678  settings->htmlReportLine += 1;
1679 
1680  std::stringstream hlpSS;
1681  hlpSS << "<font color=\"green\">" << "Structure to compare against the rest: " << this->structFiles.at(0) << "</font>";
1682  rvapi_set_text ( hlpSS.str().c_str(),
1683  "FilesSection",
1684  structIterHTML,
1685  1,
1686  1,
1687  1 );
1688  structIterHTML += 1;
1689 
1690  rvapi_flush ( );
1691  }
1692 
1693  //======================================== Read in the database data into ProSHADE_data objects
1694  double volTolerance = ( 1.0 - settings->volumeTolerance );
1695  double volMin = ( ( static_cast<double> ( (one->_xRange-this->extraSpace) ) * volTolerance ) *
1696  ( static_cast<double> ( (one->_yRange-this->extraSpace) ) * volTolerance ) *
1697  ( static_cast<double> ( (one->_zRange-this->extraSpace) ) * volTolerance ) );
1698  volTolerance = ( 1.0 + settings->volumeTolerance );
1699  double volMax = ( ( static_cast<double> ( (one->_xRange-this->extraSpace) ) * volTolerance ) *
1700  ( static_cast<double> ( (one->_yRange-this->extraSpace) ) * volTolerance ) *
1701  ( static_cast<double> ( (one->_zRange-this->extraSpace) ) * volTolerance ) );
1702  std::vector<ProSHADE_data*> dbData;
1703  bool foundAlready = false;
1704  bool tooFarAlready = false;
1705  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbStrNames.size() ); strIt++ )
1706  {
1707  if ( tooFarAlready ) { break; }
1708 
1709  if ( settings->verbose > 2 )
1710  {
1711  std::cout << ">>>>> Starting to load structure " << strIt+1 << " from the database." << std::endl;
1712  }
1713 
1714  if ( !this->saveWithAndWithout )
1715  {
1716  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings ) );
1717 
1718  if ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 )
1719  {
1720  if ( foundAlready ) { tooFarAlready = true; }
1721 
1722  dbData.pop_back ( );
1723  if ( settings->verbose > 0 )
1724  {
1725  std::cout << "Structure " << strIt+1 << " read from the database, but will not be used - too different dimmensions - see the \'--dbSizeLim\' option." << std::endl;
1726 
1727  if ( settings->htmlReport )
1728  {
1729  std::stringstream hlpSS;
1730  hlpSS << "<font color=\"orange\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be ignored." << "</font>";
1731  rvapi_set_text ( hlpSS.str().c_str(),
1732  "FilesSection",
1733  structIterHTML,
1734  1,
1735  1,
1736  1 );
1737  structIterHTML += 1;
1738  }
1739  }
1740  }
1741  else
1742  {
1743  foundAlready = true;
1744  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
1745  if ( settings->verbose > 0 )
1746  {
1747  std::cout << "Structure " << strIt+1 << " read from the database." << std::endl;
1748  }
1749 
1750  if ( settings->htmlReport )
1751  {
1752  std::stringstream hlpSS;
1753  hlpSS << "<font color=\"green\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be used." << "</font>";
1754  rvapi_set_text ( hlpSS.str().c_str(),
1755  "FilesSection",
1756  structIterHTML,
1757  1,
1758  1,
1759  1 );
1760  structIterHTML += 1;
1761  }
1762  }
1763  }
1764  else
1765  {
1766  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings, this->saveWithAndWithout ) );
1767  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings, this->saveWithAndWithout ) );
1768 
1769  if ( ( dbData.at(dbData.size()-2)->_mapResolution == -999.9 ) || ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 ) )
1770  {
1771  if ( foundAlready ) { tooFarAlready = true; }
1772 
1773  dbData.pop_back ( );
1774  dbData.pop_back ( );
1775  if ( settings->verbose > 0 )
1776  {
1777  std::cout << "Structure " << strIt+1 << " read from the database, but will not be used - too different dimmensions - see the \'--dbSizeLim\' option." << std::endl;
1778 
1779  if ( settings->htmlReport )
1780  {
1781  std::stringstream hlpSS;
1782  hlpSS << "<font color=\"orange\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be ignored." << "</font>";
1783  rvapi_set_text ( hlpSS.str().c_str(),
1784  "FilesSection",
1785  structIterHTML,
1786  1,
1787  1,
1788  1 );
1789  structIterHTML += 1;
1790  }
1791  }
1792  }
1793  else
1794  {
1795  foundAlready = true;
1796  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
1797  if ( settings->verbose > 0 )
1798  {
1799  std::cout << "Structure " << strIt+1 << " read from the database." << std::endl;
1800  }
1801 
1802  if ( settings->htmlReport )
1803  {
1804  std::stringstream hlpSS;
1805  hlpSS << "<font color=\"green\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be used." << "</font>";
1806  rvapi_set_text ( hlpSS.str().c_str(),
1807  "FilesSection",
1808  structIterHTML,
1809  1,
1810  1,
1811  1 );
1812  structIterHTML += 1;
1813  }
1814  }
1815  }
1816  }
1817 
1818  if ( settings->htmlReport )
1819  {
1820  //==================================== Record progress
1821  std::stringstream hlpSS;
1822  hlpSS << "<font color=\"green\">" << "Database imported." << "</font>";
1823  rvapi_set_text ( hlpSS.str().c_str(),
1824  "ProgressSection",
1825  settings->htmlReportLineProgress,
1826  1,
1827  1,
1828  1 );
1829  settings->htmlReportLineProgress += 1;
1830  rvapi_flush ( );
1831  }
1832 
1833  //======================================== Check for not finding any size matches
1834  if ( dbData.size() == 0 )
1835  {
1836  std::cout << "!!! ProSHADE WARNING !!! There was no database entry which would pass the size limitations and therefore cannot compute distances. This could be caused by submitting database file with small number or very narrowly distributed structure sizes. Alternatively, the size limit parameter ( \'--dbSizeLim\' ) could be set to too constricted values (or the default values are sub-optimal for this case). Now terminating..." << std::endl;
1837 
1838  if ( settings->htmlReport )
1839  {
1840  std::stringstream hlpSS;
1841  hlpSS << "<font color=\"orange\">" << "There was no database entry which would pass the size limitations and therefore cannot compute distances. This could be caused by submitting database file with small number or very narrowly distributed structure sizes. Alternatively, the size limit parameter ( \'--dbSizeLim\' ) could be set to too constricted values (or the default values are sub-optimal for this case)." << "</font>";
1842  rvapi_set_text ( hlpSS.str().c_str(),
1843  "ProgressSection",
1844  settings->htmlReportLineProgress,
1845  1,
1846  1,
1847  1 );
1848  settings->htmlReportLineProgress += 1;
1849  rvapi_flush ( );
1850  }
1851 
1852  exit ( 0 );
1853  }
1854 
1855  //======================================== Now create the two strucutre in case it is being used with both phase and reverse phase
1856  ProSHADE_data* two = new ProSHADE_data ();
1857 
1858  //======================================== Create the compare against all object
1859  if ( !this->saveWithAndWithout )
1860  {
1861  this->cmpObj = new ProSHADE_compareOneAgainstAll ( one, &dbData, this->ignoreLs, this->mPower, settings->verbose );
1862  }
1863  else
1864  {
1865  //==================================== Read in into one
1866  fileType = checkFileType ( structFiles.at(0) );
1867  if ( fileType == 2 )
1868  {
1869  two->getDensityMapFromMAP ( this->structFiles.at(0),
1870  &this->shellSpacing,
1871  this->mapResolution,
1872  &this->bandwidth,
1873  &this->theta,
1874  &this->phi,
1875  &this->glIntegOrder,
1876  &this->extraSpace,
1877  settings->mapResDefault,
1878  settings->rotChangeDefault,
1879  settings,
1880  settings->overlayDefaults );
1881  }
1882  else if ( fileType == 1 )
1883  {
1884  two->getDensityMapFromPDB ( this->structFiles.at(0),
1885  &this->shellSpacing,
1886  this->mapResolution,
1887  &this->bandwidth,
1888  &this->theta,
1889  &this->phi,
1890  &this->glIntegOrder,
1891  &this->extraSpace,
1892  settings->mapResDefault,
1893  settings,
1894  this->bFactorValue,
1895  this->firstLineCOM );
1896  }
1897  else
1898  {
1899  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(0) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
1900  exit (0);
1901  }
1902 
1903  //==================================== Deal with the centering and MAP data format, if applicable
1904  two->normaliseMap ( settings );
1905  if ( !this->usePhase )
1906  {
1907  two->keepPhaseInMap ( this->alpha,
1908  this->bFactorChange,
1909  &this->bandwidth,
1910  &this->theta,
1911  &this->phi,
1912  &this->glIntegOrder,
1913  settings,
1914  this->useCOM,
1915  settings->noIQRsFromMap,
1916  settings->verbose,
1917  settings->clearMapData,
1918  settings->rotChangeDefault,
1919  settings->overlayDefaults,
1920  settings->maskBlurFactor,
1921  false );
1922  }
1923  else
1924  {
1925  two->removePhaseFromMap ( this->alpha,
1926  this->bFactorChange,
1927  settings );
1928  }
1929 
1930  //==================================== Map the density onto spheres
1931  two->mapPhaselessToSphere ( settings,
1932  this->theta,
1933  this->phi,
1934  this->shellSpacing,
1935  this->manualShells,
1936  true );
1937 
1938  //==================================== Compute the Spherical Harmonics (SH) coefficients
1939  two->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1940 
1941  //==================================== If required, pre-compute the energy levels distance descriptor
1942  if ( this->energyLevelDist )
1943  {
1944  two->precomputeRotInvDescriptor ( settings );
1945  }
1946  if ( settings->verbose > 3 )
1947  {
1948  std::cout << ">>>>>>>> Structure 0 spherical harmonics computed (reverse phase)." << std::endl;
1949  }
1950 
1951  this->cmpObj = new ProSHADE_compareOneAgainstAll ( one, two, &dbData, this->ignoreLs, this->mPower, settings->verbose );
1952  }
1953 
1954  //======================================== Save the decision whether to use phases or not
1955  if ( one->_keepOrRemove ) { this->cmpObj->_keepOrRemove = true; }
1956  else { this->cmpObj->_keepOrRemove = false; }
1957 
1958  //======================================== If using both phased and reverse, compute the translated and rotated versions
1959  if ( this->saveWithAndWithout )
1960  {
1961  this->cmpObj->alignDensities ( settings );
1962  }
1963 
1964  //======================================== If required, compute the energy levels distances
1965  if ( this->energyLevelDist )
1966  {
1967  if ( settings->verbose > 0 )
1968  {
1969  std::cout << "Computing the cross-correlation distances." << std::endl;
1970  }
1971  if ( settings->htmlReport )
1972  {
1973  //==================================== Record progress
1974  std::stringstream hlpSS;
1975  hlpSS << "<font color=\"green\">" << "Computing the Energy Level distances." << "</font>";
1976  rvapi_set_text ( hlpSS.str().c_str(),
1977  "ProgressSection",
1978  settings->htmlReportLineProgress,
1979  1,
1980  1,
1981  1 );
1982  settings->htmlReportLineProgress += 1;
1983  rvapi_flush ( );
1984  }
1985 
1986  this->energyLevelsDistances = this->cmpObj->getEnergyLevelsDistance ( settings->verbose, settings );
1987 
1988  // ... and set which pairs not to follow further
1989  if ( this->enLevelsThreshold != -999.9 )
1990  {
1991  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
1992  {
1993  if ( this->enLevelsThreshold > this->energyLevelsDistances.at(iter) )
1994  {
1995  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 1 );
1996  }
1997  else
1998  {
1999  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2000  }
2001  }
2002  }
2003  else
2004  {
2005  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
2006  {
2007  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2008  }
2009  }
2010  }
2011  else
2012  {
2013  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
2014  {
2015  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2016  }
2017  }
2018 
2019  //======================================== Remove all structures with null pointer (i.e. those not passing the size test)
2020  this->glIntegOrderVec = std::vector<unsigned int> ( dbData.size() + 1 );
2021  this->glIntegOrderVec.at(0) = this->glIntegOrder;
2022  double distPerPointFraction = 0.0;
2023  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbData.size() ); strIt++ )
2024  {
2025  distPerPointFraction = ( ( dbData.at(strIt)->_maxMapRange / 2.0 ) / static_cast<double> ( dbData.at(strIt)->_bandwidthLimit / 2 ) ) / ( dbData.at(strIt)->_maxMapRange / 2.0 );
2026 
2027  for ( unsigned int iter = 2; iter < static_cast<unsigned int> ( ProSHADE_internal_misc::glIntMaxDists.size() ); iter++ )
2028  {
2029  if ( ProSHADE_internal_misc::glIntMaxDists.at(iter) >= distPerPointFraction )
2030  {
2031  this->glIntegOrderVec.at(strIt+1) = iter;
2032  }
2033  }
2034  }
2035 
2036  //======================================== Pre-compute the E matrices in case either the trace sigmal or full rotation distance are required
2037  if ( this->traceSigmaDist || this->fullRotFnDist )
2038  {
2039  this->cmpObj->precomputeTrSigmaDescriptor ( this->shellSpacing, &this->glIntegOrderVec, settings );
2040  }
2041 
2042  //======================================== Compute the trace sigma distances, if required
2043  if ( this->traceSigmaDist )
2044  {
2045  if ( settings->verbose > 0 )
2046  {
2047  std::cout << "Computing the trace sigma distances." << std::endl;
2048  }
2049  if ( settings->htmlReport )
2050  {
2051  //==================================== Record progress
2052  std::stringstream hlpSS;
2053  hlpSS << "<font color=\"green\">" << "Computing Trace Sigma distances." << "</font>";
2054  rvapi_set_text ( hlpSS.str().c_str(),
2055  "ProgressSection",
2056  settings->htmlReportLineProgress,
2057  1,
2058  1,
2059  1 );
2060  settings->htmlReportLineProgress += 1;
2061  rvapi_flush ( );
2062  }
2063 
2064  this->traceSigmaDistances = this->cmpObj->getTrSigmaDistance ( settings->verbose, settings );
2065 
2066  if ( this->trSigmaThreshold == -999.9 )
2067  {
2068  this->cmpObj->_trSigmaDoNotFollow = this->cmpObj->_enLevelsDoNotFollow;
2069  }
2070  else
2071  {
2072  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
2073  {
2074  if ( this->trSigmaThreshold > this->traceSigmaDistances.at(iter) )
2075  {
2076  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 1 );
2077  }
2078  else
2079  {
2080  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
2081  }
2082  }
2083  }
2084  }
2085 
2086  //======================================== If full rotation distance is required, pre-compute the requirements
2087  if ( this->fullRotFnDist )
2088  {
2089  this->cmpObj->getSO3InverseMap ( settings );
2090  if ( settings->verbose > 1 )
2091  {
2092  std::cout << ">> Inverse SO(3) Fourier transform map computed." << std::endl;
2093  }
2094 
2095  this->cmpObj->getEulerAngles ( settings );
2096  if ( settings->verbose > 2 )
2097  {
2098  std::cout << ">>>>> Optimal Euler angles obtained." << std::endl;
2099  }
2100 
2101  this->cmpObj->generateWignerMatrices ( settings );
2102  if ( settings->verbose > 1 )
2103  {
2104  std::cout << ">> Wigner matrices calculated." << std::endl;
2105  }
2106 
2107  if ( settings->verbose > 0 )
2108  {
2109  std::cout << "Computing the rotation function distances." << std::endl;
2110  }
2111  if ( settings->htmlReport )
2112  {
2113  //==================================== Record progress
2114  std::stringstream hlpSS;
2115  hlpSS << "<font color=\"green\">" << "Computing Rotation Function distances." << "</font>";
2116  rvapi_set_text ( hlpSS.str().c_str(),
2117  "ProgressSection",
2118  settings->htmlReportLineProgress,
2119  1,
2120  1,
2121  1 );
2122  settings->htmlReportLineProgress += 1;
2123  rvapi_flush ( );
2124  }
2125 
2126  this->fullRotationDistances = this->cmpObj->getRotCoeffDistance ( settings->verbose, settings );
2127  }
2128 
2129  //======================================== Delete database entries
2130  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( iter ); iter++ )
2131  {
2132  if ( dbData.at(iter) != nullptr )
2133  {
2134  delete dbData.at(iter);
2135  dbData.at(iter) = nullptr;
2136  }
2137  }
2138  dbData.clear ( );
2139 
2140  //======================================== Done
2141  return ;
2142 }
2143 
2155  std::vector<std::string>* matchedStrNames )
2156 {
2157  //======================================== Local variables
2158  unsigned int hlpUInt, hlpUInt2;
2159  char* hlpChar;
2160  std::vector<std::string> dbStrNames;
2161  double minVol = 0.0;
2162 
2163  if ( settings->verbose > 0 )
2164  {
2165  std::cout << "Computing distances between map fragments and the structure database." << std::endl;
2166  }
2167 
2168  //======================================== Open the database file
2169  std::ifstream dbFile ( settings->databaseName, std::ios::in | std::ios::binary);
2170 
2171  //======================================== Check the database file
2172  if ( dbFile.fail() )
2173  {
2174  std::cerr << "!!! ProSHADE ERROR !!! Cannot open the database file for reading " << settings->databaseName << " . Terminating..." << std::endl;
2175 
2176  if ( settings->htmlReport )
2177  {
2178  std::stringstream hlpSS;
2179  hlpSS << "<font color=\"red\">" << "Cannot open database with name " << settings->databaseName << ". Could you have no permissions to write to the requested database location?" << "</font>";
2180  rvapi_set_text ( hlpSS.str().c_str(),
2181  "ProgressSection",
2182  settings->htmlReportLineProgress,
2183  1,
2184  1,
2185  1 );
2186  settings->htmlReportLineProgress += 1;
2187  rvapi_flush ( );
2188  }
2189 
2190  exit ( -1 );
2191  }
2192 
2193  //======================================== Check fragmentation settings
2194  if ( settings->mapFragBoxSize == 0.0 )
2195  {
2196  std::cerr << "!!! ProSHADE ERROR !!! Requested fragmentation database comparison, but you did not supply the fragmentation box size - use the '--mFrag' option to set this. Terminating..." << std::endl;
2197 
2198  if ( settings->htmlReport )
2199  {
2200  std::stringstream hlpSS;
2201  hlpSS << "<font color=\"red\">" << "Missing the mandatory argument determining the fragmentation box size. Please supply it using the --mFrag command line option." << "</font>";
2202  rvapi_set_text ( hlpSS.str().c_str(),
2203  "ProgressSection",
2204  settings->htmlReportLineProgress,
2205  1,
2206  1,
2207  1 );
2208  settings->htmlReportLineProgress += 1;
2209  rvapi_flush ( );
2210  }
2211 
2212  exit ( -1 );
2213  }
2214  if ( !settings->usePhase )
2215  {
2216  std::cerr << "!!! ProSHADE ERROR !!! Requested map fragmentation without using phases - this does not make sense. Terminating..." << std::endl;
2217 
2218  if ( settings->htmlReport )
2219  {
2220  std::stringstream hlpSS;
2221  hlpSS << "<font color=\"red\">" << "Requested map fragmentation without using phases. This is not allowed." << "</font>";
2222  rvapi_set_text ( hlpSS.str().c_str(),
2223  "ProgressSection",
2224  settings->htmlReportLineProgress,
2225  1,
2226  1,
2227  1 );
2228  settings->htmlReportLineProgress += 1;
2229  rvapi_flush ( );
2230  }
2231 
2232  exit ( -1 );
2233  }
2234 
2235  if ( settings->verbose > 3 )
2236  {
2237  std::cout << ">>>>>>>> Database file opened for reading." << std::endl;
2238  }
2239 
2240  if ( settings->htmlReport )
2241  {
2242  std::stringstream hlpSS;
2243  hlpSS << "<font color=\"green\">" << "Database reading intialisation complete." << "</font>";
2244  rvapi_set_text ( hlpSS.str().c_str(),
2245  "ProgressSection",
2246  settings->htmlReportLineProgress,
2247  1,
2248  1,
2249  1 );
2250  settings->htmlReportLineProgress += 1;
2251 
2252  rvapi_flush ( );
2253  }
2254 
2255  //======================================== Save the user input which is related to comparison and should not be loeaded from the database
2256  this->enLevelsThreshold = settings->enLevelsThreshold;
2257  this->trSigmaThreshold = settings->trSigmaThreshold;
2258 
2259  //======================================== Set internal user settings
2260  bool userCOM = false;
2261  if ( settings->useCOM == true ) { userCOM = true; }
2262 
2263  //======================================== Read in the database settings
2264  dbFile.read ( reinterpret_cast<char*> ( &minVol ), sizeof ( double ) );
2265  if ( minVol == 0.0 )
2266  {
2267  std::cerr << "!!! ProSHADE ERROR !!! The database file seems to be corrupted, or was produced with too small maximum allowed volume, as it is reporting minimal structure volume of 0.0 A. Terminating..." << std::endl;
2268 
2269  if ( settings->htmlReport )
2270  {
2271  std::stringstream hlpSS;
2272  hlpSS << "<font color=\"red\">" << "The database file seems to be corrupted, or was produced with too small maximum allowed volume, as it is reporting minimal structure volume of 0.0 A. If this problem is not solved by decreasing the maximum allowed volume, this could be internal bug, in this case please report it." << "</font>";
2273  rvapi_set_text ( hlpSS.str().c_str(),
2274  "ProgressSection",
2275  settings->htmlReportLineProgress,
2276  1,
2277  1,
2278  1 );
2279  settings->htmlReportLineProgress += 1;
2280  rvapi_flush ( );
2281  }
2282 
2283  exit ( -1 );
2284  }
2285 
2286  dbFile.read ( reinterpret_cast<char*> ( &settings->mapResolution ), sizeof ( double ) );
2287  dbFile.read ( reinterpret_cast<char*> ( &settings->bandwidth ), sizeof ( unsigned int ) );
2288  dbFile.read ( reinterpret_cast<char*> ( &settings->glIntegOrder ), sizeof ( unsigned int ) );
2289  dbFile.read ( reinterpret_cast<char*> ( &settings->theta ), sizeof ( unsigned int ) );
2290  dbFile.read ( reinterpret_cast<char*> ( &settings->phi ), sizeof ( unsigned int ) );
2291  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorValue ), sizeof ( double ) );
2292  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorChange ), sizeof ( double ) );
2293  dbFile.read ( reinterpret_cast<char*> ( &settings->noIQRsFromMap ), sizeof ( double ) );
2294  dbFile.read ( reinterpret_cast<char*> ( &settings->maskBlurFactor ), sizeof ( double ) );
2295  dbFile.read ( reinterpret_cast<char*> ( &settings->shellSpacing ), sizeof ( double ) );
2296  dbFile.read ( reinterpret_cast<char*> ( &settings->manualShells ), sizeof ( unsigned int ) );
2297  dbFile.read ( reinterpret_cast<char*> ( &settings->usePhase ), sizeof ( bool ) );
2298  dbFile.read ( reinterpret_cast<char*> ( &settings->saveWithAndWithout ), sizeof ( bool ) );
2299  dbFile.read ( reinterpret_cast<char*> ( &settings->useCOM ), sizeof ( bool ) );
2300  dbFile.read ( reinterpret_cast<char*> ( &settings->firstLineCOM ), sizeof ( bool ) );
2301  dbFile.read ( reinterpret_cast<char*> ( &settings->alpha ), sizeof ( double ) );
2302  dbFile.read ( reinterpret_cast<char*> ( &settings->mPower ), sizeof ( double ) );
2303 
2304  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2305  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
2306  {
2307  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
2308  settings->ignoreLs.emplace_back ( hlpUInt2 );
2309  }
2310 
2311  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2312  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
2313  {
2314  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
2315  hlpChar = new char[hlpUInt2+1];
2316  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt2 );
2317  hlpChar[hlpUInt2] = '\0';
2318  dbStrNames.emplace_back ( hlpChar );
2319  }
2320  dbFile.read ( reinterpret_cast<char*> ( &settings->peakHeightNoIQRs ), sizeof ( double ) );
2321  dbFile.read ( reinterpret_cast<char*> ( &settings->peakDistanceForReal ), sizeof ( double ) );
2322  dbFile.read ( reinterpret_cast<char*> ( &settings->peakSurroundingPoints ), sizeof ( int ) );
2323  dbFile.read ( reinterpret_cast<char*> ( &settings->aaErrorTolerance ), sizeof ( double ) );
2324  dbFile.read ( reinterpret_cast<char*> ( &settings->symGapTolerance ), sizeof ( double ) );
2325  dbFile.read ( reinterpret_cast<char*> ( &settings->energyLevelDist ), sizeof ( bool ) );
2326  dbFile.read ( reinterpret_cast<char*> ( &settings->traceSigmaDist ), sizeof ( bool ) );
2327  dbFile.read ( reinterpret_cast<char*> ( &settings->fullRotFnDist ), sizeof ( bool ) );
2328  dbFile.read ( reinterpret_cast<char*> ( &settings->enLevelsThreshold ), sizeof ( double ) );
2329  dbFile.read ( reinterpret_cast<char*> ( &settings->trSigmaThreshold ), sizeof ( double ) );
2330  dbFile.read ( reinterpret_cast<char*> ( &settings->taskToPerform ), sizeof ( ProSHADE::Task ) );
2331 
2332  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2333  hlpChar = new char[hlpUInt+1];
2334  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
2335  hlpChar[hlpUInt] = '\0';
2336  settings->clearMapFile = std::string ( hlpChar );
2337 
2338  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2339  hlpChar = new char[hlpUInt+1];
2340  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
2341  hlpChar[hlpUInt] = '\0';
2342  settings->mapFragName = std::string ( hlpChar );
2343 
2344  if ( settings->verbose > 1 )
2345  {
2346  std::cout << ">> Database settings loaded." << std::endl;
2347  }
2348 
2349  if ( settings->htmlReport )
2350  {
2351  std::stringstream hlpSS;
2352  hlpSS << "<font color=\"green\">" << "Database settings loaded." << "</font>";
2353  rvapi_set_text ( hlpSS.str().c_str(),
2354  "ProgressSection",
2355  settings->htmlReportLineProgress,
2356  1,
2357  1,
2358  1 );
2359  settings->htmlReportLineProgress += 1;
2360 
2361  rvapi_flush ( );
2362  }
2363 
2364  //======================================== Save the settings
2365  this->mapResolution = settings->mapResolution;
2366  this->bandwidth = settings->bandwidth;
2367  this->glIntegOrder = settings->glIntegOrder;
2368  this->theta = settings->theta;
2369  this->phi = settings->phi;
2370  this->bFactorValue = settings->bFactorValue;
2371  this->bFactorChange = settings->bFactorChange;
2372  this->noIQRsFromMap = settings->noIQRsFromMap;
2373  this->shellSpacing = settings->shellSpacing;
2374  this->manualShells = settings->manualShells;
2375  this->useCOM = settings->useCOM;
2376  this->firstLineCOM = settings->firstLineCOM;
2377  this->extraSpace = settings->extraSpace;
2378  this->alpha = settings->alpha;
2379  this->mPower = settings->mPower;
2380  this->ignoreLs = settings->ignoreLs;
2381  this->energyLevelDist = settings->energyLevelDist;
2382  this->traceSigmaDist = settings->traceSigmaDist;
2383  this->fullRotFnDist = settings->fullRotFnDist;
2384  this->usePhase = settings->usePhase;
2385  this->saveWithAndWithout = settings->saveWithAndWithout;
2386  this->structFiles = settings->structFiles;
2387 
2388  if ( settings->htmlReport )
2389  {
2390  //==================================== Create section
2391  rvapi_add_section ( "DBSettingsSection",
2392  "Database Settings",
2393  "body",
2394  settings->htmlReportLine,
2395  0,
2396  1,
2397  1,
2398  false );
2399  settings->htmlReportLine += 1;
2400 
2401  std::stringstream hlpSS;
2402  hlpSS << "<pre>" << "Map resolution: ";
2403  int hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2404  for ( int iter = 0; iter < hlpIt; iter++ )
2405  {
2406  hlpSS << ".";
2407  }
2408 
2409  std::stringstream hlpSS2;
2410  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mapResolution * 1000.0 ) / 1000.0;
2411  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2412  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2413  hlpSS << " " << hlpSS2.str() << "</pre>";
2414 
2415  rvapi_set_text ( hlpSS.str().c_str(),
2416  "DBSettingsSection",
2417  0,
2418  0,
2419  1,
2420  1 );
2421 
2422  hlpSS.str ( std::string ( ) );
2423  hlpSS << "<pre>" << "Bandwidth: ";
2424  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2425  for ( int iter = 0; iter < hlpIt; iter++ )
2426  {
2427  hlpSS << ".";
2428  }
2429 
2430  hlpSS2.str ( std::string ( ) );
2431  if ( this->bandwidth == 0 ) { hlpSS2 << " AUTO"; }
2432  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bandwidth * 1000.0 ) / 1000.0; }
2433  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2434  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2435  hlpSS << " " << hlpSS2.str() << "</pre>";
2436 
2437  rvapi_set_text ( hlpSS.str().c_str(),
2438  "DBSettingsSection",
2439  1,
2440  0,
2441  1,
2442  1 );
2443 
2444  hlpSS.str ( std::string ( ) );
2445  hlpSS << "<pre>" << "Gauss-Legendre Integration order: ";
2446  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2447  for ( int iter = 0; iter < hlpIt; iter++ )
2448  {
2449  hlpSS << ".";
2450  }
2451 
2452  hlpSS2.str ( std::string ( ) );
2453  if ( this->glIntegOrder == 0 ) { hlpSS2 << " AUTO"; }
2454  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->glIntegOrder * 1000.0 ) / 1000.0; }
2455  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2456  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2457  hlpSS << " " << hlpSS2.str() << "</pre>";
2458 
2459  rvapi_set_text ( hlpSS.str().c_str(),
2460  "DBSettingsSection",
2461  2,
2462  0,
2463  1,
2464  1 );
2465 
2466  hlpSS.str ( std::string ( ) );
2467  hlpSS << "<pre>" << "Theta angle sampling: ";
2468  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2469  for ( int iter = 0; iter < hlpIt; iter++ )
2470  {
2471  hlpSS << ".";
2472  }
2473 
2474  hlpSS2.str ( std::string ( ) );
2475  if ( this->theta == 0 ) { hlpSS2 << " AUTO"; }
2476  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->theta * 1000.0 ) / 1000.0; }
2477  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2478  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2479  hlpSS << " " << hlpSS2.str() << "</pre>";
2480 
2481  rvapi_set_text ( hlpSS.str().c_str(),
2482  "DBSettingsSection",
2483  3,
2484  0,
2485  1,
2486  1 );
2487 
2488  hlpSS.str ( std::string ( ) );
2489  hlpSS << "<pre>" << "Phi angle sampling: ";
2490  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2491  for ( int iter = 0; iter < hlpIt; iter++ )
2492  {
2493  hlpSS << ".";
2494  }
2495 
2496  hlpSS2.str ( std::string ( ) );
2497  if ( this->phi == 0 ) { hlpSS2 << " AUTO"; }
2498  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->phi * 1000.0 ) / 1000.0; }
2499  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2500  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2501  hlpSS << " " << hlpSS2.str() << "</pre>";
2502 
2503  rvapi_set_text ( hlpSS.str().c_str(),
2504  "DBSettingsSection",
2505  4,
2506  0,
2507  1,
2508  1 );
2509 
2510  hlpSS.str ( std::string ( ) );
2511  hlpSS << "<pre>" << "Set all PDB file B-factors to: ";
2512  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2513  for ( int iter = 0; iter < hlpIt; iter++ )
2514  {
2515  hlpSS << ".";
2516  }
2517 
2518  hlpSS2.str ( std::string ( ) );
2519  if ( this->bFactorValue == 0 ) { hlpSS2 << " AUTO"; }
2520  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorValue * 1000.0 ) / 1000.0; }
2521  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2522  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2523  hlpSS << " " << hlpSS2.str() << "</pre>";
2524 
2525  rvapi_set_text ( hlpSS.str().c_str(),
2526  "DBSettingsSection",
2527  5,
2528  0,
2529  1,
2530  1 );
2531 
2532  hlpSS.str ( std::string ( ) );
2533  hlpSS << "<pre>" << "Change B-factors after map computation by: ";
2534  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2535  for ( int iter = 0; iter < hlpIt; iter++ )
2536  {
2537  hlpSS << ".";
2538  }
2539 
2540  hlpSS2.str ( std::string ( ) );
2541  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorChange * 1000.0 ) / 1000.0;
2542  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2543  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2544  hlpSS << " " << hlpSS2.str() << "</pre>";
2545 
2546  rvapi_set_text ( hlpSS.str().c_str(),
2547  "DBSettingsSection",
2548  6,
2549  0,
2550  1,
2551  1 );
2552 
2553  hlpSS.str ( std::string ( ) );
2554  hlpSS << "<pre>" << "Map IQR from median threshold: ";
2555  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2556  for ( int iter = 0; iter < hlpIt; iter++ )
2557  {
2558  hlpSS << ".";
2559  }
2560 
2561  hlpSS2.str ( std::string ( ) );
2562  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->noIQRsFromMap * 1000.0 ) / 1000.0;
2563  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2564  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2565  hlpSS << " " << hlpSS2.str() << "</pre>";
2566 
2567  rvapi_set_text ( hlpSS.str().c_str(),
2568  "DBSettingsSection",
2569  7,
2570  0,
2571  1,
2572  1 );
2573 
2574  hlpSS.str ( std::string ( ) );
2575  hlpSS << "<pre>" << "Distance between shells: ";
2576  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2577  for ( int iter = 0; iter < hlpIt; iter++ )
2578  {
2579  hlpSS << ".";
2580  }
2581 
2582  hlpSS2.str ( std::string ( ) );
2583  if ( this->shellSpacing == 0 ) { hlpSS2 << " AUTO"; }
2584  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->shellSpacing * 1000.0 ) / 1000.0; }
2585  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2586  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2587  hlpSS << " " << hlpSS2.str() << "</pre>";
2588 
2589  rvapi_set_text ( hlpSS.str().c_str(),
2590  "DBSettingsSection",
2591  8,
2592  0,
2593  1,
2594  1 );
2595 
2596  hlpSS.str ( std::string ( ) );
2597  hlpSS << "<pre>" << "Number of shells: ";
2598  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2599  for ( int iter = 0; iter < hlpIt; iter++ )
2600  {
2601  hlpSS << ".";
2602  }
2603 
2604  hlpSS2.str ( std::string ( ) );
2605  if ( this->manualShells == 0 ) { hlpSS2 << " AUTO"; }
2606  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->manualShells * 1000.0 ) / 1000.0; }
2607  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2608  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2609  hlpSS << " " << hlpSS2.str() << "</pre>";
2610 
2611  rvapi_set_text ( hlpSS.str().c_str(),
2612  "DBSettingsSection",
2613  9,
2614  0,
2615  1,
2616  1 );
2617 
2618  hlpSS.str ( std::string ( ) );
2619  hlpSS << "<pre>" << "Use Centre of Mass for centering: ";
2620  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2621  for ( int iter = 0; iter < hlpIt; iter++ )
2622  {
2623  hlpSS << ".";
2624  }
2625 
2626  hlpSS2.str ( std::string ( ) );
2627  if ( this->useCOM == 0 ) { hlpSS2 << " FALSE"; }
2628  else { hlpSS2 << " TRUE"; }
2629  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2630  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2631  hlpSS << " " << hlpSS2.str() << "</pre>";
2632 
2633  rvapi_set_text ( hlpSS.str().c_str(),
2634  "DBSettingsSection",
2635  10,
2636  0,
2637  1,
2638  1 );
2639 
2640  hlpSS.str ( std::string ( ) );
2641  hlpSS << "<pre>" << "Add extra space to cell: ";
2642  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2643  for ( int iter = 0; iter < hlpIt; iter++ )
2644  {
2645  hlpSS << ".";
2646  }
2647 
2648  hlpSS2.str ( std::string ( ) );
2649  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->extraSpace * 1000.0 ) / 1000.0;
2650  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2651  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2652  hlpSS << " " << hlpSS2.str() << "</pre>";
2653 
2654  rvapi_set_text ( hlpSS.str().c_str(),
2655  "DBSettingsSection",
2656  11,
2657  0,
2658  1,
2659  1 );
2660 
2661  hlpSS.str ( std::string ( ) );
2662  hlpSS << "<pre>" << "Raise Fourier coefficients to power: ";
2663  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2664  for ( int iter = 0; iter < hlpIt; iter++ )
2665  {
2666  hlpSS << ".";
2667  }
2668 
2669  hlpSS2.str ( std::string ( ) );
2670  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->alpha * 1000.0 ) / 1000.0;
2671  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2672  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2673  hlpSS << " " << hlpSS2.str() << "</pre>";
2674 
2675  rvapi_set_text ( hlpSS.str().c_str(),
2676  "DBSettingsSection",
2677  12,
2678  0,
2679  1,
2680  1 );
2681 
2682  hlpSS.str ( std::string ( ) );
2683  hlpSS << "<pre>" << "Weight Energy Level matrix position by: ";
2684  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2685  for ( int iter = 0; iter < hlpIt; iter++ )
2686  {
2687  hlpSS << ".";
2688  }
2689 
2690  hlpSS2.str ( std::string ( ) );
2691  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mPower * 1000.0 ) / 1000.0;
2692  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2693  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2694  hlpSS << " " << hlpSS2.str() << "</pre>";
2695 
2696  rvapi_set_text ( hlpSS.str().c_str(),
2697  "DBSettingsSection",
2698  13,
2699  0,
2700  1,
2701  1 );
2702 
2703  hlpSS.str ( std::string ( ) );
2704  hlpSS << "<pre>" << "Ignore the following bands: ";
2705  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2706  for ( int iter = 0; iter < hlpIt; iter++ )
2707  {
2708  hlpSS << ".";
2709  }
2710 
2711  hlpSS2.str ( std::string ( ) );
2712  for ( int iter = 0; iter < static_cast<int> ( this->ignoreLs.size() ); iter++ )
2713  {
2714  hlpSS2 << std::showpos << this->ignoreLs.at(iter) << " ";
2715  }
2716  hlpSS << " " << hlpSS2.str() << "</pre>";
2717 
2718  rvapi_set_text ( hlpSS.str().c_str(),
2719  "DBSettingsSection",
2720  14,
2721  0,
2722  1,
2723  1 );
2724 
2725  hlpSS.str ( std::string ( ) );
2726  hlpSS << "<pre>" << "Compute Energy Level distances: ";
2727  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2728  for ( int iter = 0; iter < hlpIt; iter++ )
2729  {
2730  hlpSS << ".";
2731  }
2732 
2733  hlpSS2.str ( std::string ( ) );
2734  if ( this->energyLevelDist == 0 ) { hlpSS2 << " FALSE"; }
2735  else { hlpSS2 << " TRUE"; }
2736  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2737  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2738  hlpSS << " " << hlpSS2.str() << "</pre>";
2739 
2740  rvapi_set_text ( hlpSS.str().c_str(),
2741  "DBSettingsSection",
2742  15,
2743  0,
2744  1,
2745  1 );
2746 
2747  hlpSS.str ( std::string ( ) );
2748  hlpSS << "<pre>" << "Compute Trace Sigma distances: ";
2749  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2750  for ( int iter = 0; iter < hlpIt; iter++ )
2751  {
2752  hlpSS << ".";
2753  }
2754 
2755  hlpSS2.str ( std::string ( ) );
2756  if ( this->traceSigmaDist == 0 ) { hlpSS2 << " FALSE"; }
2757  else { hlpSS2 << " TRUE"; }
2758  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2759  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2760  hlpSS << " " << hlpSS2.str() << "</pre>";
2761 
2762  rvapi_set_text ( hlpSS.str().c_str(),
2763  "DBSettingsSection",
2764  16,
2765  0,
2766  1,
2767  1 );
2768 
2769  hlpSS.str ( std::string ( ) );
2770  hlpSS << "<pre>" << "Compute Rotation Function distances: ";
2771  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2772  for ( int iter = 0; iter < hlpIt; iter++ )
2773  {
2774  hlpSS << ".";
2775  }
2776 
2777  hlpSS2.str ( std::string ( ) );
2778  if ( this->fullRotFnDist == 0 ) { hlpSS2 << " FALSE"; }
2779  else { hlpSS2 << " TRUE"; }
2780  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2781  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2782  hlpSS << " " << hlpSS2.str() << "</pre>";
2783 
2784  rvapi_set_text ( hlpSS.str().c_str(),
2785  "DBSettingsSection",
2786  17,
2787  0,
2788  1,
2789  1 );
2790 
2791  hlpSS.str ( std::string ( ) );
2792  hlpSS << "<pre>" << "Use phase information: ";
2793  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2794  for ( int iter = 0; iter < hlpIt; iter++ )
2795  {
2796  hlpSS << ".";
2797  }
2798 
2799  hlpSS2.str ( std::string ( ) );
2800  if ( this->usePhase == 0 ) { hlpSS2 << " FALSE"; }
2801  else { hlpSS2 << " TRUE"; }
2802  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2803  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2804  hlpSS << " " << hlpSS2.str() << "</pre>";
2805 
2806  rvapi_set_text ( hlpSS.str().c_str(),
2807  "DBSettingsSection",
2808  18,
2809  0,
2810  1,
2811  1 );
2812 
2813  rvapi_flush ( );
2814  }
2815 
2816  //======================================== Database settings check
2817  if ( !settings->usePhase )
2818  {
2819  std::cerr << "!!! ProSHADE ERROR !!! Tried to compare map fragments to database created without phases. This would mean comparing fragments of Patterson-like maps and this is not something that one should do... Terminating..." << std::endl;
2820 
2821  if ( settings->htmlReport )
2822  {
2823  std::stringstream hlpSS;
2824  hlpSS << "<font color=\"red\">" << "Tried to compare map fragments to database created without phases. This is not allowed and it looks like an internal bug. Please report this case." << "</font>";
2825  rvapi_set_text ( hlpSS.str().c_str(),
2826  "ProgressSection",
2827  settings->htmlReportLineProgress,
2828  1,
2829  1,
2830  1 );
2831  settings->htmlReportLineProgress += 1;
2832  rvapi_flush ( );
2833  }
2834 
2835  exit ( -1 );
2836  }
2837 
2838  //======================================== Now, create the one structure to be fragmented
2839  ProSHADE_data* one = new ProSHADE_data ();
2840 
2841  //======================================== Read in into one
2842  matchedStrNames->clear ( );
2843  matchedStrNames->emplace_back ( structFiles.at(0) );
2844 
2845  unsigned int fileType = checkFileType ( structFiles.at(0) );
2846  if ( fileType == 2 )
2847  {
2848  one->getDensityMapFromMAP ( this->structFiles.at(0),
2849  &this->shellSpacing,
2850  this->mapResolution,
2851  &this->bandwidth,
2852  &this->theta,
2853  &this->phi,
2854  &this->glIntegOrder,
2855  &this->extraSpace,
2856  settings->mapResDefault,
2857  settings->rotChangeDefault,
2858  settings,
2859  settings->overlayDefaults );
2860  }
2861  else if ( fileType == 1 )
2862  {
2863  one->getDensityMapFromPDB ( this->structFiles.at(0),
2864  &this->shellSpacing,
2865  this->mapResolution,
2866  &this->bandwidth,
2867  &this->theta,
2868  &this->phi,
2869  &this->glIntegOrder,
2870  &this->extraSpace,
2871  settings->mapResDefault,
2872  settings,
2873  this->bFactorValue,
2874  this->firstLineCOM );
2875  }
2876  else
2877  {
2878  std::cerr << "!!! ProSHADE ERROR !!! Error loading file " << this->structFiles.at(0) << " !!! Cannot detect the extension (currently, only PDB or MAP are allowed) and therefore cannot read the file." << std::endl;
2879 
2880  if ( settings->htmlReport )
2881  {
2882  std::stringstream hlpSS;
2883  hlpSS << "<font color=\"red\">" << "Cannot open file " << this->structFiles.at(0) << " .</font>";
2884  rvapi_set_text ( hlpSS.str().c_str(),
2885  "ProgressSection",
2886  settings->htmlReportLineProgress,
2887  1,
2888  1,
2889  1 );
2890  settings->htmlReportLineProgress += 1;
2891  rvapi_flush ( );
2892  }
2893 
2894  exit ( -1 );
2895  }
2896  if ( settings->verbose > 2 )
2897  {
2898  std::cout << ">>>>> Structure 0 read from file." << std::endl;
2899  }
2900 
2901  if ( settings->htmlReport )
2902  {
2903  std::stringstream hlpSS;
2904  hlpSS << "<font color=\"green\">" << "The structure for fragmenting loaded." << "</font>";
2905  rvapi_set_text ( hlpSS.str().c_str(),
2906  "ProgressSection",
2907  settings->htmlReportLineProgress,
2908  1,
2909  1,
2910  1 );
2911  settings->htmlReportLineProgress += 1;
2912 
2913  rvapi_flush ( );
2914  }
2915 
2916  //======================================== Deal with the centering and MAP data format, if applicable
2917  one->keepPhaseInMap ( this->alpha,
2918  this->bFactorChange,
2919  &this->bandwidth,
2920  &this->theta,
2921  &this->phi,
2922  &this->glIntegOrder,
2923  settings,
2924  this->useCOM,
2925  settings->noIQRsFromMap,
2926  settings->verbose,
2927  settings->clearMapData,
2928  settings->rotChangeDefault,
2929  settings->overlayDefaults,
2930  settings->maskBlurFactor,
2931  false );
2932 
2933  //======================================== Fragment
2934  std::vector<ProSHADE_data*> frags = one->fragmentMap ( settings, userCOM );
2935 
2936  if ( settings->verbose > 0 )
2937  {
2938  std::cout << "Structure 0 fragmented." << std::endl;
2939  }
2940 
2941  if ( settings->htmlReport )
2942  {
2943  std::stringstream hlpSS;
2944  hlpSS << "<font color=\"green\">" << "Fragments obtained." << "</font>";
2945  rvapi_set_text ( hlpSS.str().c_str(),
2946  "ProgressSection",
2947  settings->htmlReportLineProgress,
2948  1,
2949  1,
2950  1 );
2951  settings->htmlReportLineProgress += 1;
2952 
2953  rvapi_flush ( );
2954  }
2955 
2956  //======================================== Check for not finding any size matches
2957  if ( frags.size() == 0 )
2958  {
2959  std::cout << "!!! ProSHADE WARNING !!! Did not find any fragmentation boxes fitting the requirements. Either decrease the box size (to have more and higher chance of reaching the minimal density fraction) or change the minimal density fraction (the -mFrag parameter) to let more boxes pass." << std::endl;
2960 
2961  if ( settings->htmlReport )
2962  {
2963  std::stringstream hlpSS;
2964  hlpSS << "<font color=\"orange\">" << "Did not find any fragmentation boxes fitting the requirements. Either decrease the box size (to have more and higher chance of reaching the minimal density fraction) or change the minimal density fraction (the -mFrag parameter) to let more boxes pass." << "</font>";
2965  rvapi_set_text ( hlpSS.str().c_str(),
2966  "ProgressSection",
2967  settings->htmlReportLineProgress,
2968  1,
2969  1,
2970  1 );
2971  settings->htmlReportLineProgress += 1;
2972  rvapi_flush ( );
2973  }
2974 
2975  exit ( -1 );
2976  }
2977 
2978  //======================================== Determine size limits on database over all boxes
2979  double volTolerance = ( 1.0 - settings->volumeTolerance );
2980  double totMinVol = ( ( static_cast<double> ( frags.at(0)->_maxMapU ) * volTolerance ) *
2981  ( static_cast<double> ( frags.at(0)->_maxMapV ) * volTolerance ) *
2982  ( static_cast<double> ( frags.at(0)->_maxMapW ) * volTolerance ) );
2983  double volMin = totMinVol;
2984  for ( unsigned int iter = 1; iter < static_cast<unsigned int> ( frags.size() ); iter++ )
2985  {
2986  volMin = ( ( static_cast<double> ( frags.at(iter)->_maxMapU ) * volTolerance ) *
2987  ( static_cast<double> ( frags.at(iter)->_maxMapV ) * volTolerance ) *
2988  ( static_cast<double> ( frags.at(iter)->_maxMapW ) * volTolerance ) );
2989  totMinVol = std::min ( volMin, totMinVol );
2990  }
2991 
2992  volTolerance = ( 1.0 + settings->volumeTolerance );
2993  double totMaxVol = ( ( static_cast<double> ( frags.at(0)->_maxMapU ) * volTolerance ) *
2994  ( static_cast<double> ( frags.at(0)->_maxMapV ) * volTolerance ) *
2995  ( static_cast<double> ( frags.at(0)->_maxMapW ) * volTolerance ) );
2996  double volMax = totMaxVol;
2997  for ( unsigned int iter = 1; iter < static_cast<unsigned int> ( frags.size() ); iter++ )
2998  {
2999  volMax = ( ( static_cast<double> ( frags.at(iter)->_maxMapU ) * volTolerance ) *
3000  ( static_cast<double> ( frags.at(iter)->_maxMapV ) * volTolerance ) *
3001  ( static_cast<double> ( frags.at(iter)->_maxMapW ) * volTolerance ) );
3002  totMaxVol = std::max ( volMax, totMaxVol );
3003  }
3004 
3005  if ( settings->htmlReport )
3006  {
3007  //==================================== Create section
3008  rvapi_add_section ( "FragmentSection",
3009  "Fragment processing",
3010  "body",
3011  settings->htmlReportLine,
3012  0,
3013  1,
3014  1,
3015  false );
3016  settings->htmlReportLine += 1;
3017 
3018  rvapi_flush ( );
3019  }
3020 
3021  //======================================== Complete the data processing for each map fragment
3022  for ( unsigned int frIt = 0; frIt < static_cast<unsigned int> ( frags.size() ); frIt++ )
3023  {
3024  if ( settings->verbose > 3 )
3025  {
3026  std::cout << ">>>>>>>> Computing spherical harmonics for fragment " << frIt << " out of " << frags.size() << "." << std::endl;
3027  }
3028 
3029  //==================================== Map the density onto spheres
3030  frags.at(frIt)->mapPhaselessToSphere ( settings,
3031  frags.at(frIt)->_thetaAngle,
3032  frags.at(frIt)->_phiAngle,
3033  one->_shellSpacing,
3034  settings->manualShells );
3035 
3036  //==================================== Compute the Spherical Harmonics (SH) coefficients
3037  frags.at(frIt)->getSphericalHarmonicsCoeffs ( frags.at(frIt)->_bandwidthLimit, settings );
3038 
3039  //==================================== If required, pre-compute the energy levels distance descriptor
3040  if ( this->energyLevelDist )
3041  {
3042  frags.at(frIt)->precomputeRotInvDescriptor ( settings );
3043  }
3044 
3045  if ( settings->htmlReport )
3046  {
3047  std::stringstream hlpSS;
3048  hlpSS << "Fragment " << frIt << " spherical harmonics computation done.";
3049  rvapi_set_text ( hlpSS.str().c_str(),
3050  "FragmentSection",
3051  frIt,
3052  1,
3053  1,
3054  1 );
3055 
3056  rvapi_flush ( );
3057  }
3058 
3059  }
3060  if ( settings->verbose > 1 )
3061  {
3062  std::cout << ">> Spherical harmonics computed for " << static_cast<unsigned int> ( frags.size() ) << " fragments." << std::endl;
3063  }
3064 
3065  if ( settings->htmlReport )
3066  {
3067  std::stringstream hlpSS;
3068  hlpSS << "<font color=\"green\">" << "Spherical harmonics computed for " << static_cast<unsigned int> ( frags.size() ) << " fragments." << "</font>";
3069  rvapi_set_text ( hlpSS.str().c_str(),
3070  "ProgressSection",
3071  settings->htmlReportLineProgress,
3072  1,
3073  1,
3074  1 );
3075  settings->htmlReportLineProgress += 1;
3076 
3077  rvapi_flush ( );
3078  }
3079 
3080  //======================================== Read in the database data into ProSHADE_data objects
3081  std::vector<ProSHADE_data*> dbData;
3082  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbStrNames.size() ); strIt++ )
3083  {
3084  if ( settings->verbose > 2 )
3085  {
3086  std::cout << ">>>>> Loading structure " << strIt << " from the database." << std::endl;
3087  }
3088 
3089  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), totMinVol, totMaxVol, settings->verbose, settings ) );
3090  if ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 )
3091  {
3092  dbData.pop_back ( );
3093  }
3094  else
3095  {
3096  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
3097  }
3098  }
3099 
3100  //======================================== Check for not finding any size matches
3101  if ( dbData.size() == 0 )
3102  {
3103  std::cout << "!!! ProSHADE WARNING !!! There was no database entry which would pass the size limitations and therefore cannot compute distances. This could be caused by submitting database file with small number or very narrowly distributed structure sizes. Alternatively, the size limit parameter ( \'--dbSizeLim\' ) could be set to too constricted values (or the default values are sub-optimal for this case). Now terminating..." << std::endl;
3104 
3105  if ( settings->htmlReport )
3106  {
3107  std::stringstream hlpSS;
3108  hlpSS << "<font color=\"orange\">" << "There was no database entry which would pass the size limitations and therefore cannot compute distances. This could be caused by submitting database file with small number or very narrowly distributed structure sizes. Alternatively, the size limit parameter ( \'--dbSizeLim\' ) could be set to too constricted values (or the default values are sub-optimal for this case)." << "</font>";
3109  rvapi_set_text ( hlpSS.str().c_str(),
3110  "ProgressSection",
3111  settings->htmlReportLineProgress,
3112  1,
3113  1,
3114  1 );
3115  settings->htmlReportLineProgress += 1;
3116  rvapi_flush ( );
3117  }
3118 
3119  exit ( 0 );
3120  }
3121 
3122  if ( settings->htmlReport )
3123  {
3124  //==================================== Create section
3125  rvapi_add_section ( "FragmentDistancesSection",
3126  "Fragment distances computation",
3127  "body",
3128  settings->htmlReportLine,
3129  0,
3130  1,
3131  1,
3132  false );
3133  settings->htmlReportLine += 1;
3134 
3135  rvapi_flush ( );
3136  }
3137 
3138  for ( unsigned int frIt = 0; frIt < static_cast<unsigned int> ( frags.size() ); frIt++ )
3139  {
3140  if ( settings->verbose > 0 )
3141  {
3142  std::cout << "Computing distances for fragment " << frIt << " ." << std::endl;
3143  }
3144 
3145  //==================================== Create the compare against all object
3146  this->cmpObj = new ProSHADE_compareOneAgainstAll ( frags.at(frIt), &dbData, this->ignoreLs, this->mPower, settings->verbose );
3147 
3148  //==================================== Save the decision whether to use phases or not
3149  if ( frags.at(frIt)->_keepOrRemove ) { this->cmpObj->_keepOrRemove = true; }
3150  else { this->cmpObj->_keepOrRemove = false; }
3151 
3152  //==================================== If required, compute the energy levels distances
3153  if ( this->energyLevelDist )
3154  {
3155  this->energyLevelsDistances = this->cmpObj->getEnergyLevelsDistance ( settings->verbose, settings );
3156  this->fragEnergyLevelsDistances.emplace_back ( this->energyLevelsDistances );
3157 
3158  // ... and set which pairs not to follow further
3159  if ( this->enLevelsThreshold != -999.9 )
3160  {
3161  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
3162  {
3163  if ( this->enLevelsThreshold > this->energyLevelsDistances.at(iter) )
3164  {
3165  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 1 );
3166  }
3167  else
3168  {
3169  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
3170  }
3171  }
3172  }
3173  else
3174  {
3175  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
3176  {
3177  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
3178  }
3179  }
3180  }
3181  else
3182  {
3183  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
3184  {
3185  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
3186  }
3187  }
3188 
3189  if ( settings->verbose > 1 )
3190  {
3191  std::cout << ">> Cross-correlation distances computed ." << std::endl;
3192  }
3193 
3194  if ( settings->htmlReport )
3195  {
3196  std::stringstream hlpSS;
3197  hlpSS << "<font color=\"green\">" << "Energy Level distances computed for fragment " << frIt << "</font>";
3198  rvapi_set_text ( hlpSS.str().c_str(),
3199  "FragmentDistancesSection",
3200  ( frIt * 3 ) + 0,
3201  1,
3202  1,
3203  1 );
3204 
3205  rvapi_flush ( );
3206  }
3207 
3208  //==================================== Sort out the integration order as this is not kept within the data objects...
3209  this->glIntegOrderVec = std::vector<unsigned int> ( dbData.size() + 1 );
3210  this->glIntegOrderVec.at(0) = this->glIntegOrder;
3211  double distPerPointFraction = 0.0;
3212  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbData.size() ); strIt++ )
3213  {
3214  distPerPointFraction = ( ( dbData.at(strIt)->_maxMapRange / 2.0 ) / static_cast<double> ( dbData.at(strIt)->_bandwidthLimit / 2 ) ) / ( dbData.at(strIt)->_maxMapRange / 2.0 );
3215 
3216  for ( unsigned int iter = 2; iter < static_cast<unsigned int> ( ProSHADE_internal_misc::glIntMaxDists.size() ); iter++ )
3217  {
3218  if ( ProSHADE_internal_misc::glIntMaxDists.at(iter) >= distPerPointFraction )
3219  {
3220  this->glIntegOrderVec.at(strIt+1) = iter;
3221  }
3222  }
3223  }
3224 
3225  //==================================== Pre-compute the E matrices in case either the trace sigmal or full rotation distance are required
3226  if ( this->traceSigmaDist || this->fullRotFnDist )
3227  {
3228  this->cmpObj->precomputeTrSigmaDescriptor ( this->shellSpacing, &this->glIntegOrderVec, settings );
3229  }
3230 
3231  //==================================== Compute the trace sigma distances, if required
3232  if ( this->traceSigmaDist )
3233  {
3234  this->traceSigmaDistances = this->cmpObj->getTrSigmaDistance ( settings->verbose, settings );
3235  this->fragTraceSigmaDistances.emplace_back ( this->traceSigmaDistances );
3236 
3237  if ( this->trSigmaThreshold == -999.9 )
3238  {
3239  this->cmpObj->_trSigmaDoNotFollow = this->cmpObj->_enLevelsDoNotFollow;
3240  }
3241  else
3242  {
3243  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
3244  {
3245  if ( this->trSigmaThreshold > this->traceSigmaDistances.at(iter) )
3246  {
3247  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 1 );
3248  }
3249  else
3250  {
3251  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
3252  }
3253  }
3254  }
3255  }
3256  else
3257  {
3258  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
3259  {
3260  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
3261  }
3262  }
3263 
3264  if ( settings->verbose > 1 )
3265  {
3266  std::cout << ">> Trace sigma distances computed ." << std::endl;
3267  }
3268  if ( settings->htmlReport )
3269  {
3270  std::stringstream hlpSS;
3271  hlpSS << "<font color=\"green\">" << "Trace Sigma distances computed for fragment " << frIt << "</font>";
3272  rvapi_set_text ( hlpSS.str().c_str(),
3273  "FragmentDistancesSection",
3274  ( frIt * 3 ) + 1,
3275  1,
3276  1,
3277  1 );
3278 
3279  rvapi_flush ( );
3280  }
3281 
3282  //==================================== If full rotation distance is required, pre-compute the requirements
3283  if ( this->fullRotFnDist )
3284  {
3285  this->cmpObj->getSO3InverseMap ( settings );
3286  this->cmpObj->getEulerAngles ( settings );
3287  this->cmpObj->generateWignerMatrices ( settings );
3288  this->fullRotationDistances = this->cmpObj->getRotCoeffDistance ( settings->verbose, settings );
3289  this->fragfullRotationDistances.emplace_back ( this->fullRotationDistances );
3290  }
3291  if ( settings->verbose > 1 )
3292  {
3293  std::cout << ">> Rotation function distances computed ." << std::endl;
3294  }
3295  if ( settings->htmlReport )
3296  {
3297  std::stringstream hlpSS;
3298  hlpSS << "<font color=\"green\">" << "Rotation Function distances computed for fragment " << frIt << "</font>";
3299  rvapi_set_text ( hlpSS.str().c_str(),
3300  "FragmentDistancesSection",
3301  ( frIt * 3 ) + 2,
3302  1,
3303  1,
3304  1 );
3305 
3306  rvapi_flush ( );
3307  }
3308  }
3309 
3310  if ( settings->htmlReport )
3311  {
3312  std::stringstream hlpSS;
3313  hlpSS << "<font color=\"green\">" << "Fragment distances computed." << "</font>";
3314  rvapi_set_text ( hlpSS.str().c_str(),
3315  "ProgressSection",
3316  settings->htmlReportLineProgress,
3317  1,
3318  1,
3319  1 );
3320  settings->htmlReportLineProgress += 1;
3321 
3322  rvapi_flush ( );
3323  }
3324 
3325  //======================================== Done
3326  return ;
3327 }
3328 
3329 
3347  std::string fName,
3348  double volThreMin,
3349  double volThreMax,
3350  int verbose,
3351  ProSHADE::ProSHADE_settings* settings,
3352  bool saveWithAndWithout )
3353 {
3354  //======================================== Sanity check
3355  if ( dbFile->fail() )
3356  {
3357  std::cerr << "!!! ProSHADE ERROR !!! Cannot read from input database file. Terminating..." << std::endl;
3358 
3359  if ( settings->htmlReport )
3360  {
3361  std::stringstream hlpSS;
3362  hlpSS << "<font color=\"red\">" << "Cannot read from the database file. This looks like file corruption or internal bug, if repeating with a new database file does not help, please report this case." << "</font>";
3363  rvapi_set_text ( hlpSS.str().c_str(),
3364  "ProgressSection",
3365  settings->htmlReportLineProgress,
3366  1,
3367  1,
3368  1 );
3369  settings->htmlReportLineProgress += 1;
3370  rvapi_flush ( );
3371  }
3372 
3373  exit ( -1 );
3374  }
3375 
3376  //======================================== Initialise object to null
3377  this->_inputFileName = fName;
3378  this->_densityMapMap = nullptr;
3379  this->_densityMapCor = nullptr;
3380  this->_densityMapCorCoords = nullptr;
3381  this->_shellMappedData = nullptr;
3382  this->_realSHCoeffs = nullptr;
3383  this->_imagSHCoeffs = nullptr;
3384  this->_sphericalHarmonicsWeights = nullptr;
3385  this->_semiNaiveTable = nullptr;
3386  this->_semiNaiveTableSpace = nullptr;
3387  this->_shWorkspace = nullptr;
3388  this->_rrpMatrices = nullptr;
3389  this->_invRealData = nullptr;
3390  this->_invImagData = nullptr;
3391 
3392  this->_densityMapComputed = false;
3393  this->_phaseRemoved = false;
3394  this->_usePhase = false;
3395  this->_firstLineCOM = false;
3396  this->_sphereMapped = false;
3397  this->_sphericalCoefficientsComputed = false;
3398  this->_rrpMatricesPrecomputed = false;
3399  this->_wasBandwithGiven = true;
3400  this->_wasThetaGiven = true;
3401  this->_wasPhiGiven = true;
3402  this->_wasGlInterGiven = true;
3403 
3404  this->_xCorrection = 0;
3405  this->_yCorrection = 0;
3406  this->_zCorrection = 0;
3407 
3408  this->_mapMean = 0.0;
3409  this->_mapSdev = 1.0;
3410 
3411  //======================================== Declare local variables
3412  unsigned int hlpUInt;
3413  double hlpD;
3414 
3415  //======================================== Read in the structure settings
3416  dbFile->read ( reinterpret_cast<char*> ( &this->_fromPDB ), sizeof ( bool ) );
3417  dbFile->read ( reinterpret_cast<char*> ( &this->_shellSpacing ), sizeof ( double ) );
3418  dbFile->read ( reinterpret_cast<char*> ( &this->_maxExtraCellularSpace ), sizeof ( double ) );
3419  dbFile->read ( reinterpret_cast<char*> ( &this->_xRange ), sizeof ( double ) );
3420  dbFile->read ( reinterpret_cast<char*> ( &this->_yRange ), sizeof ( double ) );
3421  dbFile->read ( reinterpret_cast<char*> ( &this->_zRange ), sizeof ( double ) );
3422 
3423  dbFile->read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
3424  for ( unsigned int it = 0; it < hlpUInt; it++ )
3425  {
3426  dbFile->read ( reinterpret_cast<char*> ( &hlpD ), sizeof ( double ) );
3427  this->_shellPlacement.emplace_back ( hlpD );
3428  }
3429 
3430  dbFile->read ( reinterpret_cast<char*> ( &this->_mapResolution ), sizeof ( double ) );
3431  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapU ), sizeof ( unsigned int ) );
3432  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapV ), sizeof ( unsigned int ) );
3433  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapW ), sizeof ( unsigned int ) );
3434  dbFile->read ( reinterpret_cast<char*> ( &this->_densityMapComputed ), sizeof ( bool ) );
3435  dbFile->read ( reinterpret_cast<char*> ( &this->_mapMean ), sizeof ( double ) );
3436  dbFile->read ( reinterpret_cast<char*> ( &this->_mapSdev ), sizeof ( double ) );
3437  dbFile->read ( reinterpret_cast<char*> ( &this->_fourierCoeffPower ), sizeof ( double ) );
3438  dbFile->read ( reinterpret_cast<char*> ( &this->_bFactorChange ), sizeof ( double ) );
3439  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapRange ), sizeof ( double ) );
3440  dbFile->read ( reinterpret_cast<char*> ( &this->_phaseRemoved ), sizeof ( bool ) );
3441  dbFile->read ( reinterpret_cast<char*> ( &this->_usePhase ), sizeof ( bool ) );
3442  dbFile->read ( reinterpret_cast<char*> ( &this->_keepOrRemove ), sizeof ( bool ) );
3443  dbFile->read ( reinterpret_cast<char*> ( &this->_thetaAngle ), sizeof ( double ) );
3444  dbFile->read ( reinterpret_cast<char*> ( &this->_phiAngle ), sizeof ( double ) );
3445  dbFile->read ( reinterpret_cast<char*> ( &this->_noShellsWithData ), sizeof ( unsigned int ) );
3446  dbFile->read ( reinterpret_cast<char*> ( &this->_xCorrection ), sizeof ( unsigned int ) );
3447  dbFile->read ( reinterpret_cast<char*> ( &this->_yCorrection ), sizeof ( unsigned int ) );
3448  dbFile->read ( reinterpret_cast<char*> ( &this->_zCorrection ), sizeof ( unsigned int ) );
3449  dbFile->read ( reinterpret_cast<char*> ( &this->_xCorrErr ), sizeof ( double ) );
3450  dbFile->read ( reinterpret_cast<char*> ( &this->_yCorrErr ), sizeof ( double ) );
3451  dbFile->read ( reinterpret_cast<char*> ( &this->_zCorrErr ), sizeof ( double ) );
3452  dbFile->read ( reinterpret_cast<char*> ( &this->_sphereMapped ), sizeof ( bool ) );
3453  dbFile->read ( reinterpret_cast<char*> ( &this->_firstLineCOM ), sizeof ( bool ) );
3454  dbFile->read ( reinterpret_cast<char*> ( &this->_bandwidthLimit ), sizeof ( unsigned int ) );
3455  dbFile->read ( reinterpret_cast<char*> ( &this->_oneDimmension ), sizeof ( unsigned int ) );
3456  dbFile->read ( reinterpret_cast<char*> ( &this->_sphericalCoefficientsComputed ), sizeof ( bool ) );
3457  dbFile->read ( reinterpret_cast<char*> ( &this->_rrpMatricesPrecomputed ), sizeof ( bool ) );
3458 
3459  if ( verbose > 3 )
3460  {
3461  std::cout << ">>>>>>>> Settings loaded." << std::endl;
3462  }
3463 
3464  //======================================== Check the volume
3465  if ( !( ( ( (this->_xRange-this->_maxExtraCellularSpace) * (this->_yRange-this->_maxExtraCellularSpace) * (this->_zRange-this->_maxExtraCellularSpace) ) > volThreMin ) &&
3466  ( ( (this->_xRange-this->_maxExtraCellularSpace) * (this->_yRange-this->_maxExtraCellularSpace) * (this->_zRange-this->_maxExtraCellularSpace) ) < volThreMax ) ) )
3467  {
3468  //==================================== Set flag to ignore this structure further
3469  this->_mapResolution = -999.9;
3470  }
3471 
3472  //======================================== Initialise the spherical harmonics coefficient arrays
3473  this->_realSHCoeffs = new double* [this->_noShellsWithData];
3474  for ( unsigned int i = 0; i < this->_noShellsWithData; i++ ) { this->_realSHCoeffs[i] = new double [this->_oneDimmension * this->_oneDimmension]; }
3475  this->_imagSHCoeffs = new double* [this->_noShellsWithData];
3476  for ( unsigned int i = 0; i < this->_noShellsWithData; i++ ) { this->_imagSHCoeffs[i] = new double [this->_oneDimmension * this->_oneDimmension]; }
3477 
3478  //======================================== Read in the spherical harmonics coefficient arrays
3479  for ( unsigned int sh = 0; sh < this->_noShellsWithData; sh++ )
3480  {
3481  for ( unsigned int arrIt = 0; arrIt < ( this->_oneDimmension * this->_oneDimmension ); arrIt++ )
3482  {
3483  dbFile->read ( reinterpret_cast<char*> ( &this->_realSHCoeffs[sh][arrIt] ), sizeof ( double ) );
3484  dbFile->read ( reinterpret_cast<char*> ( &this->_imagSHCoeffs[sh][arrIt] ), sizeof ( double ) );
3485  }
3486  }
3487  if ( verbose > 3 )
3488  {
3489  std::cout << ">>>>>>>> Spherical harmonics loaded." << std::endl;
3490  }
3491 
3492  //======================================== Initialise the RRP matrices data arrays
3493  this->_rrpMatrices = new double** [this->_bandwidthLimit];
3494  for ( unsigned int bwIt = 0; bwIt < this->_bandwidthLimit; bwIt++ )
3495  {
3496  //==================================== Odd bands are 0, so just ignore them
3497  if ( !this->_keepOrRemove ) { if ( ( bwIt % 2 ) != 0 ) { continue; } }
3498 
3499  this->_rrpMatrices[bwIt] = new double* [this->_noShellsWithData];
3500  for ( unsigned int shIt = 0; shIt < this->_noShellsWithData; shIt++ )
3501  {
3502  this->_rrpMatrices[bwIt][shIt] = new double [this->_noShellsWithData];
3503  }
3504  }
3505 
3506  //======================================== Read in the RRP matrices data arrays
3507  for ( unsigned int bwIt = 0; bwIt < this->_bandwidthLimit; bwIt++ )
3508  {
3509  //==================================== Odd bands are 0, so just ignore them
3510  if ( !this->_keepOrRemove ) { if ( ( bwIt % 2 ) != 0 ) { continue; } }
3511 
3512  for ( unsigned int sh1 = 0; sh1 < this->_noShellsWithData; sh1++ )
3513  {
3514  for ( unsigned int sh2 = 0; sh2 < this->_noShellsWithData; sh2++ )
3515  {
3516  dbFile->read ( reinterpret_cast<char*> ( &this->_rrpMatrices[bwIt][sh1][sh2] ), sizeof ( double ) );
3517  }
3518  }
3519  }
3520  if ( verbose > 3 )
3521  {
3522  std::cout << ">>>>>>>> RRP Matrices loaded." << std::endl;
3523  }
3524 
3525  //======================================== Normalise back to usual meaning
3526  if ( saveWithAndWithout )
3527  {
3528  if ( this->_usePhase )
3529  {
3530  dbFile->read ( reinterpret_cast<char*> ( &this->_xFrom ), sizeof ( double ) );
3531  dbFile->read ( reinterpret_cast<char*> ( &this->_xTo ), sizeof ( double ) );
3532  dbFile->read ( reinterpret_cast<char*> ( &this->_yFrom ), sizeof ( double ) );
3533  dbFile->read ( reinterpret_cast<char*> ( &this->_yTo ), sizeof ( double ) );
3534  dbFile->read ( reinterpret_cast<char*> ( &this->_zFrom ), sizeof ( double ) );
3535  dbFile->read ( reinterpret_cast<char*> ( &this->_zTo ), sizeof ( double ) );
3536 
3537  this->_densityMapCor = new double [(this->_maxMapU+1) * (this->_maxMapV+1) * (this->_maxMapW+1)];
3538  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( (this->_maxMapU+1) * (this->_maxMapV+1) * (this->_maxMapW+1) ); mIt++ )
3539  {
3540  dbFile->read ( reinterpret_cast<char*> ( &this->_densityMapCor[mIt] ), sizeof ( double ) );
3541  }
3542  }
3543  }
3544 
3545  this->_xSamplingRate = this->_xRange / static_cast<double> ( this->_maxMapU );
3546  this->_ySamplingRate = this->_yRange / static_cast<double> ( this->_maxMapV );
3547  this->_zSamplingRate = this->_zRange / static_cast<double> ( this->_maxMapW );
3548 
3549  //======================================== Done
3550  return ;
3551 }
double aaErrorTolerance
The tolerance parameter on matching axes for the angle-axis representation of rotations.
Definition: ProSHADE.h:128
This class deals with reading in the data and computing structure specific information including the ...
double mapResolution
This is the internal resolution at which the calculations are done, not necessarily the resolution of...
Definition: ProSHADE.h:78
double noIQRsFromMap
This is the number of interquartile distances from mean that is used to threshold the map masking...
Definition: ProSHADE.h:93
bool clearMapData
This value is used to decide whether the input maps should be cleared again, or not.
Definition: ProSHADE.h:146
unsigned int theta
This parameter is the longitude of the spherical grid mapping. It should be 2 * bandwidth unless ther...
Definition: ProSHADE.h:83
unsigned int checkFileType(std::string fileName)
This function checks the input file for being either PDB or MAP formatted.
double bFactorValue
This is the value to which all B-factors of PDB files will be changed to.
Definition: ProSHADE.h:88
void generateWignerMatrices(ProSHADE::ProSHADE_settings *settings)
This function is responsible for computing the Wigner D matrices for full rotation function distance ...
std::string clearMapFile
If map features are to be extracted, should the clear map be saved (then give file name here)...
Definition: ProSHADE.h:144
void normaliseMap(ProSHADE::ProSHADE_settings *settings)
This function does normalises the map data.
std::vector< double > getRotCoeffDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the full rotation function descriptor distances.
double databaseMinVolume
The smallest volume of a structure in the database.
Definition: ProSHADE.h:157
std::string databaseName
The name of the bin file to which the database should be saved.
Definition: ProSHADE.h:156
void mapPhaselessToSphere(ProSHADE::ProSHADE_settings *settings, double theta, double phi, double shellSz, unsigned int manualShells=0, bool keepInMemory=false, bool rotDefaults=false)
This function assumes the data have been processed and maps them onto a set of concentric spheres wit...
bool overlayDefaults
If true, the shell spacing and distances will be doube to their typical values. This is to speed up m...
Definition: ProSHADE.h:176
void alignDensities(ProSHADE::ProSHADE_settings *settings)
Takes the internal objects with and without phases and aligns them to all the other objects...
bool usePhase
Here the user can decide whether to use phase information or whether to ignore it completely...
Definition: ProSHADE.h:101
unsigned int bandwidth
This parameter determines the angular resolution of the spherical harmonics decomposition.
Definition: ProSHADE.h:80
void keepPhaseInMap(double alpha, double bFac, unsigned int *bandwidth, unsigned int *theta, unsigned int *phi, unsigned int *glIntegOrder, ProSHADE::ProSHADE_settings *settings, bool useCom=true, double maxMapIQR=10.0, int verbose=0, bool clearMapData=true, bool rotDefaults=false, bool overlapDefaults=false, double blurFactor=500.0, bool maskBlurFactorGiven=false)
This function keeps the phase information from the density map and prepares the data for SH coefficie...
bool htmlReport
Should HTML report for the run be created?
Definition: ProSHADE.h:186
int verbose
Should the software report on the progress, or just be quiet? Value between 0 (quiet) and 4 (loud) ...
Definition: ProSHADE.h:189
std::vector< double > getTrSigmaDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the trace sigma descriptor distances.
bool saveWithAndWithout
This option decides whether both with and without phase spherical harmonics should be saved...
Definition: ProSHADE.h:102
The main header file containing all declarations the user of the library needs.
double trSigmaThreshold
All structure pairs with trace sigma descriptor value less than this will not be subjected to any fur...
Definition: ProSHADE.h:138
double alpha
This parameter determines the power to which the |F|&#39;s should be raised.
Definition: ProSHADE.h:113
bool firstLineCOM
This is a special option for metal detection, please leave false.
Definition: ProSHADE.h:106
bool fullRotFnDist
Should the full rotation function distances descriptor be computed.
Definition: ProSHADE.h:134
void getSO3InverseMap(ProSHADE::ProSHADE_settings *settings)
This function is responsible for computing the SO3 inverse transform.
std::vector< int > ignoreLs
This vector lists all the bandwidth values which should be ignored and not part of the computations...
Definition: ProSHADE.h:117
int peakSurroundingPoints
For a peak to exist, how many points in every direction need to be smalled than the middle value...
Definition: ProSHADE.h:125
void getDensityMapFromPDB(std::string fileName, double *shellDistance, double resolution, unsigned int *bandwidth, unsigned int *theta, unsigned int *phi, unsigned int *glIntegOrder, double *extraSpace, bool mapResDefault, ProSHADE::ProSHADE_settings *settings, double Bfactor=80.0, bool hpFirstLineCom=false, bool overlayDefaults=false)
Function to read in the PDB file and compute the theoretical density map.
double shellSpacing
This parameter determines how far the radial shells should be from each other.
Definition: ProSHADE.h:96
double databaseMaxVolume
The largest volume allowed to exist in the database.
Definition: ProSHADE.h:158
double volumeTolerance
The percentage tolerance on each dimmension when comparing one structure to entire database...
Definition: ProSHADE.h:159
double peakDistanceForReal
Threshold for determining &#39;missing peaks&#39; existence.
Definition: ProSHADE.h:124
bool mapResDefault
This variable states if default resolution should be used, or whether the user has supplied a differe...
Definition: ProSHADE.h:85
bool traceSigmaDist
Should the trace sigma distances descriptor be computed.
Definition: ProSHADE.h:133
void precomputeTrSigmaDescriptor(double shellSpacing, std::vector< unsigned int > *glIntegOrderVec, ProSHADE::ProSHADE_settings *settings)
This function computes the E matrices required for the trace sigma descriptor, the rotation function ...
std::vector< ProSHADE_data * > fragmentMap(ProSHADE::ProSHADE_settings *settings, bool userCOM)
This function takes the map and fragments it into boxes of given size, returning vector of data objec...
bool rotChangeDefault
If map rotation is selected, the default automatic parameter decision is changed. This variable state...
Definition: ProSHADE.h:170
void getSphericalHarmonicsCoeffs(unsigned int bandwidth, ProSHADE::ProSHADE_settings *settings)
This function takes the sphere mapped data and computes spherical harmoncis decomposition for each sh...
unsigned int phi
This parameter is the latitudd of the spherical grid mapping. It should be 2 * bandwidth unless there...
Definition: ProSHADE.h:84
The main header file containing all declarations for the innter workings of the library.
void compareFragAgainstDatabase(ProSHADE::ProSHADE_settings *settings, std::vector< std::string > *matchedStrNames)
This function fragments and compares a single file agaisnt a database of pre-computed structures...
int htmlReportLine
Iterator for current HTML line.
Definition: ProSHADE.h:187
bool energyLevelDist
Should the energy level distances descriptor be computed.
Definition: ProSHADE.h:132
int htmlReportLineProgress
Iterator for current HTML line in the progress bar.
Definition: ProSHADE.h:188
double bFactorChange
This value will be used to change the B-factors if required by the user.
Definition: ProSHADE.h:89
double peakHeightNoIQRs
How many interquartile ranges should be used to distinguish &#39;false&#39; peaks from the true ones...
Definition: ProSHADE.h:123
void getDensityMapFromMAP(std::string fileName, double *shellDistance, double resolution, unsigned int *bandwidth, unsigned int *theta, unsigned int *phi, unsigned int *glIntegOrder, double *extraSpace, bool mapResDefault, bool rotDefaults, ProSHADE::ProSHADE_settings *settings, bool overlayDefaults=false)
Function to read in the MAP file and provide the basic processing.
std::vector< std::array< double, 3 > > getEulerAngles(ProSHADE::ProSHADE_settings *settings)
This function finds the highest peak in the SO3 inverse transform map and sets it as the optimal over...
This is the executive class responsible for comparing two or more structures.
std::vector< double > getEnergyLevelsDistance(int verbose, ProSHADE::ProSHADE_settings *settings)
This function computes the energy level descriptor value from the first structure to all remaining st...
void precomputeRotInvDescriptor(ProSHADE::ProSHADE_settings *settings)
This function computes the RRP matrices, which are required for the computation of the energy levels ...
double mapFragBoxSize
Should the clear map be fragmented into boxes? If so, put box size here, otherwise leave 0...
Definition: ProSHADE.h:151
ProSHADE_data()
Contructor for the ProSHADE_data class.
double symGapTolerance
For C-symmetries - if there are many, only those with average peak height - parameter * top symmetry ...
Definition: ProSHADE.h:129
This class stores all the settings and is passed to the executive classes instead of multitude of par...
Definition: ProSHADE.h:74
double mPower
This parameter determines the scaling for trace sigma descriptor.
Definition: ProSHADE.h:114
void saveDatabase(ProSHADE::ProSHADE_settings *settings)
Function responsible for saving the structure database.
unsigned int manualShells
Should the user require so, the maximum number of radial shells can be set.
Definition: ProSHADE.h:98
bool useCOM
Should the Centre of Mass (COM) be used to center the structure in the cell?
Definition: ProSHADE.h:105
double maskBlurFactor
The is the amount of blurring to be used to create masks for maps.
Definition: ProSHADE.h:147
std::vector< std::string > structFiles
This vector should contain all the structures that are being dealt with, but this does not yet work! ...
Definition: ProSHADE.h:120
double enLevelsThreshold
All structure pairs with energy level descriptor value less than this will not be subjected to any fu...
Definition: ProSHADE.h:137
Task taskToPerform
This custom type variable determines which task to perfom (i.e. symmetry detection, distances computation or map features extraction).
Definition: ProSHADE.h:141
void removePhaseFromMap(double alpha, double bFac, ProSHADE::ProSHADE_settings *settings)
This function removes the phase information from the density map.
This file contains the ProSHADE_internal_misc namespace and its miscellaneous functions.
std::string mapFragName
The prefix of the files with the cut out boxes.
Definition: ProSHADE.h:152
double extraSpace
What should be the distance added on both sides to the structure, so that the next cell density would...
Definition: ProSHADE.h:109
unsigned int glIntegOrder
This parameter controls the Gauss-Legendre integration order and so the radial resolution.
Definition: ProSHADE.h:82
void compareAgainstDatabase(ProSHADE::ProSHADE_settings *settings, std::vector< std::string > *matchedStrNames)
This function compares a single file agaisnt a database of pre-computed structures.