00001 #ifndef BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
00002 #define BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H
00003
00004 #ifndef BALL_MATHS_CUBICSPLINE2D_H
00005 # include <BALL/MATHS/cubicSpline2D.h>
00006 #endif
00007
00008 #ifndef BALL_MATHS_CUBICSPLINE1D_H
00009 # include <BALL/MATHS/cubicSpline1D.h>
00010 #endif
00011
00012
00013 #ifndef BALL_FORMAT_GENERICMOLFILE_H
00014 # include <BALL/FORMAT/genericMolFile.h>
00015 #endif
00016
00017 #ifndef BALL_NMR_SHIFT_MODULE_H
00018 # include<BALL/NMR/shiftModule.h>
00019 #endif
00020
00021 #ifndef BALL_KERNEL_EXPRESSION_H
00022 # include<BALL/KERNEL/expression.h>
00023 #endif
00024
00025 #ifndef BALL_DATATYPE_OPTIONS_H
00026 # include <BALL/DATATYPE/options.h>
00027 #endif
00028
00029
00030 #include <set>
00031 #include <map>
00032
00033 namespace BALL
00034 {
00035 class Atom;
00036
00040 class BALL_EXPORT EmpiricalHSShiftProcessor
00041 : public ShiftModule
00042 {
00043 public:
00044
00045 BALL_CREATE(EmpiricalHSShiftProcessor)
00046
00047 static const int VERBOSITY_LEVEL_CRITICAL;
00048 static const int VERBOSITY_LEVEL_DEBUG;
00049
00053
00054 struct BALL_EXPORT Option
00055 {
00058 static const char* VERBOSITY;
00059
00060 };
00061
00063 struct BALL_EXPORT Default
00064 {
00065 static const int VERBOSITY;
00066 };
00067
00069
00070
00074
00078 static const char* PROPERTY__EHS_SHIFT;
00079
00081
00084
00087 EmpiricalHSShiftProcessor()
00088 throw();
00089
00092 virtual ~EmpiricalHSShiftProcessor()
00093 throw();
00094
00096
00099
00132 virtual void init()
00133 throw();
00134
00136
00139
00145 virtual bool start()
00146 throw();
00147
00148
00161 virtual Processor::Result operator () (Composite& composite)
00162 throw();
00163
00181 virtual bool finish()
00182 throw();
00183
00185
00188
00189 Options options;
00190
00193 void setDefaultOptions();
00195
00196 protected:
00197
00198
00199
00200
00201 class BALL_EXPORT PropertiesForShift_
00202 {
00203 public:
00204
00207 PropertiesForShift_(int verbosity_ = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
00208 throw();
00209
00212 Atom* current_atom;
00213
00230 bool computeProperties_(Atom* atom, std::set<String> properties) throw();
00231
00243 std::pair<float, String> operator [] (const String& property_name) throw();
00244
00249 static bool isDiscrete(String property) throw();
00250
00254 static bool isMixed(String property) throw();
00255
00256 protected:
00257
00258
00259
00260 std::map<String, float> properties_real_;
00261
00262 std::map<String, String> properties_string_;
00263
00264 protected:
00265
00266 float getChiAngle_(Residue* residue) throw();
00267 float getChi2Angle_(Residue* residue) throw();
00268 char getAminoAcid_(Residue* residue) throw();
00269 char getSecondaryStructure_(Residue* residue) throw();
00270 float getHA_HBondLen_(Residue* residue) throw();
00271 float getHA2_HBondLen_(Residue* residue) throw();
00272 float getHN_HBondLen_(Residue* residue) throw();
00273 float getO_HBondLen_(Residue* residue) throw();
00274 bool hasDisulfidBond_(Residue* residue) throw();
00275 bool hasHA_HBond_(Residue* residue) throw();
00276 bool hasHA2_HBond_(Residue* residue) throw();
00277 bool hasHN_HBond_(Residue* residue) throw();
00278 bool hasO_HBond_(Residue* residue) throw();
00279
00280 private:
00281
00282 int verbosity_;
00283 };
00284
00285
00286
00287
00288
00289 class ShiftHyperSurface_
00290 {
00291 public:
00292 typedef std::map<String, std::map<String, float> > tabletype;
00293
00297
00298 enum HYPERSURFACE__TYPE{
00299 REAL__REAL,
00300 REAL__DISCRETE,
00301 DISCRETE__REAL,
00302 DISCRETE__DISCRETE,
00303 CHI__REAL,
00304 REAL__CHI,
00305 CHI__DISCRETE,
00306 DISCRETE__CHI,
00307 CHI__CHI,
00308 SINGLE__REAL,
00309 SINGLE__DISCRETE,
00310 SINGLE__CHI
00311 };
00312
00313
00314
00315 ShiftHyperSurface_(int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL) throw();
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 ShiftHyperSurface_(String filename, String atomtype,
00342 String firstproperty, String secondproperty,
00343 int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
00344 throw(Exception::FileNotFound);
00345
00348 virtual ~ShiftHyperSurface_() throw();
00349
00359 float operator () (PropertiesForShift_& properties) throw();
00360
00364 bool isvalid() throw(){return !invalid_;}
00365
00366
00367 float getTotalAverage() throw() {return average_;}
00368
00369 private:
00370
00371
00372 float getTableAverage_() throw();
00373
00374
00375 float getTableRowAverage_(const std::map<String, float>& row) throw();
00376
00377
00378 float getTableColumnAverage_(const String& name) throw();
00379
00384 bool tableHasColumn_(const String& name) throw();
00385
00405 void parseDataFile_(BALL::File& file, String filename) throw();
00406
00407
00408 void convertToReal_(const vector<String>& input, vector<float>& output) throw();
00409
00413 void setType_(String firstproperty, String secondproperty) throw();
00414
00415
00416 int type_;
00417
00418
00419 String first_property_;
00420 String second_property_;
00421
00422
00423 CubicSpline2D s2d_;
00424 std::map <String, CubicSpline1D > s1d_;
00425
00426 std::map <String, std::map<String, float> > table_;
00427
00428
00429
00430 std::map <String, float> row_averages_;
00431 std::map <String, float> col_averages_;
00432
00433
00434 float row_spacing_;
00435 float col_spacing_;
00436
00437
00438 bool invalid_;
00439
00440
00441
00442 float average_;
00443
00444
00445 int verbosity_;
00446
00447
00448 vector<String> y_axis_values_;
00449 vector<vector<String> > x_axis_values_;
00450 vector<vector<float> > sample_values_;
00451 };
00452
00453
00454
00455
00456
00457
00458 std::vector<PropertiesForShift_> targets_;
00459
00460
00461
00462
00463 vector<String> target_names_;
00464
00465
00466
00467
00468
00469
00470 vector< std::set<String> > target_property_names_;
00471
00472
00473
00474
00475
00476
00477
00478
00479 vector< std::map< std::pair<String, String>, String > > property_files_;
00480
00481
00482
00483
00484 std::map< String, vector< std::pair<String, String> > > property_pairs_;
00485
00486
00487
00488
00489
00490
00491 std::map<String, std::map <std::pair<String, String>,EmpiricalHSShiftProcessor::ShiftHyperSurface_> > hypersurfaces_;
00492
00493
00494
00495
00496 bool exclude_prolins_;
00497
00498
00499 std::map<String, float> ssbond_correction_;
00500
00501 private:
00502
00503
00504
00505
00506 void printParameters_() throw();
00507 void printTargets_() throw();
00508
00509
00510
00511
00512
00513
00514 void postprocessing_() throw();
00515
00517 int verbosity_;
00518
00519 };
00520 }
00521 #endif // BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H