ProSHADE  0.6.6 (DEC 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() ), settings->extraSpace );
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  settings->manualShells,
982  true );
983  }
984  else
985  {
986  one->mapPhaselessToSphere ( settings,
987  this->theta,
988  this->phi,
989  this->shellSpacing,
990  settings->manualShells,
991  false );
992  }
993 
994  //==================================== Compute the Spherical Harmonics (SH) coefficients
995  one->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
996 
997  if ( settings->verbose > 3 )
998  {
999  std::cout << ">>>>> Spherical harmonics computed." << std::endl;
1000  }
1001 
1002  //==================================== Pre-compute the RRP matrices
1003  one->precomputeRotInvDescriptor ( settings );
1004 
1005  //==================================== Save file settings
1006  dbFile.write ( reinterpret_cast<char*> ( &one->_fromPDB ), sizeof( bool ) );
1007  dbFile.write ( reinterpret_cast<char*> ( &one->_shellSpacing ), sizeof( double ) );
1008  dbFile.write ( reinterpret_cast<char*> ( &one->_maxExtraCellularSpace ), sizeof( double ) );
1009  dbFile.write ( reinterpret_cast<char*> ( &one->_xRange ), sizeof( double ) );
1010  dbFile.write ( reinterpret_cast<char*> ( &one->_yRange ), sizeof( double ) );
1011  dbFile.write ( reinterpret_cast<char*> ( &one->_zRange ), sizeof( double ) );
1012 
1013  hlpUInt = one->_shellPlacement.size();
1014  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
1015  for ( unsigned int it = 0; it < hlpUInt; it++ )
1016  {
1017  dbFile.write ( reinterpret_cast<char*> ( &one->_shellPlacement.at(it) ), sizeof( double ) );
1018  }
1019 
1020  dbFile.write ( reinterpret_cast<char*> ( &one->_mapResolution ), sizeof( double ) );
1021  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapU ), sizeof( unsigned int ) );
1022  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapV ), sizeof( unsigned int ) );
1023  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapW ), sizeof( unsigned int ) );
1024  dbFile.write ( reinterpret_cast<char*> ( &one->_densityMapComputed ), sizeof( bool ) );
1025  dbFile.write ( reinterpret_cast<char*> ( &one->_mapMean ), sizeof( double ) );
1026  dbFile.write ( reinterpret_cast<char*> ( &one->_mapSdev ), sizeof( double ) );
1027  dbFile.write ( reinterpret_cast<char*> ( &one->_fourierCoeffPower ), sizeof( double ) );
1028  dbFile.write ( reinterpret_cast<char*> ( &one->_bFactorChange ), sizeof( double ) );
1029  dbFile.write ( reinterpret_cast<char*> ( &one->_maxMapRange ), sizeof( double ) );
1030  dbFile.write ( reinterpret_cast<char*> ( &one->_phaseRemoved ), sizeof( bool ) );
1031  dbFile.write ( reinterpret_cast<char*> ( &one->_usePhase ), sizeof( bool ) );
1032  dbFile.write ( reinterpret_cast<char*> ( &one->_keepOrRemove ), sizeof( bool ) );
1033  dbFile.write ( reinterpret_cast<char*> ( &one->_thetaAngle ), sizeof( double ) );
1034  dbFile.write ( reinterpret_cast<char*> ( &one->_phiAngle ), sizeof( double ) );
1035  dbFile.write ( reinterpret_cast<char*> ( &one->_noShellsWithData ), sizeof( unsigned int ) );
1036  dbFile.write ( reinterpret_cast<char*> ( &one->_xCorrection ), sizeof( unsigned int ) );
1037  dbFile.write ( reinterpret_cast<char*> ( &one->_yCorrection ), sizeof( unsigned int ) );
1038  dbFile.write ( reinterpret_cast<char*> ( &one->_zCorrection ), sizeof( unsigned int ) );
1039  dbFile.write ( reinterpret_cast<char*> ( &one->_xCorrErr ), sizeof( double ) );
1040  dbFile.write ( reinterpret_cast<char*> ( &one->_yCorrErr ), sizeof( double ) );
1041  dbFile.write ( reinterpret_cast<char*> ( &one->_zCorrErr ), sizeof( double ) );
1042  dbFile.write ( reinterpret_cast<char*> ( &one->_sphereMapped ), sizeof( bool ) );
1043  dbFile.write ( reinterpret_cast<char*> ( &one->_firstLineCOM ), sizeof( bool ) );
1044  dbFile.write ( reinterpret_cast<char*> ( &one->_bandwidthLimit ), sizeof( unsigned int ) );
1045  dbFile.write ( reinterpret_cast<char*> ( &one->_oneDimmension ), sizeof( unsigned int ) );
1046  dbFile.write ( reinterpret_cast<char*> ( &one->_sphericalCoefficientsComputed ), sizeof( bool ) );
1047  dbFile.write ( reinterpret_cast<char*> ( &one->_rrpMatricesPrecomputed ), sizeof( bool ) );
1048 
1049  //==================================== Save spherical harmonics values
1050  for ( unsigned int sh = 0; sh < one->_noShellsWithData; sh++ )
1051  {
1052  for ( unsigned int arrIt = 0; arrIt < ( one->_oneDimmension * one->_oneDimmension ); arrIt++ )
1053  {
1054  dbFile.write ( reinterpret_cast<char*> ( &one->_realSHCoeffs[sh][arrIt] ), sizeof( double ) );
1055  dbFile.write ( reinterpret_cast<char*> ( &one->_imagSHCoeffs[sh][arrIt] ), sizeof( double ) );
1056  }
1057  }
1058 
1059  //==================================== Save RRP matrices values
1060  for ( unsigned int bnIt = 0; bnIt < one->_bandwidthLimit; bnIt++ )
1061  {
1062  if ( !one->_keepOrRemove ) { if ( ( bnIt % 2 ) != 0 ) { continue; } }
1063 
1064  for ( unsigned int sh1 = 0; sh1 < one->_noShellsWithData; sh1++ )
1065  {
1066  for ( unsigned int sh2 = 0; sh2 < one->_noShellsWithData; sh2++ )
1067  {
1068  dbFile.write ( reinterpret_cast<char*> ( &one->_rrpMatrices[bnIt][sh1][sh2] ), sizeof( double ) );
1069  }
1070  }
1071  }
1072 
1073  //==================================== If saveWithAndWithout is true, save the other phase option as well
1074  if ( saveWithAndWithout )
1075  {
1076  //================================ Save maps as well as the XYZ from/to values
1077  if ( one->_usePhase )
1078  {
1079  dbFile.write ( reinterpret_cast<char*> ( &one->_xFrom ), sizeof( double ) );
1080  dbFile.write ( reinterpret_cast<char*> ( &one->_xTo ), sizeof( double ) );
1081  dbFile.write ( reinterpret_cast<char*> ( &one->_yFrom ), sizeof( double ) );
1082  dbFile.write ( reinterpret_cast<char*> ( &one->_yTo ), sizeof( double ) );
1083  dbFile.write ( reinterpret_cast<char*> ( &one->_zFrom ), sizeof( double ) );
1084  dbFile.write ( reinterpret_cast<char*> ( &one->_zTo ), sizeof( double ) );
1085 
1086  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( (one->_maxMapU+1) * (one->_maxMapV+1) * (one->_maxMapW+1) ); mIt++ )
1087  {
1088  dbFile.write ( reinterpret_cast<char*> ( &one->_densityMapCor[mIt] ), sizeof( double ) );
1089  }
1090  }
1091 
1092  //================================ Reverse phase
1093  settings->usePhase = !this->usePhase;
1094 
1095  //================================ Create ProSHADE_data object to hold data and compute information
1096  ProSHADE_data* two = new ProSHADE_data ();
1097 
1098  //================================ Re-set settings
1099  this->bandwidth = settings->bandwidth;
1100  this->glIntegOrder = settings->glIntegOrder;
1101  this->theta = settings->theta;
1102  this->phi = settings->phi;
1103  this->extraSpace = settings->extraSpace;
1104 
1105  //==================================== Read in the structure into two
1106  unsigned int fileType = checkFileType ( settings->structFiles.at(iter) );
1107  if ( fileType == 2 )
1108  {
1109  two->getDensityMapFromMAP ( settings->structFiles.at(iter),
1110  &this->shellSpacing,
1111  this->mapResolution,
1112  &this->bandwidth,
1113  &this->theta,
1114  &this->phi,
1115  &this->glIntegOrder,
1116  &this->extraSpace,
1117  settings->mapResDefault,
1118  settings->rotChangeDefault,
1119  settings,
1120  settings->overlayDefaults );
1121  }
1122  else if ( fileType == 1 )
1123  {
1124  two->getDensityMapFromPDB ( settings->structFiles.at(iter),
1125  &this->shellSpacing,
1126  this->mapResolution,
1127  &this->bandwidth,
1128  &this->theta,
1129  &this->phi,
1130  &this->glIntegOrder,
1131  &this->extraSpace,
1132  settings->mapResDefault,
1133  settings,
1134  this->bFactorValue,
1135  this->firstLineCOM );
1136  }
1137  else
1138  {
1139  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;
1140 
1141  if ( settings->htmlReport )
1142  {
1143  std::stringstream hlpSS;
1144  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(iter) << "." << "</font>";
1145  rvapi_set_text ( hlpSS.str().c_str(),
1146  "ProgressSection",
1147  settings->htmlReportLineProgress,
1148  1,
1149  1,
1150  1 );
1151  settings->htmlReportLineProgress += 1;
1152  rvapi_flush ( );
1153  }
1154 
1155  exit ( -1 );
1156  }
1157 
1158  if ( settings->verbose > 3 )
1159  {
1160  std::cout << ">>>>> Structure loaded." << std::endl;
1161  }
1162 
1163  //================================ Deal with the centering and MAP data format, if applicable
1164  two->normaliseMap ( settings );
1165  if ( settings->usePhase )
1166  {
1167  two->keepPhaseInMap ( this->alpha,
1168  this->bFactorChange,
1169  &this->bandwidth,
1170  &this->theta,
1171  &this->phi,
1172  &this->glIntegOrder,
1173  settings,
1174  this->useCOM,
1175  settings->noIQRsFromMap,
1176  settings->verbose,
1177  settings->clearMapData,
1178  settings->rotChangeDefault,
1179  settings->overlayDefaults,
1180  settings->maskBlurFactor,
1181  false );
1182  }
1183  else
1184  {
1185  two->removePhaseFromMap ( this->alpha,
1186  this->bFactorChange,
1187  settings );
1188  }
1189 
1190  //================================ Map the density onto spheres
1191  two->mapPhaselessToSphere ( settings,
1192  this->theta,
1193  this->phi,
1194  this->shellSpacing,
1195  settings->manualShells );
1196 
1197  //================================ Compute the Spherical Harmonics (SH) coefficients
1198  two->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1199  if ( settings->verbose > 3 )
1200  {
1201  std::cout << ">>>>> Spherical harmonics computed (phase reverse)." << std::endl;
1202  }
1203 
1204  //================================ Pre-compute the RRP matrices
1205  two->precomputeRotInvDescriptor ( settings );
1206 
1207  //================================ Save file settings
1208  dbFile.write ( reinterpret_cast<char*> ( &two->_fromPDB ), sizeof( bool ) );
1209  dbFile.write ( reinterpret_cast<char*> ( &two->_shellSpacing ), sizeof( double ) );
1210  dbFile.write ( reinterpret_cast<char*> ( &two->_maxExtraCellularSpace ), sizeof( double ) );
1211  dbFile.write ( reinterpret_cast<char*> ( &two->_xRange ), sizeof( double ) );
1212  dbFile.write ( reinterpret_cast<char*> ( &two->_yRange ), sizeof( double ) );
1213  dbFile.write ( reinterpret_cast<char*> ( &two->_zRange ), sizeof( double ) );
1214 
1215  hlpUInt = two->_shellPlacement.size();
1216  dbFile.write ( reinterpret_cast<char*> ( &hlpUInt ), sizeof( unsigned int ) );
1217  for ( unsigned int it = 0; it < hlpUInt; it++ )
1218  {
1219  dbFile.write ( reinterpret_cast<char*> ( &two->_shellPlacement.at(it) ), sizeof( double ) );
1220  }
1221 
1222  dbFile.write ( reinterpret_cast<char*> ( &two->_mapResolution ), sizeof( double ) );
1223  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapU ), sizeof( unsigned int ) );
1224  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapV ), sizeof( unsigned int ) );
1225  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapW ), sizeof( unsigned int ) );
1226  dbFile.write ( reinterpret_cast<char*> ( &two->_densityMapComputed ), sizeof( bool ) );
1227  dbFile.write ( reinterpret_cast<char*> ( &two->_mapMean ), sizeof( double ) );
1228  dbFile.write ( reinterpret_cast<char*> ( &two->_mapSdev ), sizeof( double ) );
1229  dbFile.write ( reinterpret_cast<char*> ( &two->_fourierCoeffPower ), sizeof( double ) );
1230  dbFile.write ( reinterpret_cast<char*> ( &two->_bFactorChange ), sizeof( double ) );
1231  dbFile.write ( reinterpret_cast<char*> ( &two->_maxMapRange ), sizeof( double ) );
1232  dbFile.write ( reinterpret_cast<char*> ( &two->_phaseRemoved ), sizeof( bool ) );
1233  dbFile.write ( reinterpret_cast<char*> ( &two->_usePhase ), sizeof( bool ) );
1234  dbFile.write ( reinterpret_cast<char*> ( &two->_keepOrRemove ), sizeof( bool ) );
1235  dbFile.write ( reinterpret_cast<char*> ( &two->_thetaAngle ), sizeof( double ) );
1236  dbFile.write ( reinterpret_cast<char*> ( &two->_phiAngle ), sizeof( double ) );
1237  dbFile.write ( reinterpret_cast<char*> ( &two->_noShellsWithData ), sizeof( unsigned int ) );
1238  dbFile.write ( reinterpret_cast<char*> ( &two->_xCorrection ), sizeof( unsigned int ) );
1239  dbFile.write ( reinterpret_cast<char*> ( &two->_yCorrection ), sizeof( unsigned int ) );
1240  dbFile.write ( reinterpret_cast<char*> ( &two->_zCorrection ), sizeof( unsigned int ) );
1241  dbFile.write ( reinterpret_cast<char*> ( &two->_xCorrErr ), sizeof( double ) );
1242  dbFile.write ( reinterpret_cast<char*> ( &two->_yCorrErr ), sizeof( double ) );
1243  dbFile.write ( reinterpret_cast<char*> ( &two->_zCorrErr ), sizeof( double ) );
1244  dbFile.write ( reinterpret_cast<char*> ( &two->_sphereMapped ), sizeof( bool ) );
1245  dbFile.write ( reinterpret_cast<char*> ( &two->_firstLineCOM ), sizeof( bool ) );
1246  dbFile.write ( reinterpret_cast<char*> ( &two->_bandwidthLimit ), sizeof( unsigned int ) );
1247  dbFile.write ( reinterpret_cast<char*> ( &two->_oneDimmension ), sizeof( unsigned int ) );
1248  dbFile.write ( reinterpret_cast<char*> ( &two->_sphericalCoefficientsComputed ), sizeof( bool ) );
1249  dbFile.write ( reinterpret_cast<char*> ( &two->_rrpMatricesPrecomputed ), sizeof( bool ) );
1250 
1251  //================================ Save spherical harmonics values
1252  for ( unsigned int sh = 0; sh < two->_noShellsWithData; sh++ )
1253  {
1254  for ( unsigned int arrIt = 0; arrIt < ( two->_oneDimmension * two->_oneDimmension ); arrIt++ )
1255  {
1256  dbFile.write ( reinterpret_cast<char*> ( &two->_realSHCoeffs[sh][arrIt] ), sizeof( double ) );
1257  dbFile.write ( reinterpret_cast<char*> ( &two->_imagSHCoeffs[sh][arrIt] ), sizeof( double ) );
1258  }
1259  }
1260 
1261  //================================ Save RRP matrices values
1262  for ( unsigned int bnIt = 0; bnIt < two->_bandwidthLimit; bnIt++ )
1263  {
1264  if ( !two->_keepOrRemove ) { if ( ( bnIt % 2 ) != 0 ) { continue; } }
1265 
1266  for ( unsigned int sh1 = 0; sh1 < two->_noShellsWithData; sh1++ )
1267  {
1268  for ( unsigned int sh2 = 0; sh2 < two->_noShellsWithData; sh2++ )
1269  {
1270  dbFile.write ( reinterpret_cast<char*> ( &two->_rrpMatrices[bnIt][sh1][sh2] ), sizeof( double ) );
1271  }
1272  }
1273  }
1274 
1275  //================================ Save maps as well
1276  if ( two->_usePhase )
1277  {
1278  dbFile.write ( reinterpret_cast<char*> ( &two->_xFrom ), sizeof( double ) );
1279  dbFile.write ( reinterpret_cast<char*> ( &two->_xTo ), sizeof( double ) );
1280  dbFile.write ( reinterpret_cast<char*> ( &two->_yFrom ), sizeof( double ) );
1281  dbFile.write ( reinterpret_cast<char*> ( &two->_yTo ), sizeof( double ) );
1282  dbFile.write ( reinterpret_cast<char*> ( &two->_zFrom ), sizeof( double ) );
1283  dbFile.write ( reinterpret_cast<char*> ( &two->_zTo ), sizeof( double ) );
1284 
1285  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( two->_maxMapU * two->_maxMapV * two->_maxMapW ); mIt++ )
1286  {
1287  dbFile.write ( reinterpret_cast<char*> ( &two->_densityMapCor[mIt] ), sizeof( double ) );
1288  }
1289  }
1290 
1291  //==================================== Clean up
1292  delete two;
1293  }
1294 
1295  if ( settings->verbose > 3 )
1296  {
1297  std::cout << ">>>>> Structure saved." << std::endl;
1298  }
1299 
1300  if ( settings->htmlReport )
1301  {
1302  std::stringstream hlpSS;
1303  hlpSS << "<font color=\"green\">" << "File " << this->structFiles.at(iter) << " successfully saved to the database file." << "</font>";
1304  rvapi_set_text ( hlpSS.str().c_str(),
1305  "DBFilesSection",
1306  filesSectionIter,
1307  1,
1308  1,
1309  1 );
1310  filesSectionIter += 1;
1311 
1312  rvapi_flush ( );
1313  }
1314 
1315  //==================================== Clean up
1316  delete one;
1317  }
1318 
1319  if ( settings->htmlReport )
1320  {
1321  std::stringstream hlpSS;
1322  hlpSS << "<font color=\"green\">" << "File processing complete." << "</font>";
1323  rvapi_set_text ( hlpSS.str().c_str(),
1324  "ProgressSection",
1325  settings->htmlReportLineProgress,
1326  1,
1327  1,
1328  1 );
1329  settings->htmlReportLineProgress += 1;
1330 
1331  rvapi_flush ( );
1332  }
1333 
1334  //======================================== Close output file and done
1335  dbFile.close ( );
1336 
1337  //======================================== Done
1338  return ;
1339 }
1340 
1361  std::vector<std::string>* matchedStrNames )
1362 {
1363  //======================================== Local variables
1364  unsigned int hlpUInt, hlpUInt2;
1365  char* hlpChar;
1366  std::vector<std::string> dbStrNames;
1367  double minVol = 0.0;
1368 
1369  //======================================== Open the database file
1370  std::ifstream dbFile ( settings->databaseName, std::ios::in | std::ios::binary);
1371 
1372  //======================================== Check the database file
1373  if ( dbFile.fail() )
1374  {
1375  std::cerr << "!!! ProSHADE ERROR !!! Cannot open the database file for reading " << settings->databaseName << " . Terminating..." << std::endl;
1376 
1377  if ( settings->htmlReport )
1378  {
1379  std::stringstream hlpSS;
1380  hlpSS << "<font color=\"red\">" << "Cannot open database with name " << settings->databaseName << ". Could you have no permissions to write to the requested database location?" << "</font>";
1381  rvapi_set_text ( hlpSS.str().c_str(),
1382  "ProgressSection",
1383  settings->htmlReportLineProgress,
1384  1,
1385  1,
1386  1 );
1387  settings->htmlReportLineProgress += 1;
1388  rvapi_flush ( );
1389  }
1390 
1391  exit ( -1 );
1392  }
1393 
1394  if ( settings->verbose > 3 )
1395  {
1396  std::cout << ">>>>>>>> Database file opened." << std::endl;
1397  }
1398 
1399  if ( settings->htmlReport )
1400  {
1401  //==================================== Record progress
1402  std::stringstream hlpSS;
1403  hlpSS << "<font color=\"green\">" << "Database reading initiated." << "</font>";
1404  rvapi_set_text ( hlpSS.str().c_str(),
1405  "ProgressSection",
1406  settings->htmlReportLineProgress,
1407  1,
1408  1,
1409  1 );
1410  settings->htmlReportLineProgress += 1;
1411  rvapi_flush ( );
1412  }
1413 
1414  //======================================== Save the user input which is related to comparison and should not be loeaded from the database
1415  this->enLevelsThreshold = settings->enLevelsThreshold;
1416  this->trSigmaThreshold = settings->trSigmaThreshold;
1417 
1418  //======================================== Read in the database settings
1419  dbFile.read ( reinterpret_cast<char*> ( &minVol ), sizeof ( double ) );
1420  if ( minVol == 0.0 )
1421  {
1422  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;
1423 
1424  if ( settings->htmlReport )
1425  {
1426  std::stringstream hlpSS;
1427  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>";
1428  rvapi_set_text ( hlpSS.str().c_str(),
1429  "ProgressSection",
1430  settings->htmlReportLineProgress,
1431  1,
1432  1,
1433  1 );
1434  settings->htmlReportLineProgress += 1;
1435  rvapi_flush ( );
1436  }
1437 
1438  exit ( -1 );
1439  }
1440 
1441  dbFile.read ( reinterpret_cast<char*> ( &settings->mapResolution ), sizeof ( double ) );
1442  dbFile.read ( reinterpret_cast<char*> ( &settings->bandwidth ), sizeof ( unsigned int ) );
1443  dbFile.read ( reinterpret_cast<char*> ( &settings->glIntegOrder ), sizeof ( unsigned int ) );
1444  dbFile.read ( reinterpret_cast<char*> ( &settings->theta ), sizeof ( unsigned int ) );
1445  dbFile.read ( reinterpret_cast<char*> ( &settings->phi ), sizeof ( unsigned int ) );
1446  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorValue ), sizeof ( double ) );
1447  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorChange ), sizeof ( double ) );
1448  dbFile.read ( reinterpret_cast<char*> ( &settings->noIQRsFromMap ), sizeof ( double ) );
1449  dbFile.read ( reinterpret_cast<char*> ( &settings->maskBlurFactor ), sizeof ( double ) );
1450  dbFile.read ( reinterpret_cast<char*> ( &settings->shellSpacing ), sizeof ( double ) );
1451  dbFile.read ( reinterpret_cast<char*> ( &settings->manualShells ), sizeof ( unsigned int ) );
1452  dbFile.read ( reinterpret_cast<char*> ( &settings->usePhase ), sizeof ( bool ) );
1453  dbFile.read ( reinterpret_cast<char*> ( &settings->saveWithAndWithout ), sizeof ( bool ) );
1454  dbFile.read ( reinterpret_cast<char*> ( &settings->useCOM ), sizeof ( bool ) );
1455  dbFile.read ( reinterpret_cast<char*> ( &settings->firstLineCOM ), sizeof ( bool ) );
1456  dbFile.read ( reinterpret_cast<char*> ( &settings->alpha ), sizeof ( double ) );
1457  dbFile.read ( reinterpret_cast<char*> ( &settings->mPower ), sizeof ( double ) );
1458 
1459  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1460  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
1461  {
1462  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
1463  settings->ignoreLs.emplace_back ( hlpUInt2 );
1464  }
1465 
1466  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1467  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
1468  {
1469  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
1470  hlpChar = new char[hlpUInt2+1];
1471  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt2 );
1472  hlpChar[hlpUInt2] = '\0';
1473  dbStrNames.emplace_back ( hlpChar );
1474  }
1475  dbFile.read ( reinterpret_cast<char*> ( &settings->peakHeightNoIQRs ), sizeof ( double ) );
1476  dbFile.read ( reinterpret_cast<char*> ( &settings->peakDistanceForReal ), sizeof ( double ) );
1477  dbFile.read ( reinterpret_cast<char*> ( &settings->peakSurroundingPoints ), sizeof ( int ) );
1478  dbFile.read ( reinterpret_cast<char*> ( &settings->aaErrorTolerance ), sizeof ( double ) );
1479  dbFile.read ( reinterpret_cast<char*> ( &settings->symGapTolerance ), sizeof ( double ) );
1480  dbFile.read ( reinterpret_cast<char*> ( &settings->energyLevelDist ), sizeof ( bool ) );
1481  dbFile.read ( reinterpret_cast<char*> ( &settings->traceSigmaDist ), sizeof ( bool ) );
1482  dbFile.read ( reinterpret_cast<char*> ( &settings->fullRotFnDist ), sizeof ( bool ) );
1483  dbFile.read ( reinterpret_cast<char*> ( &settings->enLevelsThreshold ), sizeof ( double ) );
1484  dbFile.read ( reinterpret_cast<char*> ( &settings->trSigmaThreshold ), sizeof ( double ) );
1485  dbFile.read ( reinterpret_cast<char*> ( &settings->taskToPerform ), sizeof ( ProSHADE::Task ) );
1486 
1487  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1488  hlpChar = new char[hlpUInt+1];
1489  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
1490  hlpChar[hlpUInt] = '\0';
1491  settings->clearMapFile = std::string ( hlpChar );
1492 
1493  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
1494  hlpChar = new char[hlpUInt+1];
1495  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
1496  hlpChar[hlpUInt] = '\0';
1497  settings->mapFragName = std::string ( hlpChar );
1498 
1499  //======================================== Save the settings
1500  this->mapResolution = settings->mapResolution;
1501  this->bandwidth = settings->bandwidth;
1502  this->glIntegOrder = settings->glIntegOrder;
1503  this->theta = settings->theta;
1504  this->phi = settings->phi;
1505  this->bFactorValue = settings->bFactorValue;
1506  this->bFactorChange = settings->bFactorChange;
1507  this->noIQRsFromMap = settings->noIQRsFromMap;
1508  this->shellSpacing = settings->shellSpacing;
1509  this->manualShells = settings->manualShells;
1510  this->useCOM = settings->useCOM;
1511  this->firstLineCOM = settings->firstLineCOM;
1512  this->extraSpace = settings->extraSpace;
1513  this->alpha = settings->alpha;
1514  this->mPower = settings->mPower;
1515  this->ignoreLs = settings->ignoreLs;
1516  this->energyLevelDist = settings->energyLevelDist;
1517  this->traceSigmaDist = settings->traceSigmaDist;
1518  this->fullRotFnDist = settings->fullRotFnDist;
1519  this->usePhase = settings->usePhase;
1520  this->saveWithAndWithout = settings->saveWithAndWithout;
1521  this->structFiles = settings->structFiles;
1522 
1523  if ( settings->verbose > 3 )
1524  {
1525  std::cout << ">>>>>>>> Database settings loaded." << std::endl;
1526  }
1527 
1528 
1529  if ( settings->htmlReport )
1530  {
1531  //==================================== Record progress
1532  std::stringstream hlpSS;
1533  hlpSS << "<font color=\"green\">" << "Database settings read." << "</font>";
1534  rvapi_set_text ( hlpSS.str().c_str(),
1535  "ProgressSection",
1536  settings->htmlReportLineProgress,
1537  1,
1538  1,
1539  1 );
1540  settings->htmlReportLineProgress += 1;
1541  rvapi_flush ( );
1542  }
1543 
1544  //======================================== Now create the one strucutre, so that its dimmensions may be used for reducing the number of read structures
1545  ProSHADE_data* one = new ProSHADE_data ();
1546 
1547  //======================================== Read in into one
1548  matchedStrNames->clear ( );
1549  matchedStrNames->emplace_back ( structFiles.at(0) );
1550  unsigned int fileType = checkFileType ( structFiles.at(0) );
1551  if ( fileType == 2 )
1552  {
1553  one->getDensityMapFromMAP ( this->structFiles.at(0),
1554  &this->shellSpacing,
1555  this->mapResolution,
1556  &this->bandwidth,
1557  &this->theta,
1558  &this->phi,
1559  &this->glIntegOrder,
1560  &this->extraSpace,
1561  settings->mapResDefault,
1562  settings->rotChangeDefault,
1563  settings,
1564  settings->overlayDefaults );
1565  }
1566  else if ( fileType == 1 )
1567  {
1568  one->getDensityMapFromPDB ( this->structFiles.at(0),
1569  &this->shellSpacing,
1570  this->mapResolution,
1571  &this->bandwidth,
1572  &this->theta,
1573  &this->phi,
1574  &this->glIntegOrder,
1575  &this->extraSpace,
1576  settings->mapResDefault,
1577  settings,
1578  this->bFactorValue,
1579  this->firstLineCOM );
1580  }
1581  else
1582  {
1583  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;
1584 
1585  if ( settings->htmlReport )
1586  {
1587  std::stringstream hlpSS;
1588  hlpSS << "<font color=\"red\">" << "Cannot open file named " << this->structFiles.at(0) << " ." << "</font>";
1589  rvapi_set_text ( hlpSS.str().c_str(),
1590  "ProgressSection",
1591  settings->htmlReportLineProgress,
1592  1,
1593  1,
1594  1 );
1595  settings->htmlReportLineProgress += 1;
1596  rvapi_flush ( );
1597  }
1598 
1599  exit ( -1 );
1600  }
1601  if ( settings->verbose > 0 )
1602  {
1603  std::cout << "Structure 0 loaded." << std::endl;
1604  }
1605 
1606  if ( settings->htmlReport )
1607  {
1608  //==================================== Record progress
1609  std::stringstream hlpSS;
1610  hlpSS << "<font color=\"green\">" << "Sought structure loaded." << "</font>";
1611  rvapi_set_text ( hlpSS.str().c_str(),
1612  "ProgressSection",
1613  settings->htmlReportLineProgress,
1614  1,
1615  1,
1616  1 );
1617  settings->htmlReportLineProgress += 1;
1618  rvapi_flush ( );
1619  }
1620 
1621  //======================================== Deal with the centering and MAP data format, if applicable
1622  one->normaliseMap ( settings );
1623  if ( this->usePhase )
1624  {
1625  one->keepPhaseInMap ( this->alpha,
1626  this->bFactorChange,
1627  &this->bandwidth,
1628  &this->theta,
1629  &this->phi,
1630  &this->glIntegOrder,
1631  settings,
1632  this->useCOM,
1633  settings->noIQRsFromMap,
1634  settings->verbose,
1635  settings->clearMapData,
1636  settings->rotChangeDefault,
1637  settings->overlayDefaults,
1638  settings->maskBlurFactor,
1639  false );
1640  }
1641  else
1642  {
1643  one->removePhaseFromMap ( this->alpha,
1644  this->bFactorChange,
1645  settings );
1646  }
1647 
1648  //======================================== Map the density onto spheres
1649  one->mapPhaselessToSphere ( settings,
1650  this->theta,
1651  this->phi,
1652  this->shellSpacing,
1653  settings->manualShells );
1654 
1655  //======================================== Compute the Spherical Harmonics (SH) coefficients
1656  one->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1657 
1658  //======================================== If required, pre-compute the energy levels distance descriptor
1659  if ( this->energyLevelDist )
1660  {
1661  one->precomputeRotInvDescriptor ( settings );
1662  }
1663  if ( settings->verbose > 3 )
1664  {
1665  std::cout << ">>>>>>>> Structure 0 spherical harmonics computed." << std::endl;
1666  }
1667 
1668  int structIterHTML = 0;
1669  if ( settings->htmlReport )
1670  {
1671  //==================================== Create section
1672  rvapi_add_section ( "FilesSection",
1673  "List of structures",
1674  "body",
1675  settings->htmlReportLine,
1676  0,
1677  1,
1678  1,
1679  false );
1680  settings->htmlReportLine += 1;
1681 
1682  std::stringstream hlpSS;
1683  hlpSS << "<font color=\"green\">" << "Structure to compare against the rest: " << this->structFiles.at(0) << "</font>";
1684  rvapi_set_text ( hlpSS.str().c_str(),
1685  "FilesSection",
1686  structIterHTML,
1687  1,
1688  1,
1689  1 );
1690  structIterHTML += 1;
1691 
1692  rvapi_flush ( );
1693  }
1694 
1695  //======================================== Read in the database data into ProSHADE_data objects
1696  double volTolerance = ( 1.0 - settings->volumeTolerance );
1697  double volMin = ( ( static_cast<double> ( (one->_xRange-this->extraSpace) ) * volTolerance ) *
1698  ( static_cast<double> ( (one->_yRange-this->extraSpace) ) * volTolerance ) *
1699  ( static_cast<double> ( (one->_zRange-this->extraSpace) ) * volTolerance ) );
1700  volTolerance = ( 1.0 + settings->volumeTolerance );
1701  double volMax = ( ( static_cast<double> ( (one->_xRange-this->extraSpace) ) * volTolerance ) *
1702  ( static_cast<double> ( (one->_yRange-this->extraSpace) ) * volTolerance ) *
1703  ( static_cast<double> ( (one->_zRange-this->extraSpace) ) * volTolerance ) );
1704  std::vector<ProSHADE_data*> dbData;
1705  bool foundAlready = false;
1706  bool tooFarAlready = false;
1707  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbStrNames.size() ); strIt++ )
1708  {
1709  if ( tooFarAlready ) { break; }
1710 
1711  if ( settings->verbose > 2 )
1712  {
1713  std::cout << ">>>>> Starting to load structure " << strIt+1 << " from the database." << std::endl;
1714  }
1715 
1716  if ( !this->saveWithAndWithout )
1717  {
1718  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings ) );
1719 
1720  if ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 )
1721  {
1722  if ( foundAlready ) { tooFarAlready = true; }
1723 
1724  dbData.pop_back ( );
1725  if ( settings->verbose > 0 )
1726  {
1727  std::cout << "Structure " << strIt+1 << " read from the database, but will not be used - too different dimmensions - see the \'--dbSizeLim\' option." << std::endl;
1728 
1729  if ( settings->htmlReport )
1730  {
1731  std::stringstream hlpSS;
1732  hlpSS << "<font color=\"orange\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be ignored." << "</font>";
1733  rvapi_set_text ( hlpSS.str().c_str(),
1734  "FilesSection",
1735  structIterHTML,
1736  1,
1737  1,
1738  1 );
1739  structIterHTML += 1;
1740  }
1741  }
1742  }
1743  else
1744  {
1745  foundAlready = true;
1746  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
1747  if ( settings->verbose > 0 )
1748  {
1749  std::cout << "Structure " << strIt+1 << " read from the database." << std::endl;
1750  }
1751 
1752  if ( settings->htmlReport )
1753  {
1754  std::stringstream hlpSS;
1755  hlpSS << "<font color=\"green\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be used." << "</font>";
1756  rvapi_set_text ( hlpSS.str().c_str(),
1757  "FilesSection",
1758  structIterHTML,
1759  1,
1760  1,
1761  1 );
1762  structIterHTML += 1;
1763  }
1764  }
1765  }
1766  else
1767  {
1768  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings, this->saveWithAndWithout ) );
1769  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), volMin, volMax, settings->verbose, settings, this->saveWithAndWithout ) );
1770 
1771  if ( ( dbData.at(dbData.size()-2)->_mapResolution == -999.9 ) || ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 ) )
1772  {
1773  if ( foundAlready ) { tooFarAlready = true; }
1774 
1775  dbData.pop_back ( );
1776  dbData.pop_back ( );
1777  if ( settings->verbose > 0 )
1778  {
1779  std::cout << "Structure " << strIt+1 << " read from the database, but will not be used - too different dimmensions - see the \'--dbSizeLim\' option." << std::endl;
1780 
1781  if ( settings->htmlReport )
1782  {
1783  std::stringstream hlpSS;
1784  hlpSS << "<font color=\"orange\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be ignored." << "</font>";
1785  rvapi_set_text ( hlpSS.str().c_str(),
1786  "FilesSection",
1787  structIterHTML,
1788  1,
1789  1,
1790  1 );
1791  structIterHTML += 1;
1792  }
1793  }
1794  }
1795  else
1796  {
1797  foundAlready = true;
1798  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
1799  if ( settings->verbose > 0 )
1800  {
1801  std::cout << "Structure " << strIt+1 << " read from the database." << std::endl;
1802  }
1803 
1804  if ( settings->htmlReport )
1805  {
1806  std::stringstream hlpSS;
1807  hlpSS << "<font color=\"green\">" << " ... database entry " << strIt+1 << ": " << dbStrNames.at(strIt) << " will be used." << "</font>";
1808  rvapi_set_text ( hlpSS.str().c_str(),
1809  "FilesSection",
1810  structIterHTML,
1811  1,
1812  1,
1813  1 );
1814  structIterHTML += 1;
1815  }
1816  }
1817  }
1818  }
1819 
1820  if ( settings->htmlReport )
1821  {
1822  //==================================== Record progress
1823  std::stringstream hlpSS;
1824  hlpSS << "<font color=\"green\">" << "Database imported." << "</font>";
1825  rvapi_set_text ( hlpSS.str().c_str(),
1826  "ProgressSection",
1827  settings->htmlReportLineProgress,
1828  1,
1829  1,
1830  1 );
1831  settings->htmlReportLineProgress += 1;
1832  rvapi_flush ( );
1833  }
1834 
1835  //======================================== Check for not finding any size matches
1836  if ( dbData.size() == 0 )
1837  {
1838  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;
1839 
1840  if ( settings->htmlReport )
1841  {
1842  std::stringstream hlpSS;
1843  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>";
1844  rvapi_set_text ( hlpSS.str().c_str(),
1845  "ProgressSection",
1846  settings->htmlReportLineProgress,
1847  1,
1848  1,
1849  1 );
1850  settings->htmlReportLineProgress += 1;
1851  rvapi_flush ( );
1852  }
1853 
1854  exit ( 0 );
1855  }
1856 
1857  //======================================== Now create the two strucutre in case it is being used with both phase and reverse phase
1858  ProSHADE_data* two = new ProSHADE_data ();
1859 
1860  //======================================== Create the compare against all object
1861  if ( !this->saveWithAndWithout )
1862  {
1863  this->cmpObj = new ProSHADE_compareOneAgainstAll ( one, &dbData, this->ignoreLs, this->mPower, settings->verbose );
1864  }
1865  else
1866  {
1867  //==================================== Read in into one
1868  fileType = checkFileType ( structFiles.at(0) );
1869  if ( fileType == 2 )
1870  {
1871  two->getDensityMapFromMAP ( this->structFiles.at(0),
1872  &this->shellSpacing,
1873  this->mapResolution,
1874  &this->bandwidth,
1875  &this->theta,
1876  &this->phi,
1877  &this->glIntegOrder,
1878  &this->extraSpace,
1879  settings->mapResDefault,
1880  settings->rotChangeDefault,
1881  settings,
1882  settings->overlayDefaults );
1883  }
1884  else if ( fileType == 1 )
1885  {
1886  two->getDensityMapFromPDB ( this->structFiles.at(0),
1887  &this->shellSpacing,
1888  this->mapResolution,
1889  &this->bandwidth,
1890  &this->theta,
1891  &this->phi,
1892  &this->glIntegOrder,
1893  &this->extraSpace,
1894  settings->mapResDefault,
1895  settings,
1896  this->bFactorValue,
1897  this->firstLineCOM );
1898  }
1899  else
1900  {
1901  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;
1902  exit (0);
1903  }
1904 
1905  //==================================== Deal with the centering and MAP data format, if applicable
1906  two->normaliseMap ( settings );
1907  if ( !this->usePhase )
1908  {
1909  two->keepPhaseInMap ( this->alpha,
1910  this->bFactorChange,
1911  &this->bandwidth,
1912  &this->theta,
1913  &this->phi,
1914  &this->glIntegOrder,
1915  settings,
1916  this->useCOM,
1917  settings->noIQRsFromMap,
1918  settings->verbose,
1919  settings->clearMapData,
1920  settings->rotChangeDefault,
1921  settings->overlayDefaults,
1922  settings->maskBlurFactor,
1923  false );
1924  }
1925  else
1926  {
1927  two->removePhaseFromMap ( this->alpha,
1928  this->bFactorChange,
1929  settings );
1930  }
1931 
1932  //==================================== Map the density onto spheres
1933  two->mapPhaselessToSphere ( settings,
1934  this->theta,
1935  this->phi,
1936  this->shellSpacing,
1937  settings->manualShells,
1938  true );
1939 
1940  //==================================== Compute the Spherical Harmonics (SH) coefficients
1941  two->getSphericalHarmonicsCoeffs ( this->bandwidth, settings );
1942 
1943  //==================================== If required, pre-compute the energy levels distance descriptor
1944  if ( this->energyLevelDist )
1945  {
1946  two->precomputeRotInvDescriptor ( settings );
1947  }
1948  if ( settings->verbose > 3 )
1949  {
1950  std::cout << ">>>>>>>> Structure 0 spherical harmonics computed (reverse phase)." << std::endl;
1951  }
1952 
1953  this->cmpObj = new ProSHADE_compareOneAgainstAll ( one, two, &dbData, this->ignoreLs, this->mPower, settings->verbose );
1954  }
1955 
1956  //======================================== Save the decision whether to use phases or not
1957  if ( one->_keepOrRemove ) { this->cmpObj->_keepOrRemove = true; }
1958  else { this->cmpObj->_keepOrRemove = false; }
1959 
1960  //======================================== If using both phased and reverse, compute the translated and rotated versions
1961  if ( this->saveWithAndWithout )
1962  {
1963  this->cmpObj->alignDensities ( settings );
1964  }
1965 
1966  //======================================== If required, compute the energy levels distances
1967  if ( this->energyLevelDist )
1968  {
1969  if ( settings->verbose > 0 )
1970  {
1971  std::cout << "Computing the cross-correlation distances." << std::endl;
1972  }
1973  if ( settings->htmlReport )
1974  {
1975  //==================================== Record progress
1976  std::stringstream hlpSS;
1977  hlpSS << "<font color=\"green\">" << "Computing the Energy Level distances." << "</font>";
1978  rvapi_set_text ( hlpSS.str().c_str(),
1979  "ProgressSection",
1980  settings->htmlReportLineProgress,
1981  1,
1982  1,
1983  1 );
1984  settings->htmlReportLineProgress += 1;
1985  rvapi_flush ( );
1986  }
1987 
1988  this->energyLevelsDistances = this->cmpObj->getEnergyLevelsDistance ( settings->verbose, settings );
1989 
1990  // ... and set which pairs not to follow further
1991  if ( this->enLevelsThreshold != -999.9 )
1992  {
1993  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
1994  {
1995  if ( this->enLevelsThreshold > this->energyLevelsDistances.at(iter) )
1996  {
1997  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 1 );
1998  }
1999  else
2000  {
2001  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2002  }
2003  }
2004  }
2005  else
2006  {
2007  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
2008  {
2009  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2010  }
2011  }
2012  }
2013  else
2014  {
2015  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
2016  {
2017  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
2018  }
2019  }
2020 
2021  //======================================== Remove all structures with null pointer (i.e. those not passing the size test)
2022  this->glIntegOrderVec = std::vector<unsigned int> ( dbData.size() + 1 );
2023  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbData.size() + 1 ); strIt++ )
2024  {
2025  this->glIntegOrderVec.at(strIt) = this->glIntegOrder;
2026  }
2027 
2028  //======================================== Pre-compute the E matrices in case either the trace sigmal or full rotation distance are required
2029  if ( this->traceSigmaDist || this->fullRotFnDist )
2030  {
2031  this->cmpObj->precomputeTrSigmaDescriptor ( this->shellSpacing, &this->glIntegOrderVec, settings );
2032  }
2033 
2034  //======================================== Compute the trace sigma distances, if required
2035  if ( this->traceSigmaDist )
2036  {
2037  if ( settings->verbose > 0 )
2038  {
2039  std::cout << "Computing the trace sigma distances." << std::endl;
2040  }
2041  if ( settings->htmlReport )
2042  {
2043  //==================================== Record progress
2044  std::stringstream hlpSS;
2045  hlpSS << "<font color=\"green\">" << "Computing Trace Sigma distances." << "</font>";
2046  rvapi_set_text ( hlpSS.str().c_str(),
2047  "ProgressSection",
2048  settings->htmlReportLineProgress,
2049  1,
2050  1,
2051  1 );
2052  settings->htmlReportLineProgress += 1;
2053  rvapi_flush ( );
2054  }
2055 
2056  this->traceSigmaDistances = this->cmpObj->getTrSigmaDistance ( settings->verbose, settings );
2057 
2058  if ( this->trSigmaThreshold == -999.9 )
2059  {
2060  this->cmpObj->_trSigmaDoNotFollow = this->cmpObj->_enLevelsDoNotFollow;
2061  }
2062  else
2063  {
2064  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
2065  {
2066  if ( this->trSigmaThreshold > this->traceSigmaDistances.at(iter) )
2067  {
2068  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 1 );
2069  }
2070  else
2071  {
2072  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
2073  }
2074  }
2075  }
2076  }
2077 
2078  //======================================== If full rotation distance is required, pre-compute the requirements
2079  if ( this->fullRotFnDist )
2080  {
2081  this->cmpObj->getSO3InverseMap ( settings );
2082  if ( settings->verbose > 1 )
2083  {
2084  std::cout << ">> Inverse SO(3) Fourier transform map computed." << std::endl;
2085  }
2086 
2087  this->cmpObj->getEulerAngles ( settings );
2088  if ( settings->verbose > 2 )
2089  {
2090  std::cout << ">>>>> Optimal Euler angles obtained." << std::endl;
2091  }
2092 
2093  this->cmpObj->generateWignerMatrices ( settings );
2094  if ( settings->verbose > 1 )
2095  {
2096  std::cout << ">> Wigner matrices calculated." << std::endl;
2097  }
2098 
2099  if ( settings->verbose > 0 )
2100  {
2101  std::cout << "Computing the rotation function distances." << std::endl;
2102  }
2103  if ( settings->htmlReport )
2104  {
2105  //==================================== Record progress
2106  std::stringstream hlpSS;
2107  hlpSS << "<font color=\"green\">" << "Computing Rotation Function distances." << "</font>";
2108  rvapi_set_text ( hlpSS.str().c_str(),
2109  "ProgressSection",
2110  settings->htmlReportLineProgress,
2111  1,
2112  1,
2113  1 );
2114  settings->htmlReportLineProgress += 1;
2115  rvapi_flush ( );
2116  }
2117 
2118  this->fullRotationDistances = this->cmpObj->getRotCoeffDistance ( settings->verbose, settings );
2119  }
2120 
2121  //======================================== Delete database entries
2122  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( iter ); iter++ )
2123  {
2124  if ( dbData.at(iter) != nullptr )
2125  {
2126  delete dbData.at(iter);
2127  dbData.at(iter) = nullptr;
2128  }
2129  }
2130  dbData.clear ( );
2131 
2132  //======================================== Done
2133  return ;
2134 }
2135 
2147  std::vector<std::string>* matchedStrNames )
2148 {
2149  //======================================== Local variables
2150  unsigned int hlpUInt, hlpUInt2;
2151  char* hlpChar;
2152  std::vector<std::string> dbStrNames;
2153  double minVol = 0.0;
2154 
2155  if ( settings->verbose > 0 )
2156  {
2157  std::cout << "Computing distances between map fragments and the structure database." << std::endl;
2158  }
2159 
2160  //======================================== Open the database file
2161  std::ifstream dbFile ( settings->databaseName, std::ios::in | std::ios::binary);
2162 
2163  //======================================== Check the database file
2164  if ( dbFile.fail() )
2165  {
2166  std::cerr << "!!! ProSHADE ERROR !!! Cannot open the database file for reading " << settings->databaseName << " . Terminating..." << std::endl;
2167 
2168  if ( settings->htmlReport )
2169  {
2170  std::stringstream hlpSS;
2171  hlpSS << "<font color=\"red\">" << "Cannot open database with name " << settings->databaseName << ". Could you have no permissions to write to the requested database location?" << "</font>";
2172  rvapi_set_text ( hlpSS.str().c_str(),
2173  "ProgressSection",
2174  settings->htmlReportLineProgress,
2175  1,
2176  1,
2177  1 );
2178  settings->htmlReportLineProgress += 1;
2179  rvapi_flush ( );
2180  }
2181 
2182  exit ( -1 );
2183  }
2184 
2185  //======================================== Check fragmentation settings
2186  if ( settings->mapFragBoxSize == 0.0 )
2187  {
2188  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;
2189 
2190  if ( settings->htmlReport )
2191  {
2192  std::stringstream hlpSS;
2193  hlpSS << "<font color=\"red\">" << "Missing the mandatory argument determining the fragmentation box size. Please supply it using the --mFrag command line option." << "</font>";
2194  rvapi_set_text ( hlpSS.str().c_str(),
2195  "ProgressSection",
2196  settings->htmlReportLineProgress,
2197  1,
2198  1,
2199  1 );
2200  settings->htmlReportLineProgress += 1;
2201  rvapi_flush ( );
2202  }
2203 
2204  exit ( -1 );
2205  }
2206  if ( !settings->usePhase )
2207  {
2208  std::cerr << "!!! ProSHADE ERROR !!! Requested map fragmentation without using phases - this does not make sense. Terminating..." << std::endl;
2209 
2210  if ( settings->htmlReport )
2211  {
2212  std::stringstream hlpSS;
2213  hlpSS << "<font color=\"red\">" << "Requested map fragmentation without using phases. This is not allowed." << "</font>";
2214  rvapi_set_text ( hlpSS.str().c_str(),
2215  "ProgressSection",
2216  settings->htmlReportLineProgress,
2217  1,
2218  1,
2219  1 );
2220  settings->htmlReportLineProgress += 1;
2221  rvapi_flush ( );
2222  }
2223 
2224  exit ( -1 );
2225  }
2226 
2227  if ( settings->verbose > 3 )
2228  {
2229  std::cout << ">>>>>>>> Database file opened for reading." << std::endl;
2230  }
2231 
2232  if ( settings->htmlReport )
2233  {
2234  std::stringstream hlpSS;
2235  hlpSS << "<font color=\"green\">" << "Database reading intialisation complete." << "</font>";
2236  rvapi_set_text ( hlpSS.str().c_str(),
2237  "ProgressSection",
2238  settings->htmlReportLineProgress,
2239  1,
2240  1,
2241  1 );
2242  settings->htmlReportLineProgress += 1;
2243 
2244  rvapi_flush ( );
2245  }
2246 
2247  //======================================== Save the user input which is related to comparison and should not be loeaded from the database
2248  this->enLevelsThreshold = settings->enLevelsThreshold;
2249  this->trSigmaThreshold = settings->trSigmaThreshold;
2250 
2251  //======================================== Set internal user settings
2252  bool userCOM = false;
2253  if ( settings->useCOM == true ) { userCOM = true; }
2254 
2255  //======================================== Read in the database settings
2256  dbFile.read ( reinterpret_cast<char*> ( &minVol ), sizeof ( double ) );
2257  if ( minVol == 0.0 )
2258  {
2259  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;
2260 
2261  if ( settings->htmlReport )
2262  {
2263  std::stringstream hlpSS;
2264  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>";
2265  rvapi_set_text ( hlpSS.str().c_str(),
2266  "ProgressSection",
2267  settings->htmlReportLineProgress,
2268  1,
2269  1,
2270  1 );
2271  settings->htmlReportLineProgress += 1;
2272  rvapi_flush ( );
2273  }
2274 
2275  exit ( -1 );
2276  }
2277 
2278  dbFile.read ( reinterpret_cast<char*> ( &settings->mapResolution ), sizeof ( double ) );
2279  dbFile.read ( reinterpret_cast<char*> ( &settings->bandwidth ), sizeof ( unsigned int ) );
2280  dbFile.read ( reinterpret_cast<char*> ( &settings->glIntegOrder ), sizeof ( unsigned int ) );
2281  dbFile.read ( reinterpret_cast<char*> ( &settings->theta ), sizeof ( unsigned int ) );
2282  dbFile.read ( reinterpret_cast<char*> ( &settings->phi ), sizeof ( unsigned int ) );
2283  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorValue ), sizeof ( double ) );
2284  dbFile.read ( reinterpret_cast<char*> ( &settings->bFactorChange ), sizeof ( double ) );
2285  dbFile.read ( reinterpret_cast<char*> ( &settings->noIQRsFromMap ), sizeof ( double ) );
2286  dbFile.read ( reinterpret_cast<char*> ( &settings->maskBlurFactor ), sizeof ( double ) );
2287  dbFile.read ( reinterpret_cast<char*> ( &settings->shellSpacing ), sizeof ( double ) );
2288  dbFile.read ( reinterpret_cast<char*> ( &settings->manualShells ), sizeof ( unsigned int ) );
2289  dbFile.read ( reinterpret_cast<char*> ( &settings->usePhase ), sizeof ( bool ) );
2290  dbFile.read ( reinterpret_cast<char*> ( &settings->saveWithAndWithout ), sizeof ( bool ) );
2291  dbFile.read ( reinterpret_cast<char*> ( &settings->useCOM ), sizeof ( bool ) );
2292  dbFile.read ( reinterpret_cast<char*> ( &settings->firstLineCOM ), sizeof ( bool ) );
2293  dbFile.read ( reinterpret_cast<char*> ( &settings->alpha ), sizeof ( double ) );
2294  dbFile.read ( reinterpret_cast<char*> ( &settings->mPower ), sizeof ( double ) );
2295 
2296  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2297  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
2298  {
2299  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
2300  settings->ignoreLs.emplace_back ( hlpUInt2 );
2301  }
2302 
2303  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2304  for ( unsigned int iter = 0; iter < hlpUInt; iter++ )
2305  {
2306  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt2 ), sizeof ( unsigned int ) );
2307  hlpChar = new char[hlpUInt2+1];
2308  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt2 );
2309  hlpChar[hlpUInt2] = '\0';
2310  dbStrNames.emplace_back ( hlpChar );
2311  }
2312  dbFile.read ( reinterpret_cast<char*> ( &settings->peakHeightNoIQRs ), sizeof ( double ) );
2313  dbFile.read ( reinterpret_cast<char*> ( &settings->peakDistanceForReal ), sizeof ( double ) );
2314  dbFile.read ( reinterpret_cast<char*> ( &settings->peakSurroundingPoints ), sizeof ( int ) );
2315  dbFile.read ( reinterpret_cast<char*> ( &settings->aaErrorTolerance ), sizeof ( double ) );
2316  dbFile.read ( reinterpret_cast<char*> ( &settings->symGapTolerance ), sizeof ( double ) );
2317  dbFile.read ( reinterpret_cast<char*> ( &settings->energyLevelDist ), sizeof ( bool ) );
2318  dbFile.read ( reinterpret_cast<char*> ( &settings->traceSigmaDist ), sizeof ( bool ) );
2319  dbFile.read ( reinterpret_cast<char*> ( &settings->fullRotFnDist ), sizeof ( bool ) );
2320  dbFile.read ( reinterpret_cast<char*> ( &settings->enLevelsThreshold ), sizeof ( double ) );
2321  dbFile.read ( reinterpret_cast<char*> ( &settings->trSigmaThreshold ), sizeof ( double ) );
2322  dbFile.read ( reinterpret_cast<char*> ( &settings->taskToPerform ), sizeof ( ProSHADE::Task ) );
2323 
2324  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2325  hlpChar = new char[hlpUInt+1];
2326  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
2327  hlpChar[hlpUInt] = '\0';
2328  settings->clearMapFile = std::string ( hlpChar );
2329 
2330  dbFile.read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
2331  hlpChar = new char[hlpUInt+1];
2332  dbFile.read ( hlpChar, sizeof ( char ) * hlpUInt );
2333  hlpChar[hlpUInt] = '\0';
2334  settings->mapFragName = std::string ( hlpChar );
2335 
2336  if ( settings->verbose > 1 )
2337  {
2338  std::cout << ">> Database settings loaded." << std::endl;
2339  }
2340 
2341  if ( settings->htmlReport )
2342  {
2343  std::stringstream hlpSS;
2344  hlpSS << "<font color=\"green\">" << "Database settings loaded." << "</font>";
2345  rvapi_set_text ( hlpSS.str().c_str(),
2346  "ProgressSection",
2347  settings->htmlReportLineProgress,
2348  1,
2349  1,
2350  1 );
2351  settings->htmlReportLineProgress += 1;
2352 
2353  rvapi_flush ( );
2354  }
2355 
2356  //======================================== Save the settings
2357  this->mapResolution = settings->mapResolution;
2358  this->bandwidth = settings->bandwidth;
2359  this->glIntegOrder = settings->glIntegOrder;
2360  this->theta = settings->theta;
2361  this->phi = settings->phi;
2362  this->bFactorValue = settings->bFactorValue;
2363  this->bFactorChange = settings->bFactorChange;
2364  this->noIQRsFromMap = settings->noIQRsFromMap;
2365  this->shellSpacing = settings->shellSpacing;
2366  this->manualShells = settings->manualShells;
2367  this->useCOM = settings->useCOM;
2368  this->firstLineCOM = settings->firstLineCOM;
2369  this->extraSpace = settings->extraSpace;
2370  this->alpha = settings->alpha;
2371  this->mPower = settings->mPower;
2372  this->ignoreLs = settings->ignoreLs;
2373  this->energyLevelDist = settings->energyLevelDist;
2374  this->traceSigmaDist = settings->traceSigmaDist;
2375  this->fullRotFnDist = settings->fullRotFnDist;
2376  this->usePhase = settings->usePhase;
2377  this->saveWithAndWithout = settings->saveWithAndWithout;
2378  this->structFiles = settings->structFiles;
2379 
2380  if ( settings->htmlReport )
2381  {
2382  //==================================== Create section
2383  rvapi_add_section ( "DBSettingsSection",
2384  "Database Settings",
2385  "body",
2386  settings->htmlReportLine,
2387  0,
2388  1,
2389  1,
2390  false );
2391  settings->htmlReportLine += 1;
2392 
2393  std::stringstream hlpSS;
2394  hlpSS << "<pre>" << "Map resolution: ";
2395  int hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2396  for ( int iter = 0; iter < hlpIt; iter++ )
2397  {
2398  hlpSS << ".";
2399  }
2400 
2401  std::stringstream hlpSS2;
2402  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mapResolution * 1000.0 ) / 1000.0;
2403  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2404  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2405  hlpSS << " " << hlpSS2.str() << "</pre>";
2406 
2407  rvapi_set_text ( hlpSS.str().c_str(),
2408  "DBSettingsSection",
2409  0,
2410  0,
2411  1,
2412  1 );
2413 
2414  hlpSS.str ( std::string ( ) );
2415  hlpSS << "<pre>" << "Bandwidth: ";
2416  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2417  for ( int iter = 0; iter < hlpIt; iter++ )
2418  {
2419  hlpSS << ".";
2420  }
2421 
2422  hlpSS2.str ( std::string ( ) );
2423  if ( this->bandwidth == 0 ) { hlpSS2 << " AUTO"; }
2424  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bandwidth * 1000.0 ) / 1000.0; }
2425  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2426  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2427  hlpSS << " " << hlpSS2.str() << "</pre>";
2428 
2429  rvapi_set_text ( hlpSS.str().c_str(),
2430  "DBSettingsSection",
2431  1,
2432  0,
2433  1,
2434  1 );
2435 
2436  hlpSS.str ( std::string ( ) );
2437  hlpSS << "<pre>" << "Gauss-Legendre Integration order: ";
2438  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2439  for ( int iter = 0; iter < hlpIt; iter++ )
2440  {
2441  hlpSS << ".";
2442  }
2443 
2444  hlpSS2.str ( std::string ( ) );
2445  if ( this->glIntegOrder == 0 ) { hlpSS2 << " AUTO"; }
2446  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->glIntegOrder * 1000.0 ) / 1000.0; }
2447  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2448  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2449  hlpSS << " " << hlpSS2.str() << "</pre>";
2450 
2451  rvapi_set_text ( hlpSS.str().c_str(),
2452  "DBSettingsSection",
2453  2,
2454  0,
2455  1,
2456  1 );
2457 
2458  hlpSS.str ( std::string ( ) );
2459  hlpSS << "<pre>" << "Theta angle sampling: ";
2460  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2461  for ( int iter = 0; iter < hlpIt; iter++ )
2462  {
2463  hlpSS << ".";
2464  }
2465 
2466  hlpSS2.str ( std::string ( ) );
2467  if ( this->theta == 0 ) { hlpSS2 << " AUTO"; }
2468  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->theta * 1000.0 ) / 1000.0; }
2469  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2470  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2471  hlpSS << " " << hlpSS2.str() << "</pre>";
2472 
2473  rvapi_set_text ( hlpSS.str().c_str(),
2474  "DBSettingsSection",
2475  3,
2476  0,
2477  1,
2478  1 );
2479 
2480  hlpSS.str ( std::string ( ) );
2481  hlpSS << "<pre>" << "Phi angle sampling: ";
2482  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2483  for ( int iter = 0; iter < hlpIt; iter++ )
2484  {
2485  hlpSS << ".";
2486  }
2487 
2488  hlpSS2.str ( std::string ( ) );
2489  if ( this->phi == 0 ) { hlpSS2 << " AUTO"; }
2490  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->phi * 1000.0 ) / 1000.0; }
2491  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2492  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2493  hlpSS << " " << hlpSS2.str() << "</pre>";
2494 
2495  rvapi_set_text ( hlpSS.str().c_str(),
2496  "DBSettingsSection",
2497  4,
2498  0,
2499  1,
2500  1 );
2501 
2502  hlpSS.str ( std::string ( ) );
2503  hlpSS << "<pre>" << "Set all PDB file B-factors to: ";
2504  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2505  for ( int iter = 0; iter < hlpIt; iter++ )
2506  {
2507  hlpSS << ".";
2508  }
2509 
2510  hlpSS2.str ( std::string ( ) );
2511  if ( this->bFactorValue == 0 ) { hlpSS2 << " AUTO"; }
2512  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorValue * 1000.0 ) / 1000.0; }
2513  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2514  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2515  hlpSS << " " << hlpSS2.str() << "</pre>";
2516 
2517  rvapi_set_text ( hlpSS.str().c_str(),
2518  "DBSettingsSection",
2519  5,
2520  0,
2521  1,
2522  1 );
2523 
2524  hlpSS.str ( std::string ( ) );
2525  hlpSS << "<pre>" << "Change B-factors after map computation by: ";
2526  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2527  for ( int iter = 0; iter < hlpIt; iter++ )
2528  {
2529  hlpSS << ".";
2530  }
2531 
2532  hlpSS2.str ( std::string ( ) );
2533  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->bFactorChange * 1000.0 ) / 1000.0;
2534  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2535  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2536  hlpSS << " " << hlpSS2.str() << "</pre>";
2537 
2538  rvapi_set_text ( hlpSS.str().c_str(),
2539  "DBSettingsSection",
2540  6,
2541  0,
2542  1,
2543  1 );
2544 
2545  hlpSS.str ( std::string ( ) );
2546  hlpSS << "<pre>" << "Map IQR from median threshold: ";
2547  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2548  for ( int iter = 0; iter < hlpIt; iter++ )
2549  {
2550  hlpSS << ".";
2551  }
2552 
2553  hlpSS2.str ( std::string ( ) );
2554  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->noIQRsFromMap * 1000.0 ) / 1000.0;
2555  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2556  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2557  hlpSS << " " << hlpSS2.str() << "</pre>";
2558 
2559  rvapi_set_text ( hlpSS.str().c_str(),
2560  "DBSettingsSection",
2561  7,
2562  0,
2563  1,
2564  1 );
2565 
2566  hlpSS.str ( std::string ( ) );
2567  hlpSS << "<pre>" << "Distance between shells: ";
2568  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2569  for ( int iter = 0; iter < hlpIt; iter++ )
2570  {
2571  hlpSS << ".";
2572  }
2573 
2574  hlpSS2.str ( std::string ( ) );
2575  if ( this->shellSpacing == 0 ) { hlpSS2 << " AUTO"; }
2576  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->shellSpacing * 1000.0 ) / 1000.0; }
2577  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2578  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2579  hlpSS << " " << hlpSS2.str() << "</pre>";
2580 
2581  rvapi_set_text ( hlpSS.str().c_str(),
2582  "DBSettingsSection",
2583  8,
2584  0,
2585  1,
2586  1 );
2587 
2588  hlpSS.str ( std::string ( ) );
2589  hlpSS << "<pre>" << "Number of shells: ";
2590  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2591  for ( int iter = 0; iter < hlpIt; iter++ )
2592  {
2593  hlpSS << ".";
2594  }
2595 
2596  hlpSS2.str ( std::string ( ) );
2597  if ( this->manualShells == 0 ) { hlpSS2 << " AUTO"; }
2598  else { hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->manualShells * 1000.0 ) / 1000.0; }
2599  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2600  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2601  hlpSS << " " << hlpSS2.str() << "</pre>";
2602 
2603  rvapi_set_text ( hlpSS.str().c_str(),
2604  "DBSettingsSection",
2605  9,
2606  0,
2607  1,
2608  1 );
2609 
2610  hlpSS.str ( std::string ( ) );
2611  hlpSS << "<pre>" << "Use Centre of Mass for centering: ";
2612  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2613  for ( int iter = 0; iter < hlpIt; iter++ )
2614  {
2615  hlpSS << ".";
2616  }
2617 
2618  hlpSS2.str ( std::string ( ) );
2619  if ( this->useCOM == 0 ) { hlpSS2 << " FALSE"; }
2620  else { hlpSS2 << " TRUE"; }
2621  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2622  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2623  hlpSS << " " << hlpSS2.str() << "</pre>";
2624 
2625  rvapi_set_text ( hlpSS.str().c_str(),
2626  "DBSettingsSection",
2627  10,
2628  0,
2629  1,
2630  1 );
2631 
2632  hlpSS.str ( std::string ( ) );
2633  hlpSS << "<pre>" << "Add extra space to cell: ";
2634  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2635  for ( int iter = 0; iter < hlpIt; iter++ )
2636  {
2637  hlpSS << ".";
2638  }
2639 
2640  hlpSS2.str ( std::string ( ) );
2641  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->extraSpace * 1000.0 ) / 1000.0;
2642  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2643  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2644  hlpSS << " " << hlpSS2.str() << "</pre>";
2645 
2646  rvapi_set_text ( hlpSS.str().c_str(),
2647  "DBSettingsSection",
2648  11,
2649  0,
2650  1,
2651  1 );
2652 
2653  hlpSS.str ( std::string ( ) );
2654  hlpSS << "<pre>" << "Raise Fourier coefficients to power: ";
2655  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2656  for ( int iter = 0; iter < hlpIt; iter++ )
2657  {
2658  hlpSS << ".";
2659  }
2660 
2661  hlpSS2.str ( std::string ( ) );
2662  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->alpha * 1000.0 ) / 1000.0;
2663  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2664  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2665  hlpSS << " " << hlpSS2.str() << "</pre>";
2666 
2667  rvapi_set_text ( hlpSS.str().c_str(),
2668  "DBSettingsSection",
2669  12,
2670  0,
2671  1,
2672  1 );
2673 
2674  hlpSS.str ( std::string ( ) );
2675  hlpSS << "<pre>" << "Weight Energy Level matrix position by: ";
2676  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2677  for ( int iter = 0; iter < hlpIt; iter++ )
2678  {
2679  hlpSS << ".";
2680  }
2681 
2682  hlpSS2.str ( std::string ( ) );
2683  hlpSS2 << std::showpos << ProSHADE_internal_misc::roundDouble ( this->mPower * 1000.0 ) / 1000.0;
2684  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2685  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2686  hlpSS << " " << hlpSS2.str() << "</pre>";
2687 
2688  rvapi_set_text ( hlpSS.str().c_str(),
2689  "DBSettingsSection",
2690  13,
2691  0,
2692  1,
2693  1 );
2694 
2695  hlpSS.str ( std::string ( ) );
2696  hlpSS << "<pre>" << "Ignore the following bands: ";
2697  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2698  for ( int iter = 0; iter < hlpIt; iter++ )
2699  {
2700  hlpSS << ".";
2701  }
2702 
2703  hlpSS2.str ( std::string ( ) );
2704  for ( int iter = 0; iter < static_cast<int> ( this->ignoreLs.size() ); iter++ )
2705  {
2706  hlpSS2 << std::showpos << this->ignoreLs.at(iter) << " ";
2707  }
2708  hlpSS << " " << hlpSS2.str() << "</pre>";
2709 
2710  rvapi_set_text ( hlpSS.str().c_str(),
2711  "DBSettingsSection",
2712  14,
2713  0,
2714  1,
2715  1 );
2716 
2717  hlpSS.str ( std::string ( ) );
2718  hlpSS << "<pre>" << "Compute Energy Level distances: ";
2719  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2720  for ( int iter = 0; iter < hlpIt; iter++ )
2721  {
2722  hlpSS << ".";
2723  }
2724 
2725  hlpSS2.str ( std::string ( ) );
2726  if ( this->energyLevelDist == 0 ) { hlpSS2 << " FALSE"; }
2727  else { hlpSS2 << " TRUE"; }
2728  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2729  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2730  hlpSS << " " << hlpSS2.str() << "</pre>";
2731 
2732  rvapi_set_text ( hlpSS.str().c_str(),
2733  "DBSettingsSection",
2734  15,
2735  0,
2736  1,
2737  1 );
2738 
2739  hlpSS.str ( std::string ( ) );
2740  hlpSS << "<pre>" << "Compute Trace Sigma distances: ";
2741  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2742  for ( int iter = 0; iter < hlpIt; iter++ )
2743  {
2744  hlpSS << ".";
2745  }
2746 
2747  hlpSS2.str ( std::string ( ) );
2748  if ( this->traceSigmaDist == 0 ) { hlpSS2 << " FALSE"; }
2749  else { hlpSS2 << " TRUE"; }
2750  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2751  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2752  hlpSS << " " << hlpSS2.str() << "</pre>";
2753 
2754  rvapi_set_text ( hlpSS.str().c_str(),
2755  "DBSettingsSection",
2756  16,
2757  0,
2758  1,
2759  1 );
2760 
2761  hlpSS.str ( std::string ( ) );
2762  hlpSS << "<pre>" << "Compute Rotation Function distances: ";
2763  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2764  for ( int iter = 0; iter < hlpIt; iter++ )
2765  {
2766  hlpSS << ".";
2767  }
2768 
2769  hlpSS2.str ( std::string ( ) );
2770  if ( this->fullRotFnDist == 0 ) { hlpSS2 << " FALSE"; }
2771  else { hlpSS2 << " TRUE"; }
2772  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2773  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2774  hlpSS << " " << hlpSS2.str() << "</pre>";
2775 
2776  rvapi_set_text ( hlpSS.str().c_str(),
2777  "DBSettingsSection",
2778  17,
2779  0,
2780  1,
2781  1 );
2782 
2783  hlpSS.str ( std::string ( ) );
2784  hlpSS << "<pre>" << "Use phase information: ";
2785  hlpIt = static_cast<int> ( 70 - hlpSS.str().length() );
2786  for ( int iter = 0; iter < hlpIt; iter++ )
2787  {
2788  hlpSS << ".";
2789  }
2790 
2791  hlpSS2.str ( std::string ( ) );
2792  if ( this->usePhase == 0 ) { hlpSS2 << " FALSE"; }
2793  else { hlpSS2 << " TRUE"; }
2794  if ( hlpSS2.str().length() != 6 ) { int hlp = 6 - hlpSS2.str().length(); for ( int i = 0; i < hlp; i++ ) { hlpSS << " "; } }
2795  if ( hlpSS2.str().length() > 6 ) { hlpSS2.str( hlpSS2.str().substr( 0, 6 ) ); }
2796  hlpSS << " " << hlpSS2.str() << "</pre>";
2797 
2798  rvapi_set_text ( hlpSS.str().c_str(),
2799  "DBSettingsSection",
2800  18,
2801  0,
2802  1,
2803  1 );
2804 
2805  rvapi_flush ( );
2806  }
2807 
2808  //======================================== Database settings check
2809  if ( !settings->usePhase )
2810  {
2811  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;
2812 
2813  if ( settings->htmlReport )
2814  {
2815  std::stringstream hlpSS;
2816  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>";
2817  rvapi_set_text ( hlpSS.str().c_str(),
2818  "ProgressSection",
2819  settings->htmlReportLineProgress,
2820  1,
2821  1,
2822  1 );
2823  settings->htmlReportLineProgress += 1;
2824  rvapi_flush ( );
2825  }
2826 
2827  exit ( -1 );
2828  }
2829 
2830  //======================================== Now, create the one structure to be fragmented
2831  ProSHADE_data* one = new ProSHADE_data ();
2832 
2833  //======================================== Read in into one
2834  matchedStrNames->clear ( );
2835  matchedStrNames->emplace_back ( structFiles.at(0) );
2836 
2837  unsigned int fileType = checkFileType ( structFiles.at(0) );
2838  if ( fileType == 2 )
2839  {
2840  one->getDensityMapFromMAP ( this->structFiles.at(0),
2841  &this->shellSpacing,
2842  this->mapResolution,
2843  &this->bandwidth,
2844  &this->theta,
2845  &this->phi,
2846  &this->glIntegOrder,
2847  &this->extraSpace,
2848  settings->mapResDefault,
2849  settings->rotChangeDefault,
2850  settings,
2851  settings->overlayDefaults );
2852  }
2853  else if ( fileType == 1 )
2854  {
2855  one->getDensityMapFromPDB ( this->structFiles.at(0),
2856  &this->shellSpacing,
2857  this->mapResolution,
2858  &this->bandwidth,
2859  &this->theta,
2860  &this->phi,
2861  &this->glIntegOrder,
2862  &this->extraSpace,
2863  settings->mapResDefault,
2864  settings,
2865  this->bFactorValue,
2866  this->firstLineCOM );
2867  }
2868  else
2869  {
2870  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;
2871 
2872  if ( settings->htmlReport )
2873  {
2874  std::stringstream hlpSS;
2875  hlpSS << "<font color=\"red\">" << "Cannot open file " << this->structFiles.at(0) << " .</font>";
2876  rvapi_set_text ( hlpSS.str().c_str(),
2877  "ProgressSection",
2878  settings->htmlReportLineProgress,
2879  1,
2880  1,
2881  1 );
2882  settings->htmlReportLineProgress += 1;
2883  rvapi_flush ( );
2884  }
2885 
2886  exit ( -1 );
2887  }
2888  if ( settings->verbose > 2 )
2889  {
2890  std::cout << ">>>>> Structure 0 read from file." << std::endl;
2891  }
2892 
2893  if ( settings->htmlReport )
2894  {
2895  std::stringstream hlpSS;
2896  hlpSS << "<font color=\"green\">" << "The structure for fragmenting loaded." << "</font>";
2897  rvapi_set_text ( hlpSS.str().c_str(),
2898  "ProgressSection",
2899  settings->htmlReportLineProgress,
2900  1,
2901  1,
2902  1 );
2903  settings->htmlReportLineProgress += 1;
2904 
2905  rvapi_flush ( );
2906  }
2907 
2908  //======================================== Deal with the centering and MAP data format, if applicable
2909  one->keepPhaseInMap ( this->alpha,
2910  this->bFactorChange,
2911  &this->bandwidth,
2912  &this->theta,
2913  &this->phi,
2914  &this->glIntegOrder,
2915  settings,
2916  this->useCOM,
2917  settings->noIQRsFromMap,
2918  settings->verbose,
2919  settings->clearMapData,
2920  settings->rotChangeDefault,
2921  settings->overlayDefaults,
2922  settings->maskBlurFactor,
2923  false );
2924 
2925  //======================================== Fragment
2926  std::vector<ProSHADE_data*> frags = one->fragmentMap ( settings, userCOM );
2927 
2928  if ( settings->verbose > 0 )
2929  {
2930  std::cout << "Structure 0 fragmented." << std::endl;
2931  }
2932 
2933  if ( settings->htmlReport )
2934  {
2935  std::stringstream hlpSS;
2936  hlpSS << "<font color=\"green\">" << "Fragments obtained." << "</font>";
2937  rvapi_set_text ( hlpSS.str().c_str(),
2938  "ProgressSection",
2939  settings->htmlReportLineProgress,
2940  1,
2941  1,
2942  1 );
2943  settings->htmlReportLineProgress += 1;
2944 
2945  rvapi_flush ( );
2946  }
2947 
2948  //======================================== Check for not finding any size matches
2949  if ( frags.size() == 0 )
2950  {
2951  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;
2952 
2953  if ( settings->htmlReport )
2954  {
2955  std::stringstream hlpSS;
2956  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>";
2957  rvapi_set_text ( hlpSS.str().c_str(),
2958  "ProgressSection",
2959  settings->htmlReportLineProgress,
2960  1,
2961  1,
2962  1 );
2963  settings->htmlReportLineProgress += 1;
2964  rvapi_flush ( );
2965  }
2966 
2967  exit ( -1 );
2968  }
2969 
2970  //======================================== Determine size limits on database over all boxes
2971  double volTolerance = ( 1.0 - settings->volumeTolerance );
2972  double totMinVol = ( ( static_cast<double> ( frags.at(0)->_maxMapU ) * volTolerance ) *
2973  ( static_cast<double> ( frags.at(0)->_maxMapV ) * volTolerance ) *
2974  ( static_cast<double> ( frags.at(0)->_maxMapW ) * volTolerance ) );
2975  double volMin = totMinVol;
2976  for ( unsigned int iter = 1; iter < static_cast<unsigned int> ( frags.size() ); iter++ )
2977  {
2978  volMin = ( ( static_cast<double> ( frags.at(iter)->_maxMapU ) * volTolerance ) *
2979  ( static_cast<double> ( frags.at(iter)->_maxMapV ) * volTolerance ) *
2980  ( static_cast<double> ( frags.at(iter)->_maxMapW ) * volTolerance ) );
2981  totMinVol = std::min ( volMin, totMinVol );
2982  }
2983 
2984  volTolerance = ( 1.0 + settings->volumeTolerance );
2985  double totMaxVol = ( ( static_cast<double> ( frags.at(0)->_maxMapU ) * volTolerance ) *
2986  ( static_cast<double> ( frags.at(0)->_maxMapV ) * volTolerance ) *
2987  ( static_cast<double> ( frags.at(0)->_maxMapW ) * volTolerance ) );
2988  double volMax = totMaxVol;
2989  for ( unsigned int iter = 1; iter < static_cast<unsigned int> ( frags.size() ); iter++ )
2990  {
2991  volMax = ( ( static_cast<double> ( frags.at(iter)->_maxMapU ) * volTolerance ) *
2992  ( static_cast<double> ( frags.at(iter)->_maxMapV ) * volTolerance ) *
2993  ( static_cast<double> ( frags.at(iter)->_maxMapW ) * volTolerance ) );
2994  totMaxVol = std::max ( volMax, totMaxVol );
2995  }
2996 
2997  if ( settings->htmlReport )
2998  {
2999  //==================================== Create section
3000  rvapi_add_section ( "FragmentSection",
3001  "Fragment processing",
3002  "body",
3003  settings->htmlReportLine,
3004  0,
3005  1,
3006  1,
3007  false );
3008  settings->htmlReportLine += 1;
3009 
3010  rvapi_flush ( );
3011  }
3012 
3013  //======================================== Complete the data processing for each map fragment
3014  for ( unsigned int frIt = 0; frIt < static_cast<unsigned int> ( frags.size() ); frIt++ )
3015  {
3016  if ( settings->verbose > 3 )
3017  {
3018  std::cout << ">>>>>>>> Computing spherical harmonics for fragment " << frIt << " out of " << frags.size() << "." << std::endl;
3019  }
3020 
3021  //==================================== Map the density onto spheres
3022  frags.at(frIt)->mapPhaselessToSphere ( settings,
3023  frags.at(frIt)->_thetaAngle,
3024  frags.at(frIt)->_phiAngle,
3025  one->_shellSpacing,
3026  settings->manualShells );
3027 
3028  //==================================== Compute the Spherical Harmonics (SH) coefficients
3029  frags.at(frIt)->getSphericalHarmonicsCoeffs ( frags.at(frIt)->_bandwidthLimit, settings );
3030 
3031  //==================================== If required, pre-compute the energy levels distance descriptor
3032  if ( this->energyLevelDist )
3033  {
3034  frags.at(frIt)->precomputeRotInvDescriptor ( settings );
3035  }
3036 
3037  if ( settings->htmlReport )
3038  {
3039  std::stringstream hlpSS;
3040  hlpSS << "Fragment " << frIt << " spherical harmonics computation done.";
3041  rvapi_set_text ( hlpSS.str().c_str(),
3042  "FragmentSection",
3043  frIt,
3044  1,
3045  1,
3046  1 );
3047 
3048  rvapi_flush ( );
3049  }
3050 
3051  }
3052  if ( settings->verbose > 1 )
3053  {
3054  std::cout << ">> Spherical harmonics computed for " << static_cast<unsigned int> ( frags.size() ) << " fragments." << std::endl;
3055  }
3056 
3057  if ( settings->htmlReport )
3058  {
3059  std::stringstream hlpSS;
3060  hlpSS << "<font color=\"green\">" << "Spherical harmonics computed for " << static_cast<unsigned int> ( frags.size() ) << " fragments." << "</font>";
3061  rvapi_set_text ( hlpSS.str().c_str(),
3062  "ProgressSection",
3063  settings->htmlReportLineProgress,
3064  1,
3065  1,
3066  1 );
3067  settings->htmlReportLineProgress += 1;
3068 
3069  rvapi_flush ( );
3070  }
3071 
3072  //======================================== Read in the database data into ProSHADE_data objects
3073  std::vector<ProSHADE_data*> dbData;
3074  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbStrNames.size() ); strIt++ )
3075  {
3076  if ( settings->verbose > 2 )
3077  {
3078  std::cout << ">>>>> Loading structure " << strIt << " from the database." << std::endl;
3079  }
3080 
3081  dbData.emplace_back ( new ProSHADE_data ( &dbFile, dbStrNames.at(strIt), totMinVol, totMaxVol, settings->verbose, settings ) );
3082  if ( dbData.at(dbData.size()-1)->_mapResolution == -999.9 )
3083  {
3084  dbData.pop_back ( );
3085  }
3086  else
3087  {
3088  matchedStrNames->emplace_back ( dbStrNames.at(strIt) );
3089  }
3090  }
3091 
3092  //======================================== Check for not finding any size matches
3093  if ( dbData.size() == 0 )
3094  {
3095  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;
3096 
3097  if ( settings->htmlReport )
3098  {
3099  std::stringstream hlpSS;
3100  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>";
3101  rvapi_set_text ( hlpSS.str().c_str(),
3102  "ProgressSection",
3103  settings->htmlReportLineProgress,
3104  1,
3105  1,
3106  1 );
3107  settings->htmlReportLineProgress += 1;
3108  rvapi_flush ( );
3109  }
3110 
3111  exit ( 0 );
3112  }
3113 
3114  if ( settings->htmlReport )
3115  {
3116  //==================================== Create section
3117  rvapi_add_section ( "FragmentDistancesSection",
3118  "Fragment distances computation",
3119  "body",
3120  settings->htmlReportLine,
3121  0,
3122  1,
3123  1,
3124  false );
3125  settings->htmlReportLine += 1;
3126 
3127  rvapi_flush ( );
3128  }
3129 
3130  for ( unsigned int frIt = 0; frIt < static_cast<unsigned int> ( frags.size() ); frIt++ )
3131  {
3132  if ( settings->verbose > 0 )
3133  {
3134  std::cout << "Computing distances for fragment " << frIt << " ." << std::endl;
3135  }
3136 
3137  //==================================== Create the compare against all object
3138  this->cmpObj = new ProSHADE_compareOneAgainstAll ( frags.at(frIt), &dbData, this->ignoreLs, this->mPower, settings->verbose );
3139 
3140  //==================================== Save the decision whether to use phases or not
3141  if ( frags.at(frIt)->_keepOrRemove ) { this->cmpObj->_keepOrRemove = true; }
3142  else { this->cmpObj->_keepOrRemove = false; }
3143 
3144  //==================================== If required, compute the energy levels distances
3145  if ( this->energyLevelDist )
3146  {
3147  this->energyLevelsDistances = this->cmpObj->getEnergyLevelsDistance ( settings->verbose, settings );
3148  this->fragEnergyLevelsDistances.emplace_back ( this->energyLevelsDistances );
3149 
3150  // ... and set which pairs not to follow further
3151  if ( this->enLevelsThreshold != -999.9 )
3152  {
3153  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
3154  {
3155  if ( this->enLevelsThreshold > this->energyLevelsDistances.at(iter) )
3156  {
3157  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 1 );
3158  }
3159  else
3160  {
3161  this->cmpObj->_enLevelsDoNotFollow.emplace_back ( 0 );
3162  }
3163  }
3164  }
3165  else
3166  {
3167  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->cmpObj->all->size() ); iter++ )
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  if ( settings->verbose > 1 )
3182  {
3183  std::cout << ">> Cross-correlation distances computed ." << std::endl;
3184  }
3185 
3186  if ( settings->htmlReport )
3187  {
3188  std::stringstream hlpSS;
3189  hlpSS << "<font color=\"green\">" << "Energy Level distances computed for fragment " << frIt << "</font>";
3190  rvapi_set_text ( hlpSS.str().c_str(),
3191  "FragmentDistancesSection",
3192  ( frIt * 3 ) + 0,
3193  1,
3194  1,
3195  1 );
3196 
3197  rvapi_flush ( );
3198  }
3199 
3200  //==================================== Sort out the integration order as this is not kept within the data objects...
3201  this->glIntegOrderVec = std::vector<unsigned int> ( dbData.size() + 1 );
3202  this->glIntegOrderVec.at(0) = this->glIntegOrder;
3203  double distPerPointFraction = 0.0;
3204  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( dbData.size() ); strIt++ )
3205  {
3206  distPerPointFraction = static_cast<double> ( dbData.at(strIt)->_shellSpacing ) / ( dbData.at(strIt)->_maxMapRange / 2.0 );
3207 
3208  for ( unsigned int iter = 2; iter < static_cast<unsigned int> ( ProSHADE_internal_misc::glIntMaxDists.size() ); iter++ )
3209  {
3210  if ( ProSHADE_internal_misc::glIntMaxDists.at(iter) >= distPerPointFraction )
3211  {
3212  this->glIntegOrderVec.at(strIt+1) = iter;
3213  }
3214  }
3215  }
3216 
3217  //==================================== Pre-compute the E matrices in case either the trace sigmal or full rotation distance are required
3218  if ( this->traceSigmaDist || this->fullRotFnDist )
3219  {
3220  this->cmpObj->precomputeTrSigmaDescriptor ( this->shellSpacing, &this->glIntegOrderVec, settings );
3221  }
3222 
3223  //==================================== Compute the trace sigma distances, if required
3224  if ( this->traceSigmaDist )
3225  {
3226  this->traceSigmaDistances = this->cmpObj->getTrSigmaDistance ( settings->verbose, settings );
3227  this->fragTraceSigmaDistances.emplace_back ( this->traceSigmaDistances );
3228 
3229  if ( this->trSigmaThreshold == -999.9 )
3230  {
3231  this->cmpObj->_trSigmaDoNotFollow = this->cmpObj->_enLevelsDoNotFollow;
3232  }
3233  else
3234  {
3235  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
3236  {
3237  if ( this->trSigmaThreshold > this->traceSigmaDistances.at(iter) )
3238  {
3239  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 1 );
3240  }
3241  else
3242  {
3243  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
3244  }
3245  }
3246  }
3247  }
3248  else
3249  {
3250  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( this->traceSigmaDistances.size() ); iter++ )
3251  {
3252  this->cmpObj->_trSigmaDoNotFollow.emplace_back ( 0 );
3253  }
3254  }
3255 
3256  if ( settings->verbose > 1 )
3257  {
3258  std::cout << ">> Trace sigma distances computed ." << std::endl;
3259  }
3260  if ( settings->htmlReport )
3261  {
3262  std::stringstream hlpSS;
3263  hlpSS << "<font color=\"green\">" << "Trace Sigma distances computed for fragment " << frIt << "</font>";
3264  rvapi_set_text ( hlpSS.str().c_str(),
3265  "FragmentDistancesSection",
3266  ( frIt * 3 ) + 1,
3267  1,
3268  1,
3269  1 );
3270 
3271  rvapi_flush ( );
3272  }
3273 
3274  //==================================== If full rotation distance is required, pre-compute the requirements
3275  if ( this->fullRotFnDist )
3276  {
3277  this->cmpObj->getSO3InverseMap ( settings );
3278  this->cmpObj->getEulerAngles ( settings );
3279  this->cmpObj->generateWignerMatrices ( settings );
3280  this->fullRotationDistances = this->cmpObj->getRotCoeffDistance ( settings->verbose, settings );
3281  this->fragfullRotationDistances.emplace_back ( this->fullRotationDistances );
3282  }
3283  if ( settings->verbose > 1 )
3284  {
3285  std::cout << ">> Rotation function distances computed ." << std::endl;
3286  }
3287  if ( settings->htmlReport )
3288  {
3289  std::stringstream hlpSS;
3290  hlpSS << "<font color=\"green\">" << "Rotation Function distances computed for fragment " << frIt << "</font>";
3291  rvapi_set_text ( hlpSS.str().c_str(),
3292  "FragmentDistancesSection",
3293  ( frIt * 3 ) + 2,
3294  1,
3295  1,
3296  1 );
3297 
3298  rvapi_flush ( );
3299  }
3300  }
3301 
3302  if ( settings->htmlReport )
3303  {
3304  std::stringstream hlpSS;
3305  hlpSS << "<font color=\"green\">" << "Fragment distances computed." << "</font>";
3306  rvapi_set_text ( hlpSS.str().c_str(),
3307  "ProgressSection",
3308  settings->htmlReportLineProgress,
3309  1,
3310  1,
3311  1 );
3312  settings->htmlReportLineProgress += 1;
3313 
3314  rvapi_flush ( );
3315  }
3316 
3317  //======================================== Done
3318  return ;
3319 }
3320 
3321 
3339  std::string fName,
3340  double volThreMin,
3341  double volThreMax,
3342  int verbose,
3343  ProSHADE::ProSHADE_settings* settings,
3344  bool saveWithAndWithout )
3345 {
3346  //======================================== Sanity check
3347  if ( dbFile->fail() )
3348  {
3349  std::cerr << "!!! ProSHADE ERROR !!! Cannot read from input database file. Terminating..." << std::endl;
3350 
3351  if ( settings->htmlReport )
3352  {
3353  std::stringstream hlpSS;
3354  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>";
3355  rvapi_set_text ( hlpSS.str().c_str(),
3356  "ProgressSection",
3357  settings->htmlReportLineProgress,
3358  1,
3359  1,
3360  1 );
3361  settings->htmlReportLineProgress += 1;
3362  rvapi_flush ( );
3363  }
3364 
3365  exit ( -1 );
3366  }
3367 
3368  //======================================== Initialise object to null
3369  this->_inputFileName = fName;
3370  this->_densityMapMap = nullptr;
3371  this->_densityMapCor = nullptr;
3372  this->_densityMapCorCoords = nullptr;
3373  this->_shellMappedData = nullptr;
3374  this->_realSHCoeffs = nullptr;
3375  this->_imagSHCoeffs = nullptr;
3376  this->_sphericalHarmonicsWeights = nullptr;
3377  this->_semiNaiveTable = nullptr;
3378  this->_semiNaiveTableSpace = nullptr;
3379  this->_shWorkspace = nullptr;
3380  this->_rrpMatrices = nullptr;
3381  this->_invRealData = nullptr;
3382  this->_invImagData = nullptr;
3383 
3384  this->_densityMapComputed = false;
3385  this->_phaseRemoved = false;
3386  this->_usePhase = false;
3387  this->_firstLineCOM = false;
3388  this->_sphereMapped = false;
3389  this->_sphericalCoefficientsComputed = false;
3390  this->_rrpMatricesPrecomputed = false;
3391  this->_wasBandwithGiven = true;
3392  this->_wasThetaGiven = true;
3393  this->_wasPhiGiven = true;
3394  this->_wasGlInterGiven = true;
3395 
3396  this->_xCorrection = 0;
3397  this->_yCorrection = 0;
3398  this->_zCorrection = 0;
3399 
3400  this->_mapMean = 0.0;
3401  this->_mapSdev = 1.0;
3402 
3403  //======================================== Declare local variables
3404  unsigned int hlpUInt;
3405  double hlpD;
3406 
3407  //======================================== Read in the structure settings
3408  dbFile->read ( reinterpret_cast<char*> ( &this->_fromPDB ), sizeof ( bool ) );
3409  dbFile->read ( reinterpret_cast<char*> ( &this->_shellSpacing ), sizeof ( double ) );
3410  dbFile->read ( reinterpret_cast<char*> ( &this->_maxExtraCellularSpace ), sizeof ( double ) );
3411  dbFile->read ( reinterpret_cast<char*> ( &this->_xRange ), sizeof ( double ) );
3412  dbFile->read ( reinterpret_cast<char*> ( &this->_yRange ), sizeof ( double ) );
3413  dbFile->read ( reinterpret_cast<char*> ( &this->_zRange ), sizeof ( double ) );
3414 
3415  dbFile->read ( reinterpret_cast<char*> ( &hlpUInt ), sizeof ( unsigned int ) );
3416  for ( unsigned int it = 0; it < hlpUInt; it++ )
3417  {
3418  dbFile->read ( reinterpret_cast<char*> ( &hlpD ), sizeof ( double ) );
3419  this->_shellPlacement.emplace_back ( hlpD );
3420  }
3421 
3422  dbFile->read ( reinterpret_cast<char*> ( &this->_mapResolution ), sizeof ( double ) );
3423  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapU ), sizeof ( unsigned int ) );
3424  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapV ), sizeof ( unsigned int ) );
3425  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapW ), sizeof ( unsigned int ) );
3426  dbFile->read ( reinterpret_cast<char*> ( &this->_densityMapComputed ), sizeof ( bool ) );
3427  dbFile->read ( reinterpret_cast<char*> ( &this->_mapMean ), sizeof ( double ) );
3428  dbFile->read ( reinterpret_cast<char*> ( &this->_mapSdev ), sizeof ( double ) );
3429  dbFile->read ( reinterpret_cast<char*> ( &this->_fourierCoeffPower ), sizeof ( double ) );
3430  dbFile->read ( reinterpret_cast<char*> ( &this->_bFactorChange ), sizeof ( double ) );
3431  dbFile->read ( reinterpret_cast<char*> ( &this->_maxMapRange ), sizeof ( double ) );
3432  dbFile->read ( reinterpret_cast<char*> ( &this->_phaseRemoved ), sizeof ( bool ) );
3433  dbFile->read ( reinterpret_cast<char*> ( &this->_usePhase ), sizeof ( bool ) );
3434  dbFile->read ( reinterpret_cast<char*> ( &this->_keepOrRemove ), sizeof ( bool ) );
3435  dbFile->read ( reinterpret_cast<char*> ( &this->_thetaAngle ), sizeof ( double ) );
3436  dbFile->read ( reinterpret_cast<char*> ( &this->_phiAngle ), sizeof ( double ) );
3437  dbFile->read ( reinterpret_cast<char*> ( &this->_noShellsWithData ), sizeof ( unsigned int ) );
3438  dbFile->read ( reinterpret_cast<char*> ( &this->_xCorrection ), sizeof ( unsigned int ) );
3439  dbFile->read ( reinterpret_cast<char*> ( &this->_yCorrection ), sizeof ( unsigned int ) );
3440  dbFile->read ( reinterpret_cast<char*> ( &this->_zCorrection ), sizeof ( unsigned int ) );
3441  dbFile->read ( reinterpret_cast<char*> ( &this->_xCorrErr ), sizeof ( double ) );
3442  dbFile->read ( reinterpret_cast<char*> ( &this->_yCorrErr ), sizeof ( double ) );
3443  dbFile->read ( reinterpret_cast<char*> ( &this->_zCorrErr ), sizeof ( double ) );
3444  dbFile->read ( reinterpret_cast<char*> ( &this->_sphereMapped ), sizeof ( bool ) );
3445  dbFile->read ( reinterpret_cast<char*> ( &this->_firstLineCOM ), sizeof ( bool ) );
3446  dbFile->read ( reinterpret_cast<char*> ( &this->_bandwidthLimit ), sizeof ( unsigned int ) );
3447  dbFile->read ( reinterpret_cast<char*> ( &this->_oneDimmension ), sizeof ( unsigned int ) );
3448  dbFile->read ( reinterpret_cast<char*> ( &this->_sphericalCoefficientsComputed ), sizeof ( bool ) );
3449  dbFile->read ( reinterpret_cast<char*> ( &this->_rrpMatricesPrecomputed ), sizeof ( bool ) );
3450 
3451  if ( verbose > 3 )
3452  {
3453  std::cout << ">>>>>>>> Settings loaded." << std::endl;
3454  }
3455 
3456  //======================================== Check the volume
3457  if ( !( ( ( (this->_xRange-this->_maxExtraCellularSpace) * (this->_yRange-this->_maxExtraCellularSpace) * (this->_zRange-this->_maxExtraCellularSpace) ) > volThreMin ) &&
3458  ( ( (this->_xRange-this->_maxExtraCellularSpace) * (this->_yRange-this->_maxExtraCellularSpace) * (this->_zRange-this->_maxExtraCellularSpace) ) < volThreMax ) ) )
3459  {
3460  //==================================== Set flag to ignore this structure further
3461  this->_mapResolution = -999.9;
3462  }
3463 
3464  //======================================== Initialise the spherical harmonics coefficient arrays
3465  this->_realSHCoeffs = new double* [this->_noShellsWithData];
3466  for ( unsigned int i = 0; i < this->_noShellsWithData; i++ ) { this->_realSHCoeffs[i] = new double [this->_oneDimmension * this->_oneDimmension]; }
3467  this->_imagSHCoeffs = new double* [this->_noShellsWithData];
3468  for ( unsigned int i = 0; i < this->_noShellsWithData; i++ ) { this->_imagSHCoeffs[i] = new double [this->_oneDimmension * this->_oneDimmension]; }
3469 
3470  //======================================== Read in the spherical harmonics coefficient arrays
3471  for ( unsigned int sh = 0; sh < this->_noShellsWithData; sh++ )
3472  {
3473  for ( unsigned int arrIt = 0; arrIt < ( this->_oneDimmension * this->_oneDimmension ); arrIt++ )
3474  {
3475  dbFile->read ( reinterpret_cast<char*> ( &this->_realSHCoeffs[sh][arrIt] ), sizeof ( double ) );
3476  dbFile->read ( reinterpret_cast<char*> ( &this->_imagSHCoeffs[sh][arrIt] ), sizeof ( double ) );
3477  }
3478  }
3479  if ( verbose > 3 )
3480  {
3481  std::cout << ">>>>>>>> Spherical harmonics loaded." << std::endl;
3482  }
3483 
3484  //======================================== Initialise the RRP matrices data arrays
3485  this->_rrpMatrices = new double** [this->_bandwidthLimit];
3486  for ( unsigned int bwIt = 0; bwIt < this->_bandwidthLimit; bwIt++ )
3487  {
3488  //==================================== Odd bands are 0, so just ignore them
3489  if ( !this->_keepOrRemove ) { if ( ( bwIt % 2 ) != 0 ) { continue; } }
3490 
3491  this->_rrpMatrices[bwIt] = new double* [this->_noShellsWithData];
3492  for ( unsigned int shIt = 0; shIt < this->_noShellsWithData; shIt++ )
3493  {
3494  this->_rrpMatrices[bwIt][shIt] = new double [this->_noShellsWithData];
3495  }
3496  }
3497 
3498  //======================================== Read in the RRP matrices data arrays
3499  for ( unsigned int bwIt = 0; bwIt < this->_bandwidthLimit; bwIt++ )
3500  {
3501  //==================================== Odd bands are 0, so just ignore them
3502  if ( !this->_keepOrRemove ) { if ( ( bwIt % 2 ) != 0 ) { continue; } }
3503 
3504  for ( unsigned int sh1 = 0; sh1 < this->_noShellsWithData; sh1++ )
3505  {
3506  for ( unsigned int sh2 = 0; sh2 < this->_noShellsWithData; sh2++ )
3507  {
3508  dbFile->read ( reinterpret_cast<char*> ( &this->_rrpMatrices[bwIt][sh1][sh2] ), sizeof ( double ) );
3509  }
3510  }
3511  }
3512  if ( verbose > 3 )
3513  {
3514  std::cout << ">>>>>>>> RRP Matrices loaded." << std::endl;
3515  }
3516 
3517  //======================================== Normalise back to usual meaning
3518  if ( saveWithAndWithout )
3519  {
3520  if ( this->_usePhase )
3521  {
3522  dbFile->read ( reinterpret_cast<char*> ( &this->_xFrom ), sizeof ( double ) );
3523  dbFile->read ( reinterpret_cast<char*> ( &this->_xTo ), sizeof ( double ) );
3524  dbFile->read ( reinterpret_cast<char*> ( &this->_yFrom ), sizeof ( double ) );
3525  dbFile->read ( reinterpret_cast<char*> ( &this->_yTo ), sizeof ( double ) );
3526  dbFile->read ( reinterpret_cast<char*> ( &this->_zFrom ), sizeof ( double ) );
3527  dbFile->read ( reinterpret_cast<char*> ( &this->_zTo ), sizeof ( double ) );
3528 
3529  this->_densityMapCor = new double [(this->_maxMapU+1) * (this->_maxMapV+1) * (this->_maxMapW+1)];
3530  for ( unsigned int mIt = 0; mIt < static_cast<unsigned int> ( (this->_maxMapU+1) * (this->_maxMapV+1) * (this->_maxMapW+1) ); mIt++ )
3531  {
3532  dbFile->read ( reinterpret_cast<char*> ( &this->_densityMapCor[mIt] ), sizeof ( double ) );
3533  }
3534  }
3535  }
3536 
3537  this->_xSamplingRate = this->_xRange / static_cast<double> ( this->_maxMapU );
3538  this->_ySamplingRate = this->_yRange / static_cast<double> ( this->_maxMapV );
3539  this->_zSamplingRate = this->_zRange / static_cast<double> ( this->_maxMapW );
3540 
3541  //======================================== Done
3542  return ;
3543 }
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:185
int verbose
Should the software report on the progress, or just be quiet? Value between 0 (quiet) and 4 (loud) ...
Definition: ProSHADE.h:188
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:186
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:187
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.