ProSHADE  0.6.5 (NOV 2018)
Protein Shape Descriptors and Symmetry Detection
All Classes Namespaces Files Functions Variables Pages
mapSearch.cpp
Go to the documentation of this file.
1 
20 //============================================ ProSHADE
21 #include "../proshade/ProSHADE.h"
22 #include "../proshade/ProSHADE_internal.h"
23 
24 //============================================ Main
25 int main ( int argc, char **argv )
26 {
27  //======================================== Initialise variables
29  setUp->verbose = -1;
30  setUp->extraSpace = 0.0;
31  setUp->volumeTolerance = 10.0;
32  setUp->useCOM = false;
33 
34  std::string mapName = "../xx_searchMap_data/02/emd_7780.map";
35  setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainA.pdb" );
36 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainB.pdb" );
37 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainC.pdb" );
38 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainD.pdb" );
39 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainE.pdb" );
40 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainG.pdb" );
41 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainH.pdb" );
42 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainI.pdb" );
43 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainJ.pdb" );
44 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainK.pdb" );
45 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainL.pdb" );
46 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainM.pdb" );
47 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainN.pdb" );
48 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainO.pdb" );
49 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainP.pdb" );
50 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainQ.pdb" );
51 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainS.pdb" );
52 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainT.pdb" );
53 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainU.pdb" );
54 // setUp->structFiles.emplace_back ( "../xx_searchMap_data/02/ChainV.pdb" );
55 
56  std::vector<std::array<double,2> > strRadii;
57  std::vector<double> shSpacing ( setUp->structFiles.size(), setUp->shellSpacing );
58  std::vector<unsigned int> bandVec ( setUp->structFiles.size(), setUp->bandwidth );
59  std::vector<unsigned int> thetaVec ( setUp->structFiles.size(), setUp->theta );
60  std::vector<unsigned int> phiVec ( setUp->structFiles.size(), setUp->phi );
61  std::vector<unsigned int> glIntegVec ( setUp->structFiles.size(), setUp->glIntegOrder );
62  std::vector<double> extraVec ( setUp->structFiles.size(), setUp->extraSpace );
63  std::array<double,2> hlpArr;
64 
65  double maxRange = 0.0;
66  double secRange = 0.0;
67 
68  //======================================== For each input structure
69  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( setUp->structFiles.size ( ) ); strIt++ )
70  {
71  //==================================== Initialise structure reading
73 
74  //==================================== Read in the structures
75  if ( ProSHADE_internal::checkFileType ( setUp->structFiles.at ( strIt ) ) == 1 )
76  {
77  str->getDensityMapFromPDB ( setUp->structFiles.at ( strIt ),
78  &shSpacing.at ( strIt ),
79  setUp->mapResolution,
80  &bandVec.at ( strIt ),
81  &thetaVec.at ( strIt ),
82  &phiVec.at ( strIt ),
83  &glIntegVec.at ( strIt ),
84  &extraVec.at ( strIt ),
85  setUp->mapResDefault,
86  setUp,
87  setUp->bFactorValue,
88  false,
89  setUp->overlayDefaults );
90  }
91  else
92  {
93  str->getDensityMapFromMAP ( setUp->structFiles.at ( strIt ),
94  &shSpacing.at ( strIt ),
95  setUp->mapResolution,
96  &bandVec.at ( strIt ),
97  &thetaVec.at ( strIt ),
98  &phiVec.at ( strIt ),
99  &glIntegVec.at ( strIt ),
100  &extraVec.at ( strIt ),
101  setUp->mapResDefault,
102  setUp->rotChangeDefault,
103  setUp,
104  setUp->overlayDefaults );
105  }
106 
107  //==================================== Find input structure radius
108  maxRange = std::max ( str->getMapXRange ( ), std::max ( str->getMapYRange ( ), str->getMapZRange ( ) ) );
109  if ( maxRange == str->getMapXRange ( ) )
110  {
111  secRange = std::max ( str->getMapYRange ( ), str->getMapZRange ( ) );
112  }
113  else if ( maxRange == str->getMapYRange ( ) )
114  {
115  secRange = std::max ( str->getMapXRange ( ), str->getMapZRange ( ) );
116  }
117  else
118  {
119  secRange = std::max ( str->getMapXRange ( ), str->getMapYRange ( ) );
120  }
121 
122  hlpArr[0] = strIt;
123  hlpArr[1] = sqrt ( pow ( maxRange, 2.0 ) + pow ( secRange, 2.0 ) );
124  strRadii.emplace_back ( hlpArr );
125 
126  //==================================== Free memory
127  delete str;
128  }
129 
130  //======================================== Sort by radii
131  std::sort ( strRadii.begin (), strRadii.end(), [](const std::array<double,2>& a, const std::array<double,2>& b) { return a[1] > b[1]; } );
132 
133  //======================================== Find settings max's and min's
134  double minSpacing = std::numeric_limits<double>::infinity ( );
135  unsigned int maxBand = 0;
136  unsigned int maxTheta = 0;
137  unsigned int maxPhi = 0;
138  unsigned int maxGlInt = 0;
139  double maxExtraSpace = 0.0;
140  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( setUp->structFiles.size ( ) ); iter++ )
141  {
142  if ( shSpacing.at ( iter ) < minSpacing ) { minSpacing = shSpacing.at ( iter ); }
143  if ( bandVec.at ( iter ) > maxBand ) { maxBand = bandVec.at ( iter ); }
144  if ( thetaVec.at ( iter ) > maxTheta ) { maxTheta = thetaVec.at ( iter ); }
145  if ( phiVec.at ( iter ) > maxPhi ) { maxPhi = phiVec.at ( iter ); }
146  if ( glIntegVec.at ( iter ) > maxGlInt ) { maxGlInt = glIntegVec.at ( iter ); }
147  if ( extraVec.at ( iter ) > maxExtraSpace) { maxExtraSpace = extraVec.at ( iter ); }
148  }
149 
150  double minSpacingCopy = minSpacing;
151  unsigned int maxBandCopy = maxBand;
152  unsigned int maxThetaCopy = maxTheta;
153  unsigned int maxPhiCopy = maxPhi;
154  unsigned int maxGlIntCopy = maxGlInt;
155  double maxExtraSpaceCopy = maxExtraSpace;
156 
157  //======================================== Build the database
158  setUp->taskToPerform = ProSHADE::BuildDB;
159  setUp->databaseName = "testDB.bin";
160 
161  setUp->shellSpacing = minSpacing;
162  setUp->bandwidth = maxBand;
163  setUp->theta = maxTheta;
164  setUp->phi = maxPhi;
165  setUp->glIntegOrder = maxGlInt;
166  setUp->extraSpace = maxExtraSpace;
167 
168  setUp->clearMapData = false;
169  setUp->saveWithAndWithout = true;
170 
171  ProSHADE::ProSHADE *run = new ProSHADE::ProSHADE ( setUp );
172  delete run;
173 
174  //======================================== Read in the map
176  inMap->getDensityMapFromMAP ( mapName,
177  &minSpacingCopy,
178  setUp->mapResolution,
179  &maxBandCopy,
180  &maxThetaCopy,
181  &maxPhiCopy,
182  &maxGlIntCopy,
183  &maxExtraSpaceCopy,
184  setUp->mapResDefault,
185  setUp->rotChangeDefault,
186  setUp,
187  setUp->overlayDefaults );
188 
189  //======================================== Map the query to the shells
190  inMap->keepPhaseInMap ( setUp->alpha,
191  setUp->bFactorChange,
192  &maxBandCopy,
193  &maxThetaCopy,
194  &maxPhiCopy,
195  &maxGlIntCopy,
196  setUp,
197  setUp->useCOM,
198  setUp->noIQRsFromMap,
199  setUp->verbose,
200  setUp->clearMapData,
201  setUp->rotChangeDefault,
202  setUp->overlayDefaults,
203  setUp->maskBlurFactor,
204  setUp->maskBlurFactorGiven );
205 
206  inMap->mapPhaselessToSphere ( setUp,
207  maxThetaCopy,
208  maxPhiCopy,
209  minSpacingCopy,
210  setUp->manualShells,
211  true,
212  false );
213 
214  //======================================== Database comparison settings
216 
217  // ... Settings regarding which distances to compute
218  dbCompSetUp->energyLevelDist = true;
219  dbCompSetUp->traceSigmaDist = true;
220  dbCompSetUp->fullRotFnDist = true;
221 
222  // ... Settings regarding hierarchical distance computation
223  dbCompSetUp->enLevelsThreshold = -999.9;
224  dbCompSetUp->trSigmaThreshold = -999.9;
225 
226  // ... Settings regarding the task
227  dbCompSetUp->taskToPerform = ProSHADE::Distances;
228 
229  // ... Settings regarding the database
230  dbCompSetUp->databaseName = setUp->databaseName;
231  dbCompSetUp->volumeTolerance = setUp->volumeTolerance;
232  dbCompSetUp->clearMapData = false;
233  dbCompSetUp->extraSpace = setUp->extraSpace;
234 
235  // ... Settings regarding loudness
236  dbCompSetUp->verbose = setUp->verbose;
237  dbCompSetUp->htmlReport = setUp->htmlReport;
238 
239  //======================================== For each input structure, fragment the map
240  for ( unsigned int strIt = 0; strIt < static_cast<unsigned int> ( strRadii.size ( ) ); strIt++ )
241  {
242  //==================================== Fragmentation set up
243  setUp->mapFragBoxSize = strRadii.at(strIt)[1] * 2.0;
244 
245  //==================================== Do the fragmentation
246  std::vector<ProSHADE_internal::ProSHADE_data*> frags = inMap->fragmentMap ( setUp, false );
247 
248  //==================================== For each passing fragment, check against the input db
249  for ( unsigned int frIt = 0; frIt < static_cast<unsigned int> ( frags.size() ); frIt++ )
250  {
251  //================================ Initialise fragment comparison settings
252  std::stringstream frgName;
253  frgName << "proshade_tmp_frag" << strIt << "_" << frIt << ".map";
254  dbCompSetUp->structFiles.clear ( );
255  dbCompSetUp->structFiles.emplace_back ( frgName.str() );
256 
257  //================================ Print the fragment - this could be made fasted by using the internal representation, but it would also require more work. Will get back to this in due time.
258  frags.at(frIt)->writeMap ( frgName.str(), frags.at(frIt)->getMap ( ) );
259 
260  //================================ Now, compare the fragment against the database
261  ProSHADE::ProSHADE *compareFrag = new ProSHADE::ProSHADE ( dbCompSetUp );
262 
263  //================================ And get distances
264  std::vector<double> crossCorrDists = compareFrag->getCrossCorrDists ( );
265  std::vector<double> traceSigmaDists = compareFrag->getTraceSigmaDists ( );
266  std::vector<double> rotFunDists = compareFrag->getRotFunctionDists ( );
267 
268  //================================ Release the computation object
269  delete compareFrag;
270 
271  for ( int i = 0; i < static_cast<int> ( crossCorrDists.size() ); i++ )
272  {
273 // if ( rotFunDists.at(i) > 0.1 )
274  {
275  printf ( "%i\t%i\t||\t%+.3f\t\t%+.3f\t\t%+.3f\t\t%s\n", strIt, frIt, crossCorrDists.at(i), traceSigmaDists.at(i), rotFunDists.at(i), dbCompSetUp->structFiles.at(i+1).c_str() );
276  }
277  }
278  }
279 
280  std::cout << " ... " << std::endl; exit (0);
281 
282  //==================================== Clean up
283  for ( unsigned int iter = 0; iter < static_cast<unsigned int> ( frags.size ( ) ); iter++ )
284  {
285  delete frags.at(iter);
286  }
287  frags.clear ( );
288  }
289 
290  //======================================== Free database comparison memory
291  delete dbCompSetUp;
292 
293  //======================================== Free memory
294  delete inMap;
295  delete setUp;
296 
297  //======================================== DONE
298  return 0;
299 }
300 
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
std::vector< double > getRotFunctionDists(void)
Accessor function for the rotation function based distances vector.
Definition: ProSHADE.cpp:3011
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
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
unsigned int bandwidth
This parameter determines the angular resolution of the spherical harmonics decomposition.
Definition: ProSHADE.h:80
void keepPhaseInMap(double alpha, double bFac, unsigned int *bandwidth, unsigned int *theta, unsigned int *phi, unsigned int *glIntegOrder, ProSHADE::ProSHADE_settings *settings, bool useCom=true, double maxMapIQR=10.0, int verbose=0, bool clearMapData=true, bool rotDefaults=false, bool overlapDefaults=false, double blurFactor=500.0, bool maskBlurFactorGiven=false)
This function keeps the phase information from the density map and prepares the data for SH coefficie...
bool htmlReport
Should HTML report for the run be created?
Definition: ProSHADE.h:186
int verbose
Should the software report on the progress, or just be quiet? Value between 0 (quiet) and 4 (loud) ...
Definition: ProSHADE.h:189
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 fullRotFnDist
Should the full rotation function distances descriptor be computed.
Definition: ProSHADE.h:134
bool maskBlurFactorGiven
Was a specific value of the blurring factor requested by the user?
Definition: ProSHADE.h:148
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 volumeTolerance
The percentage tolerance on each dimmension when comparing one structure to entire database...
Definition: ProSHADE.h:159
std::vector< double > getTraceSigmaDists(void)
Accessor function for the trace sigma distances vector.
Definition: ProSHADE.cpp:2985
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
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
unsigned int phi
This parameter is the latitudd of the spherical grid mapping. It should be 2 * bandwidth unless there...
Definition: ProSHADE.h:84
bool energyLevelDist
Should the energy level distances descriptor be computed.
Definition: ProSHADE.h:132
double bFactorChange
This value will be used to change the B-factors if required by the user.
Definition: ProSHADE.h:89
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.
double mapFragBoxSize
Should the clear map be fragmented into boxes? If so, put box size here, otherwise leave 0...
Definition: ProSHADE.h:151
This class stores all the settings and is passed to the executive classes instead of multitude of par...
Definition: ProSHADE.h:74
unsigned int manualShells
Should the user require so, the maximum number of radial shells can be set.
Definition: ProSHADE.h:98
std::vector< double > getCrossCorrDists(void)
Accessor function for the cross-correlation distances vector.
Definition: ProSHADE.cpp:2959
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
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