ProSHADE  0.6.5 (NOV 2018)
Protein Shape Descriptors and Symmetry Detection
ProSHADE.h
Go to the documentation of this file.
1 
21 //============================================ Apply -pedantic and -Wshadow to my code only (some of the dependencies fill not compile if this is allowed for all)
22 //#define __PROSHADE_DEVEL_CODE__
23 
24 //============================================ Include once
25 #ifndef __PROSHADE_LIBRARY__
26 #define __PROSHADE_LIBRARY__
27 
28 //============================================ Standard library
29 #include <iostream>
30 #include <fstream>
31 #include <sstream>
32 #include <iterator>
33 #include <string>
34 #include <vector>
35 #include <array>
36 #include <numeric>
37 #include <functional>
38 #include <algorithm>
39 #include <ctime>
40 #include <chrono>
41 #include <memory>
42 #include <exception>
43 #include <getopt.h>
44 #include <limits>
45 #include <string.h>
46 #include <cmath>
47 #include <sys/stat.h>
48 
49 //============================================ Development compilation pragmas
50 #ifdef __PROSHADE_DEVEL_CODE__
51 #pragma GCC diagnostic error "-Wshadow"
52 #pragma GCC diagnostic error "-Wpedantic"
53 #endif
54 
55 typedef double fftw_complex[2];
56 
62 namespace ProSHADE
63 {
64  //======================================== The Task data type
65  enum Task { NA, Symmetry, Distances, DistancesFrag, Features, BuildDB, HalfMaps, RotateMap, OverlayMap, SimpleRebox };
66 
75  {
76  public:
77  //==================================== Settings regarding resolutions
78  double mapResolution;
80  unsigned int bandwidth;
81  bool wasBandGiven;
82  unsigned int glIntegOrder;
83  unsigned int theta;
84  unsigned int phi;
86 
87  //==================================== Settings regarding B factors
88  double bFactorValue;
89  double bFactorChange;
91 
92  //==================================== Setting regarding maps and removing noise
93  double noIQRsFromMap;
94 
95  //==================================== Settings regarding concentric shells
96  double shellSpacing;
98  unsigned int manualShells;
99 
100  //==================================== Settings regarding phase
101  bool usePhase;
103 
104  //==================================== Settings regarding map with phases
105  bool useCOM;
107 
108  //==================================== Settings regarding space around the structure in lattice
109  double extraSpace;
111 
112  //==================================== Settings regarding weighting the distances
113  double alpha;
114  double mPower;
115 
116  //==================================== Settings regarding bands to ignore
117  std::vector<int> ignoreLs;
118 
119  //==================================== Settings regarding the structures to use
120  std::vector <std::string> structFiles;
121 
122  //==================================== Settings regarding peak finding
126 
127  //==================================== Settings regarding axis and angle error tolerance
130 
131  //==================================== Settings regarding which distances to compute
135 
136  //==================================== Settings regarding thresholds for hierarchical distance computation
139 
140  //==================================== Settings regarding which of the task to perform
142 
143  //==================================== Settings regarding where and if to save the clear map
144  std::string clearMapFile;
147  double maskBlurFactor;
149 
150  //==================================== Settings regarding map fragmentation
151  double mapFragBoxSize;
152  std::string mapFragName;
154 
155  //==================================== Settings regarding structure database
156  std::string databaseName;
160 
161  //==================================== Settings regarding the symmetry type required
162  unsigned int symmetryFold;
163  std::string symmetryType;
164 
165  //==================================== Settings regarding the map rotation mode
166  double rotAngle;
167  double rotXAxis;
168  double rotYAxis;
169  double rotZAxis;
171  double xTranslation;
172  double yTranslation;
173  double zTranslation;
174 
175  //==================================== Settings regarding the map overlay mode
178  bool resizeMovingStructure;
179  unsigned int maxRotError;
180  std::vector<std::string> deleteModels;
181 
182  //==================================== Settings regarding the map saving mode
183  std::string axisOrder;
184 
185  //==================================== Settings regarding verbosity of the program
186  bool htmlReport;
189  int verbose;
190 
191  public:
192  //==================================== Public functions available to user: Constructor and destructor
193  ProSHADE_settings ( );
194 
195  //==================================== Public functions available to user: Pecularities
196  void printSettings ( );
197  void getCommandLineParams ( int argc, char* argv[] );
198  void ignoreLsAddValuePy ( const int val );
199  void appendStructure ( std::string str );
200  };
201 
208  class ProSHADE
209  {
210  //==================================== Friends
211  friend class ProSHADE_settings;
212 
213  private:
214  //==================================== Keep settings object
215  ProSHADE_settings* settings;
216 
217  //==================================== Decision bools
218  bool distancesAvailable;
219  bool symmetriesAvailable;
220  bool fragmentsAvailable;
221 
222  //==================================== Values from the ProSHADE run
223  std::vector<double> crossCorrDists;
224  std::vector<double> traceSigmaDists;
225  std::vector<double> rotFunctionDists;
226  std::vector< std::array<double,5> > cyclicSymmetries;
227  std::vector< std::array<double,5> > cyclicSymmetriesClear;
228  std::vector< std::vector< std::array<double,6> > > dihedralSymmetries;
229  std::vector< std::vector< std::array<double,6> > > dihedralSymmetriesClear;
230  std::vector< std::array<double,5> > tetrahedralSymmetry;
231  std::vector< std::array<double,5> > octahedralSymmetry;
232  std::vector< std::array<double,5> > icosahedralSymmetry;
233  std::vector< std::string > fragmentList;
234 
235  public:
236  //==================================== Public functions available to user: Constructor and destructor
237  ProSHADE ( ProSHADE_settings *settings );
238  ~ProSHADE ( void );
239 
240  //==================================== Public functions available to user: Accessor functions for distances
241  std::vector<double> getCrossCorrDists ( void );
242  std::vector<double> getTraceSigmaDists ( void );
243  std::vector<double> getRotFunctionDists ( void );
244 
245  //==================================== Public functions available to user: Accessor functions for symmetries (C++)
246  std::vector< std::array<double,5> > getCyclicSymmetries ( void );
247  std::vector< std::array<double,5> > getClearCyclicSymmetries ( void );
248  std::vector< std::vector<std::array< double,6> > > getDihedralSymmetries ( void );
249  std::vector< std::vector<std::array< double,6> > > getClearDihedralSymmetries ( void );
250  std::vector< std::array<double,5> > getTetrahedralSymmetries ( void );
251  std::vector< std::array<double,5> > getOctahedralSymmetries ( void );
252  std::vector< std::array<double,5> > getIcosahedralSymmetries ( void );
253  std::vector< std::array<double,5> > getRecommendedSymmetry ( void );
254  std::vector< std::array<double,5> > getSpecificSymmetryElements ( std::string symType, int symFold = 0 );
255 
256  //==================================== Public functions available to user: Accessor functions for symmetries (Python)
257  std::vector< double > getCyclicSymmetriesPy ( void );
258  std::vector< double > getDihedralSymmetriesPy ( void );
259  std::vector< double > getTetrahedralSymmetriesPy ( void );
260  std::vector< double > getOctahedralSymmetriesPy ( void );
261  std::vector< double > getIcosahedralSymmetriesPy ( void );
262  std::vector< double > getRecommendedSymmetryElementsPy ( void );
263  std::vector< double > getSpecificSymmetryElementsPy ( std::string symType, int symFold = 0 );
264 
265  //==================================== Public functions available to user: Accessor functions for fragmentation
266  std::vector< std::string > getMapFragments ( void );
267 
268  //==================================== Public functions available to user: Miscellaneous
269  std::string getProSHADEVersion ( void );
270  };
271 }
272 
273 //============================================ END
274 #endif
double aaErrorTolerance
The tolerance parameter on matching axes for the angle-axis representation of rotations.
Definition: ProSHADE.h:128
bool wasBandGiven
Variable stating whether the bandwidth value was given by the user, or decided automatically.
Definition: ProSHADE.h:81
std::string symmetryType
The required symmetry type. If no symmetry is required, leave empty. Possible values are: C...
Definition: ProSHADE.h:163
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
bool dbDistOverlay
This value is false in all conditions, unless programatically changed. If changed, distance computations will use the phaseless database to compute overlay before distances computation. This is computationally expensive and requires phaseless as well as phased database.
Definition: ProSHADE.h:177
double bFactorValue
This is the value to which all B-factors of PDB files will be changed to.
Definition: ProSHADE.h:88
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
double databaseMinVolume
The smallest volume of a structure in the database.
Definition: ProSHADE.h:157
void printSettings()
Function for outputting the current settings recorded in the ProSHADE_settings class instance...
Definition: ProSHADE.cpp:190
std::string databaseName
The name of the bin file to which the database should be saved.
Definition: ProSHADE.h:156
double zTranslation
The number of angstroms by which the structure should be translated along the Z axis.
Definition: ProSHADE.h:173
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
bool usePhase
Here the user can decide whether to use phase information or whether to ignore it completely...
Definition: ProSHADE.h:101
bool wasExtraSpaceGiven
Variable stating whether the extra cell space value was given by the user, or decided automatically...
Definition: ProSHADE.h:110
double mapFragBoxFraction
Fraction of box that needs to have density in order to be passed on.
Definition: ProSHADE.h:153
std::vector< std::string > deleteModels
The filenames listed here consist of models which should have their density deleted from the map befo...
Definition: ProSHADE.h:180
unsigned int bandwidth
This parameter determines the angular resolution of the spherical harmonics decomposition.
Definition: ProSHADE.h:80
bool wasShellSpacingGiven
Variable stating whether the distance between shells value was given by the user, or decided automati...
Definition: ProSHADE.h:97
bool htmlReport
Should HTML report for the run be created?
Definition: ProSHADE.h:186
int verbose
Should the software report on the progress, or just be quiet? Value between 0 (quiet) and 4 (loud) ...
Definition: ProSHADE.h:189
double rotAngle
The angle of the rotation to be done to the map structure in the map rotation mode.
Definition: ProSHADE.h:166
bool saveWithAndWithout
This option decides whether both with and without phase spherical harmonics should be saved...
Definition: ProSHADE.h:102
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
bool useCubicMaps
When saving clear maps, should the rectangular or cubic (older versions of refmac need this) maps be ...
Definition: ProSHADE.h:145
bool maskBlurFactorGiven
Was a specific value of the blurring factor requested by the user?
Definition: ProSHADE.h:148
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
double rotXAxis
The X-axis element of the rotation axis along which the rotation is to be done in the map rotation mo...
Definition: ProSHADE.h:167
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 rotYAxis
The Y-axis element of the rotation axis along which the rotation is to be done in the map rotation mo...
Definition: ProSHADE.h:168
double rotZAxis
The Z-axis element of the rotation axis along which the rotation is to be done in the map rotation mo...
Definition: ProSHADE.h:169
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 appendStructure(std::string str)
Miscellanous function allowing adding a single string to the structures vector.
Definition: ProSHADE.cpp:2924
bool rotChangeDefault
If map rotation is selected, the default automatic parameter decision is changed. This variable state...
Definition: ProSHADE.h:170
void getCommandLineParams(int argc, char *argv[])
This function parses the command line arguments and saves the user values into the settings class...
Definition: ProSHADE.cpp:433
unsigned int phi
This parameter is the latitudd of the spherical grid mapping. It should be 2 * bandwidth unless there...
Definition: ProSHADE.h:84
unsigned int maxRotError
This is the maximum allowed error in degrees for the rotation computation. This can be used to speed ...
Definition: ProSHADE.h:179
unsigned int symmetryFold
The required fold of the sought symmetry. Applicable to C and D symmetries, otherwise leave 0...
Definition: ProSHADE.h:162
std::string axisOrder
A string specifying the order of the axis. Must have three characters and any permutation of &#39;x&#39;...
Definition: ProSHADE.h:183
This namespace contains all the external objects and their forward declarations.
int htmlReportLine
Iterator for current HTML line.
Definition: ProSHADE.h:187
bool energyLevelDist
Should the energy level distances descriptor be computed.
Definition: ProSHADE.h:132
double xTranslation
The number of angstroms by which the structure should be translated along the X axis.
Definition: ProSHADE.h:171
int htmlReportLineProgress
Iterator for current HTML line in the progress bar.
Definition: ProSHADE.h:188
double bFactorChange
This value will be used to change the B-factors if required by the user.
Definition: ProSHADE.h:89
bool wasResolutionGiven
Variable stating whether the resolution value was given by the user, or decided automatically.
Definition: ProSHADE.h:79
ProSHADE_settings()
Contructor for the ProSHADE_settings class.
Definition: ProSHADE.cpp:69
double peakHeightNoIQRs
How many interquartile ranges should be used to distinguish &#39;false&#39; peaks from the true ones...
Definition: ProSHADE.h:123
bool wasBChangeGiven
Variable stating whether the B factor change (sharpening/blurring) value was given by the user...
Definition: ProSHADE.h:90
double yTranslation
The number of angstroms by which the structure should be translated along the Y axis.
Definition: ProSHADE.h:172
double mapFragBoxSize
Should the clear map be fragmented into boxes? If so, put box size here, otherwise leave 0...
Definition: ProSHADE.h:151
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
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
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