BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
empiricalHSShiftProcessor.h
Go to the documentation of this file.
1 #ifndef BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
2 #define BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
3 
4 #ifndef BALL_MATHS_CUBICSPLINE2D_H
6 #endif
7 
8 #ifndef BALL_MATHS_CUBICSPLINE1D_H
10 #endif
11 
12 
13 #ifndef BALL_FORMAT_GENERICMOLFILE_H
15 #endif
16 
17 #ifndef BALL_NMR_SHIFT_MODULE_H
18 # include<BALL/NMR/shiftModule.h>
19 #endif
20 
21 #ifndef BALL_KERNEL_EXPRESSION_H
22 # include<BALL/KERNEL/expression.h>
23 #endif
24 
25 #ifndef BALL_DATATYPE_OPTIONS_H
26 # include <BALL/DATATYPE/options.h>
27 #endif
28 
29 
30 #include <set>
31 #include <map>
32 
33 namespace BALL
34 {
35  class Atom;
36 
41  : public ShiftModule
42  {
43  public:
44 
46 
47  static const int VERBOSITY_LEVEL_CRITICAL;
48  static const int VERBOSITY_LEVEL_DEBUG;
49 
53  struct BALL_EXPORT Option
55  {
58  static const char* VERBOSITY;
59 
60  };
61 
64  {
65  static const int VERBOSITY;
66  };
67 
69 
70 
74 
78  static const char* PROPERTY__EHS_SHIFT;
79 
81 
84 
88 
91  virtual ~EmpiricalHSShiftProcessor();
92 
94 
97 
130  virtual void init();
131 
133 
136 
142  virtual bool start();
143 
144 
157  virtual Processor::Result operator () (Composite& composite);
158 
176  virtual bool finish();
177 
179 
182  Options options;
184 
187  void setDefaultOptions();
189 
190  protected:
191 
192 
193  /*_ Neested class providing atom properties for the shift computations
194  * */
196  {
197  public:
198 
202 
206 
223  bool computeProperties_(Atom* atom, std::set<String> properties);
224 
236  std::pair<float, String> operator [] (const String& property_name);
237 
242  static bool isDiscrete(String property);
243 
247  static bool isMixed(String property);
248 
249  protected:
250 
251  // Storing the atoms properties
252  // ...as numerical value
253  std::map<String, float> properties_real_;
254  // ... as alphanumerical/discrete value
255  std::map<String, String> properties_string_;
256 
257  protected:
258 
259  float getChiAngle_(Residue* residue);
260  float getChi2Angle_(Residue* residue);
261  char getAminoAcid_(Residue* residue);
262  char getSecondaryStructure_(Residue* residue);
263  float getHA_HBondLen_(Residue* residue);
264  float getHA2_HBondLen_(Residue* residue);
265  float getHN_HBondLen_(Residue* residue);
266  float getO_HBondLen_(Residue* residue);
267  bool hasDisulfidBond_(Residue* residue);
268  bool hasHA_HBond_(Residue* residue);
269  bool hasHA2_HBond_(Residue* residue);
270  bool hasHN_HBond_(Residue* residue);
271  bool hasO_HBond_(Residue* residue);
272 
273  private:
274  // verbosity of the classes methods
275  int verbosity_;
276  }; // end of nested class
277 
278 
279  /*_ Neested class handling the empirical hypersurfaces.
280  **/
281 
283  {
284  public:
285  typedef std::map<String, std::map<String, float> > tabletype;
286 
290 
294  DISCRETE__REAL, // not used
296  CHI__REAL, // not used
303  SINGLE__CHI
304  };
305 
306  /*_ Constructors and Destructors.
307  */
309 
310  /*_ Detailed constructor.
311  * Creates a ShiftHyperSurface given the <b>filename<\b> of the data file,
312  * the atom type, and the two property types according to its deduced
313  * hypersurface types (see {\tt HYPERSURFACE__TYPE()}).
314  *
315  * If the data file cannot be found, no hypersurface is created.
316  *
317  * In the special case that the two properties have the same type, we create just one table entry in
318  * {\tt table_} or just one spline { \tt in s1d_ }.
319  *
320  * In case of hypersurfaces of type {\tt REAL__DISCRETE} the splines default values are set to the
321  * row-averages if given specified in the datafile.
322  *
323  * In case of hypersurfaces of type {\tt REAL__CHI, REAL__REAL } the splines default values are
324  * set to the splines averages.
325  *
326  * In all cases but look-up tables the bounds for the splines are set as specified in
327  * the datafile if specified.
328  *
329  * Note:
330  * The spline or value can be accessed
331  * by the {\tt operator () } given __not__ the property-value, but the property name.
332  *
333  */
334  ShiftHyperSurface_(String filename, String atomtype,
335  String firstproperty, String secondproperty,
337  throw(Exception::FileNotFound);
338 
341  virtual ~ShiftHyperSurface_();
342 
352  float operator () (PropertiesForShift_& properties);
353 
357  bool isvalid(){return !invalid_;}
358 
359  // Returns the total average given in the input file.
360  float getTotalAverage() {return average_;}
361 
362  private:
363 
364  // Computes the average of the look-up table values.
365  float getTableAverage_();
366 
367  // Computes the row average of the look-up table given a row name.
368  float getTableRowAverage_(const std::map<String, float>& row);
369 
370  // Computes the column average of the look-up table given a column name.
371  float getTableColumnAverage_(const String& name);
372 
377  bool tableHasColumn_(const String& name) ;
378 
398  void parseDataFile_(BALL::File& file, String filename) ;
399 
400  // Method to convert a vector of strings into a vector of floats {/tt output}.
401  void convertToReal_(const vector<String>& input, vector<float>& output);
402 
406  void setType_(String firstproperty, String secondproperty);
407 
408  // The type of the hypersurface.
409  int type_;
410 
411  // The properties of the hypersurface.
412  String first_property_;
413  String second_property_;
414 
415  // The hypersurface can be a 2D spline, 1D spline or a look-up table.
416  CubicSpline2D s2d_;
417  std::map <String, CubicSpline1D > s1d_;
418  // Note: access of the look--up table: first the discrete key x, second the numerical key y.
419  std::map <String, std::map<String, float> > table_;
420 
421  // The averages of the hypersurface as read from the file.
422  // //TODO rename to row_defaults
423  std::map <String, float> row_averages_;
424  std::map <String, float> col_averages_;
425 
426  // The spacing in x and y direction as read from the file.
427  float row_spacing_;
428  float col_spacing_;
429 
430  // Flag to store whether the spline we created is valid.
431  bool invalid_;
432 
433  // The average over the complete hypersurface as read from the file.
434  // Note: this average maybe weighted in non-obvious ways!
435  float average_;
436 
437  // verbosity of the method
438  int verbosity_;
439 
440  // The underlying data of the hypersurface as read from the file.
441  vector<String> y_axis_values_;
442  vector<vector<String> > x_axis_values_;
443  vector<vector<float> > sample_values_;
444  };
445 
446 
447 
448 
449  /*_ The target atoms collected by {\tt operator ()}.
450  */
451  std::vector<PropertiesForShift_> targets_;
452 
453  /*_ The target atom types stored as a vector of strings collected from the ini-file
454  * by {\tt init ()}.
455  */
456  vector<String> target_names_;
457 
458  /*_ The target properties used for determine the
459  * empirical hypersurface shifts. The properties are collected
460  * from the ini-file by {\tt init ()} and are stored per target atom
461  * in the same order as the target_names.
462  */
463  vector< std::set<String> > target_property_names_;
464 
465  /*_ The file names of the files storing the property-data-splines for computing the
466  * shift contributions are stored in a map, whose key is the pair of
467  * properties, to which the splines belong.
468  * The maps are stored per target atom type in the same order as the target_names.
469  * The files are specified in the section {\tt EmpiricalShiftHyperSurfaces}
470  * of the file {\tt ShiftX.ini} and are collected by {\tt init ()}.
471  */
472  vector< std::map< std::pair<String, String>, String > > property_files_;
473 
474  /*_ The property pairs for each atom type are stored in this map.
475  * The map is created in {\tt init ()}.
476  **/
477  std::map< String, vector< std::pair<String, String> > > property_pairs_;
478 
479  /*_ The hypersurfaces are precomputed by {\tt init()}
480  * and then are stored per atom type in a map with key atom_type of
481  * maps with the property pair as key.
482  */
483 
484  std::map<String, std::map <std::pair<String, String>,EmpiricalHSShiftProcessor::ShiftHyperSurface_> > hypersurfaces_;
485 
486  /*_ Option to exclude prolins from the shift computations.
487  Default is false.
488  */
490 
491  // Map containing possible correction terms for ssbonds.
492  std::map<String, float> ssbond_correction_;
493 
494  private:
495 
496  /*_ Some debugging functions printing parameter/effector/target information
497  * to the Log stream.
498  */
499  void printParameters_();
500  void printTargets_();
501 
502  /*_ A function to perform some ShiftX-y postprocessing:
503  add for all CA-atoms 0.2 times the EF-shift-value of the bound HA-atoms.
504  Due to some reason ShiftX does not perform this postprocessing
505  for the empirical Hypersurface contributions.
506  */
507  void postprocessing_();
508 
510  int verbosity_;
511 
512  };// end of class
513 } // end of namespace
514 #endif // BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
vector< std::set< String > > target_property_names_
std::map< String, vector< std::pair< String, String > > > property_pairs_
#define BALL_CREATE(name)
Definition: create.h:62
std::map< String, std::map< std::pair< String, String >, EmpiricalHSShiftProcessor::ShiftHyperSurface_ > > hypersurfaces_
vector< std::map< std::pair< String, String >, String > > property_files_
std::map< String, std::map< String, float > > tabletype
std::map< String, float > ssbond_correction_
std::vector< PropertiesForShift_ > targets_
char Atom[5]
Definition: PDBdefs.h:257
#define BALL_EXPORT
Definition: COMMON/global.h:50