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
00091 virtual ~EmpiricalHSShiftProcessor();
00092
00094
00097
00130 virtual void init();
00131
00133
00136
00142 virtual bool start();
00143
00144
00157 virtual Processor::Result operator () (Composite& composite);
00158
00176 virtual bool finish();
00177
00179
00182
00183 Options options;
00184
00187 void setDefaultOptions();
00189
00190 protected:
00191
00192
00193
00194
00195 class BALL_EXPORT PropertiesForShift_
00196 {
00197 public:
00198
00201 PropertiesForShift_(int verbosity_ = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
00202
00205 Atom* current_atom;
00206
00223 bool computeProperties_(Atom* atom, std::set<String> properties);
00224
00236 std::pair<float, String> operator [] (const String& property_name);
00237
00242 static bool isDiscrete(String property);
00243
00247 static bool isMixed(String property);
00248
00249 protected:
00250
00251
00252
00253 std::map<String, float> properties_real_;
00254
00255 std::map<String, String> properties_string_;
00256
00257 protected:
00258
00259 float getChiAngle_(Residue* residue);
00260 float getChi2Angle_(Residue* residue);
00261 char getAminoAcid_(Residue* residue);
00262 char getSecondaryStructure_(Residue* residue);
00263 float getHA_HBondLen_(Residue* residue);
00264 float getHA2_HBondLen_(Residue* residue);
00265 float getHN_HBondLen_(Residue* residue);
00266 float getO_HBondLen_(Residue* residue);
00267 bool hasDisulfidBond_(Residue* residue);
00268 bool hasHA_HBond_(Residue* residue);
00269 bool hasHA2_HBond_(Residue* residue);
00270 bool hasHN_HBond_(Residue* residue);
00271 bool hasO_HBond_(Residue* residue);
00272
00273 private:
00274
00275 int verbosity_;
00276 };
00277
00278
00279
00280
00281
00282 class ShiftHyperSurface_
00283 {
00284 public:
00285 typedef std::map<String, std::map<String, float> > tabletype;
00286
00290
00291 enum HYPERSURFACE__TYPE{
00292 REAL__REAL,
00293 REAL__DISCRETE,
00294 DISCRETE__REAL,
00295 DISCRETE__DISCRETE,
00296 CHI__REAL,
00297 REAL__CHI,
00298 CHI__DISCRETE,
00299 DISCRETE__CHI,
00300 CHI__CHI,
00301 SINGLE__REAL,
00302 SINGLE__DISCRETE,
00303 SINGLE__CHI
00304 };
00305
00306
00307
00308 ShiftHyperSurface_(int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL);
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 ShiftHyperSurface_(String filename, String atomtype,
00335 String firstproperty, String secondproperty,
00336 int verbosity = EmpiricalHSShiftProcessor::VERBOSITY_LEVEL_CRITICAL)
00337 throw(Exception::FileNotFound);
00338
00341 virtual ~ShiftHyperSurface_();
00342
00352 float operator () (PropertiesForShift_& properties);
00353
00357 bool isvalid(){return !invalid_;}
00358
00359
00360 float getTotalAverage() {return average_;}
00361
00362 private:
00363
00364
00365 float getTableAverage_();
00366
00367
00368 float getTableRowAverage_(const std::map<String, float>& row);
00369
00370
00371 float getTableColumnAverage_(const String& name);
00372
00377 bool tableHasColumn_(const String& name) ;
00378
00398 void parseDataFile_(BALL::File& file, String filename) ;
00399
00400
00401 void convertToReal_(const vector<String>& input, vector<float>& output);
00402
00406 void setType_(String firstproperty, String secondproperty);
00407
00408
00409 int type_;
00410
00411
00412 String first_property_;
00413 String second_property_;
00414
00415
00416 CubicSpline2D s2d_;
00417 std::map <String, CubicSpline1D > s1d_;
00418
00419 std::map <String, std::map<String, float> > table_;
00420
00421
00422
00423 std::map <String, float> row_averages_;
00424 std::map <String, float> col_averages_;
00425
00426
00427 float row_spacing_;
00428 float col_spacing_;
00429
00430
00431 bool invalid_;
00432
00433
00434
00435 float average_;
00436
00437
00438 int verbosity_;
00439
00440
00441 vector<String> y_axis_values_;
00442 vector<vector<String> > x_axis_values_;
00443 vector<vector<float> > sample_values_;
00444 };
00445
00446
00447
00448
00449
00450
00451 std::vector<PropertiesForShift_> targets_;
00452
00453
00454
00455
00456 vector<String> target_names_;
00457
00458
00459
00460
00461
00462
00463 vector< std::set<String> > target_property_names_;
00464
00465
00466
00467
00468
00469
00470
00471
00472 vector< std::map< std::pair<String, String>, String > > property_files_;
00473
00474
00475
00476
00477 std::map< String, vector< std::pair<String, String> > > property_pairs_;
00478
00479
00480
00481
00482
00483
00484 std::map<String, std::map <std::pair<String, String>,EmpiricalHSShiftProcessor::ShiftHyperSurface_> > hypersurfaces_;
00485
00486
00487
00488
00489 bool exclude_prolins_;
00490
00491
00492 std::map<String, float> ssbond_correction_;
00493
00494 private:
00495
00496
00497
00498
00499 void printParameters_();
00500 void printTargets_();
00501
00502
00503
00504
00505
00506
00507 void postprocessing_();
00508
00510 int verbosity_;
00511
00512 };
00513 }
00514 #endif // BALL_NMR_EMPIRICALHSSHIFTPROCESSOR_H