26 #include <basic/database/open.hh>
27 #include <basic/Tracer.hh>
28 #include <basic/database/sql_utils.hh>
29 #include <basic/database/schema_generator/PrimaryKey.hh>
30 #include <basic/database/schema_generator/ForeignKey.hh>
31 #include <basic/database/schema_generator/Column.hh>
32 #include <basic/database/schema_generator/Schema.hh>
36 #include <utility/io/izstream.hh>
37 #include <utility/exit.hh>
38 #include <utility/string_util.hh>
39 #include <utility/vector1.hh>
40 #include <utility/sql_database/DatabaseSessionManager.hh>
43 #include <cppdb/frontend.h>
46 #include <boost/foreach.hpp>
47 #define foreach BOOST_FOREACH
52 #include <ObjexxFCL/FArray3D.hh>
64 using std::stringstream;
66 using cppdb::statement;
67 using basic::database::open;
69 using utility::io::izstream;
70 using utility::string_split;
72 using utility::sql_database::sessionOP;
74 static Tracer
tr(
"core.scoring.hbonds.HBondDatabase");
81 params_database_tag_(
""),
82 HBFadeInterval_lookup_by_name_(),
83 HBFadeInterval_lookup_(),
88 HBPoly1D_lookup_by_name_(),
111 params_database_tag_( hbond_params_database_tag ),
112 HBFadeInterval_lookup_by_name_(),
113 HBFadeInterval_lookup_(),
118 HBPoly1D_lookup_by_name_(),
136 ReferenceCount( src ),
137 initialized_(src.initialized_),
139 params_database_tag_( src.params_database_tag_ ),
140 HBFadeInterval_lookup_by_name_(src.HBFadeInterval_lookup_by_name_),
141 HBFadeInterval_lookup_(src.HBFadeInterval_lookup_),
142 AHdist_short_fade_lookup_(src.AHdist_short_fade_lookup_),
143 AHdist_long_fade_lookup_(src.AHdist_long_fade_lookup_),
144 cosBAH_fade_lookup_(src.cosBAH_fade_lookup_),
145 cosAHD_fade_lookup_(src.cosAHD_fade_lookup_),
146 HBPoly1D_lookup_by_name_(src.HBPoly1D_lookup_by_name_),
147 HBPoly1D_lookup_(src.HBPoly1D_lookup_),
148 AHdist_poly_lookup_(src.AHdist_poly_lookup_),
149 cosBAH_short_poly_lookup_(src.cosBAH_short_poly_lookup_),
150 cosBAH_long_poly_lookup_(src.cosBAH_long_poly_lookup_),
151 cosAHD_short_poly_lookup_(src.cosAHD_short_poly_lookup_),
152 cosAHD_long_poly_lookup_(src.cosAHD_long_poly_lookup_),
153 chi_poly_lookup_(src.chi_poly_lookup_),
156 weight_type_lookup_(src.weight_type_lookup_)
164 map< string const, HBondDatabaseCOP >::const_iterator
169 return param_db->second();
175 map< string const, HBondDatabaseCOP >::const_iterator
180 return param_db->second();
193 tr <<
"Re-intializing HBond Database when it has already been initialized!";
221 string HBFadeInterval_fname =
"scoring/score_functions/hbonds/" +
params_database_tag_ +
"/HBFadeIntervals.csv";
224 if (!open(s, HBFadeInterval_fname)){
225 stringstream message;
226 message <<
"Unable to open hbond parameter file HBFadeInterval:" << endl;
227 message <<
"'" << HBFadeInterval_fname <<
"'";
228 utility_exit_with_message(message.str());
235 string fade_interval_name;
236 bool smoothed(
false);
237 Real min0, fmin, fmax, max0;
238 while ( getline( s, line ) ) {
240 tokens = string_split( line,
',');
242 if (tokens.size() != ntokens){
243 stringstream message;
244 message <<
"FadeInterval definition line does not have the expected number of fields " << endl;
245 message <<
"Expected '" << ntokens <<
"' tokens but found '" << tokens.size() <<
"' tokens. " << endl;
246 message << line << endl;
247 utility_exit_with_message(message.str());
251 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> id; }
252 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> fade_interval_name; }
254 string junction_type;
255 stringstream buf; buf << tokens[i]; i++; buf >> junction_type;
256 if( junction_type ==
"smoothed" ){
258 }
else if (junction_type ==
"piecewise_linear"){
261 stringstream message;
263 <<
"On line " << HBFadeInterval_fname <<
":" << line_no <<
": '" << line <<
"'"
264 <<
"the junction_type should be either 'smoothed' or 'piecewise_linear', "
265 <<
"however it the unrecognized string '" << junction_type <<
"'." << endl;
266 utility_exit_with_message(message.str());
269 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> min0; }
270 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> fmin; }
271 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> fmax; }
272 { stringstream buf;buf.precision(16); buf << tokens[i]; i++; buf >> max0; }
275 new FadeInterval(fade_interval_name, min0, fmin, fmax, max0, smoothed));
278 stringstream message;
279 message <<
"The id fields in the HBFadeInterval file '" << HBFadeInterval_fname <<
"'" << endl;
280 message <<
"are out of order or missing: Expected id: " <<
HBFadeInterval_lookup_.size() + 1 <<
" but instead found id: " <<
id << endl;
281 message <<
"on line: '" << line <<
"'" << endl;
282 utility_exit_with_message(message.str());
297 string HBPoly1D_fname =
"scoring/score_functions/hbonds/" +
params_database_tag_ +
"/HBPoly1D.csv";
300 if (!open(s, HBPoly1D_fname)){
301 stringstream message;
302 message <<
"Unable to open hbond parameter file HBPoly1D:" << endl;
303 message << HBPoly1D_fname;
304 utility_exit_with_message(message.str());
310 string polynomial_name;
313 Real xmin, xmax, min_val, max_val, root1, root2;
316 while ( getline( s, line ) ) {
317 tokens = string_split( line,
',');
319 if (tokens.size() != ntokens){
320 stringstream message;
321 message <<
"Polynomial definition line does not have enough fields" << endl;
322 message <<
"Expected " << ntokens <<
" tokens but found " << tokens.size() <<
" tokens. " << endl;
323 message << line << endl;
324 utility_exit_with_message(message.str());
328 { stringstream buf; buf << tokens[i]; i++; buf >> id;}
329 { stringstream buf; buf << tokens[i]; i++; buf >> polynomial_name;}
331 { stringstream buf; buf << tokens[i]; i++; buf >> geo_dim_name;
333 { stringstream buf; buf << tokens[i]; i++; buf >> xmin;}
334 { stringstream buf; buf << tokens[i]; i++; buf >> xmax;}
335 { stringstream buf; buf << tokens[i]; i++; buf >> min_val;}
336 { stringstream buf; buf << tokens[i]; i++; buf >> max_val;}
337 { stringstream buf; buf << tokens[i]; i++; buf >> root1;}
338 { stringstream buf; buf << tokens[i]; i++; buf >> root2;}
339 { stringstream buf; buf << tokens[i]; i++; buf >> degree;}
343 while( i <= tokens.size()){
344 stringstream buf; buf << tokens[i]; i++; buf >>
c;
345 coefficients_.push_back(c);
351 xmin, xmax, min_val, max_val, root1, root2,
356 stringstream message;
357 message <<
"The id fields in the HBPoly1D file '" << HBPoly1D_fname <<
"'" << endl;
358 message <<
"are out of order or missing: Expected id: " <<
HBPoly1D_lookup_.size() + 1 <<
" but instead found id: " <<
id << endl;
359 message <<
"on line: '" << line <<
"'" << endl;
360 utility_exit_with_message(message.str());
380 open(s, HBEval_fname);
385 string AHdist_poly_name, cosBAH_short_poly_name, cosBAH_long_poly_name,
386 cosAHD_short_poly_name, cosAHD_long_poly_name, chi_poly_name,
387 don_chem_type_name, acc_chem_type_name, seq_sep_type_name,
388 AHdist_short_fade_name, AHdist_long_fade_name,
389 cosBAH_fade_name, cosAHD_fade_name;
394 cosAHD_short_poly, cosAHD_long_poly, chi_poly;
395 FadeIntervalCOP AHdist_short_fade, AHdist_long_fade, cosBAH_fade, cosAHD_fade;
396 string weight_type_name;
399 while (getline(s, line)) {
401 tokens = string_split( line,
',');
402 if (tokens.size() != 15){
403 stringstream message;
404 message <<
"HBond evaluation data line does not have enough fields" << endl;
405 message <<
"Expected '" << 15 <<
"' tokens but found '" << tokens.size() <<
"' tokens." << endl;
406 message << line << endl;
407 utility_exit_with_message(message.str());
413 buf << tokens[i]; i++;
414 buf >> don_chem_type_name;
419 buf << tokens[i]; i++;
420 buf >> acc_chem_type_name;
425 buf << tokens[i]; i++;
426 buf >> seq_sep_type_name;
431 if( initialized_hbe_types[hbe_type]){
432 tr <<
"Duplicate parameter specification in HBEval.csv:" << endl;
433 tr <<
" hbe_type: " << hbe_type <<
" line :" << line_number << endl;
435 initialized_hbe_types[hbe_type] =
true;
439 stringstream message;
440 message <<
"hb_eval_type created from" << endl;
441 message <<
"\tdon_chem_type:'"<< don_chem_type_name <<
"'" << endl;
442 message <<
"\tacc_chem_type:'"<< acc_chem_type_name <<
"'" << endl;
443 message <<
"\tseq_sep_type: '"<< seq_sep_type_name <<
"'" << endl;
444 message <<
"gives type" << hbe_type <<
", which is out of the range valid range (0," <<
HB_EVAL_TYPE_COUNT <<
")" << endl;
445 utility_exit_with_message(message.str());
460 buf << tokens[i]; i++;
461 buf >> AHdist_short_fade_name;
471 buf << tokens[i]; i++;
472 buf >> AHdist_long_fade_name;
482 buf << tokens[i]; i++;
483 buf >> cosBAH_fade_name;
493 buf << tokens[i]; i++;
494 buf >> cosAHD_fade_name;
505 buf << tokens[i]; i++;
506 buf >> AHdist_poly_name;
509 if ( AHdist_poly->geometric_dimension() !=
hbgd_AHdist ) {
510 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", expected to read a distance polynomial (i.e. geometric_dimension == hbgd_AHdist), but instead, found " + AHdist_poly_name +
" of geometric dimension " + utility::to_string(AHdist_poly->geometric_dimension()) );
520 buf << tokens[i]; i++;
521 buf >> cosBAH_short_poly_name;
524 if ( cosBAH_short_poly->geometric_dimension() !=
hbgd_cosBAH ) {
525 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", expected to read a short-range cosBAH polynomial (i.e. geometric_dimension == hbgd_cosBAH), but instead, found " + cosBAH_short_poly_name +
" of geometric dimension " + utility::to_string(cosBAH_short_poly->geometric_dimension()) );
535 buf << tokens[i]; i++;
536 buf >> cosBAH_long_poly_name;
539 if ( cosBAH_long_poly->geometric_dimension() !=
hbgd_cosBAH ) {
540 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", expected to read a long-range cosBAH polynomial (i.e. geometric_dimension == hbgd_cosBAH), but instead, found " + cosBAH_long_poly_name +
" of geometric dimension " + utility::to_string(cosBAH_long_poly->geometric_dimension()) );
550 buf << tokens[i]; i++;
551 buf >> cosAHD_short_poly_name;
554 if ( cosAHD_short_poly->geometric_dimension() !=
hbgd_cosAHD && cosAHD_short_poly->geometric_dimension() !=
hbgd_AHD ) {
555 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", expected to read a short-range cosAHD or AHD polynomial (i.e. geometric_dimension == hbgd_cosAHD or hbgd_AHD), but instead, found " + cosAHD_short_poly_name +
" of geometric dimension " + utility::to_string(cosAHD_short_poly->geometric_dimension()) );
565 buf << tokens[i]; i++;
566 buf >> cosAHD_long_poly_name;
569 if ( cosAHD_long_poly->geometric_dimension() !=
hbgd_cosAHD && cosAHD_long_poly->geometric_dimension() !=
hbgd_AHD ) {
570 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", expected to read a long-range cosAHD or AHD polynomial (i.e. geometric_dimension == hbgd_cosAHD or hbgd_AHD), but instead, found " + cosAHD_long_poly_name +
" of geometric dimension " + utility::to_string(cosAHD_long_poly->geometric_dimension()) );
573 if ( cosAHD_long_poly->geometric_dimension() != cosAHD_short_poly->geometric_dimension() ) {
574 utility_exit_with_message(
"When reading HBEval.csv parameters for " + don_chem_type_name +
" and " + acc_chem_type_name +
", found that the short- and long-range polynomials for the AHD angle are of different geometric types: one of hbgd_cosAHD and the other of hbgd_AHD. These types cannot be mixed" );
596 buf << tokens[i]; i++;
597 buf >> weight_type_name;
607 if(!initialized_hbe_types[i]){
608 tr <<
"hbe_type: " << i <<
" is not initialized in HBEval.csv" << endl;
615 string don_strength_fname =
620 open(s, don_strength_fname,
false);
629 Size expected_n_tokens(2);
632 string don_type_name;
635 while(getline(s, line)){
637 tokens = string_split(line,
',');
638 if(tokens.size() != expected_n_tokens){
639 stringstream message;
641 <<
"BondStrength.csv:" << line_number <<
" "
642 <<
"should have " << expected_n_tokens <<
", "
643 <<
"however it has " << tokens.size() << endl;
646 utility_exit_with_message(message.str());
652 buf << tokens[i]; i++;
653 buf >> don_type_name;
657 buf << tokens[i]; i++;
658 buf >> site_strength;
668 string acc_strength_fname =
672 open(s, acc_strength_fname,
false);
680 Size expected_n_tokens(2);
683 string acc_type_name;
686 while(getline(s, line)){
688 tokens = string_split(line,
',');
689 if(tokens.size() != expected_n_tokens){
690 stringstream message;
692 <<
"BondStrength.csv:" << line_number <<
" "
693 <<
"should have " << expected_n_tokens <<
", "
694 <<
"however it has " << tokens.size() << endl;
697 utility_exit_with_message(message.str());
703 buf << tokens[i]; i++;
704 buf >> acc_type_name;
708 buf << tokens[i]; i++;
709 buf >> site_strength;
723 stringstream message;
724 message <<
"Fade Interval '" << name <<
"' has not been defined.";
725 utility_exit_with_message(message.str());
741 stringstream message;
742 message <<
"HBond eval type '" << hb_eval_type <<
743 "' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
744 utility_exit_with_message(message.str());
750 stringstream message;
751 message <<
"No short fade interval for AHdist has been defined for hb eval type '"
752 << hb_eval_type <<
"'" <<endl;
753 utility_exit_with_message(message.str());
765 stringstream message;
766 message <<
"HBond eval type '" << hb_eval_type
767 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
768 utility_exit_with_message(message.str());
773 stringstream message;
774 message <<
"No long fade interval for AHdist has been defined for hb eval type '"
775 << hb_eval_type <<
"'" <<endl;
776 utility_exit_with_message(message.str());
788 stringstream message;
789 message <<
"HBond eval type '" << hb_eval_type
790 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
791 utility_exit_with_message(message.str());
796 stringstream message;
797 message <<
"No fade interval for cosBAH has been defined for hb eval type '"
798 << hb_eval_type <<
"'" <<endl;
799 utility_exit_with_message(message.str());
811 stringstream message;
812 message <<
"HBond eval type '" << hb_eval_type
813 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
814 utility_exit_with_message(message.str());
819 stringstream message;
820 message <<
"No fade interval for cosAHD has been defined for hb eval type '"
821 << hb_eval_type <<
"'" <<endl;
822 utility_exit_with_message(message.str());
833 stringstream message;
834 message <<
"1d Polynomial '" << name <<
"' has not been defined.";
835 utility_exit_with_message(message.str());
849 stringstream message;
850 message <<
"HBond eval type '" << hb_eval_type
851 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
852 utility_exit_with_message(message.str());
857 stringstream message;
858 message <<
"No AHdist polynomial has been defined for hb eval type '"
859 << hb_eval_type <<
"'" <<endl;
860 utility_exit_with_message(message.str());
872 stringstream message;
873 message <<
"HBond eval type '" << hb_eval_type
874 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
875 utility_exit_with_message(message.str());
880 stringstream message;
881 message <<
"No cosBAH_short polynomial has been defined for hb eval type '"
882 << hb_eval_type <<
"'" << endl;
883 utility_exit_with_message(message.str());
896 stringstream message;
897 message <<
"HBond eval type '" << hb_eval_type
898 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
899 utility_exit_with_message(message.str());
904 stringstream message;
905 message <<
"No cosBAH_long polynomial has been defined for hb eval type '"
906 << hb_eval_type <<
"'" << endl;
907 utility_exit_with_message(message.str());
919 stringstream message;
920 message <<
"HBond eval type '" << hb_eval_type
921 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
922 utility_exit_with_message(message.str());
927 stringstream message;
928 message <<
"No cosAHD_short polynomial has been defined for hb eval type '"
929 << hb_eval_type <<
"'" << endl;
930 utility_exit_with_message(message.str());
942 stringstream message;
943 message <<
"HBond eval type '" << hb_eval_type
944 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
945 utility_exit_with_message(message.str());
950 stringstream message;
951 message <<
"No cosAHD_long polynomial has been defined for hb eval type '"
952 << hb_eval_type <<
"'" << endl;
953 utility_exit_with_message(message.str());
964 stringstream message;
965 message <<
"HBond eval type '" << hb_eval_type
966 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
967 utility_exit_with_message(message.str());
972 stringstream message;
973 message <<
"No chi polynomial has been defined for hb eval type '"
974 << hb_eval_type <<
"'" << endl;
975 utility_exit_with_message(message.str());
985 assert(don_chem_type >= 1 && don_chem_type <=
hbdon_MAX );
994 assert(acc_chem_type >= 1 && acc_chem_type <=
hbacc_MAX );
1006 stringstream message;
1007 message <<
"HBond eval type '" << hb_eval_type
1008 <<
"' is out side of the valid range (1," << HB_EVAL_TYPE_COUNT <<
")";
1009 utility_exit_with_message(message.str());
1014 stringstream message;
1015 message <<
"No weight type has been defined for hb eval type '"
1016 << hb_eval_type <<
"'" << endl;
1017 utility_exit_with_message(message.str());
1024 sessionOP db_session
1033 sessionOP db_session
1035 using namespace basic::database::schema_generator;
1037 Column database_tag(
"database_tag",
new DbText());
1038 Column name(
"name",
new DbText());
1039 Column junction_type(
"junction_type",
new DbText());
1040 Column min0(
"min0",
new DbReal());
1041 Column fmin(
"fmin",
new DbReal());
1042 Column fmax(
"fmax",
new DbReal());
1043 Column max0(
"max0",
new DbReal());
1046 Columns primary_key_columns;
1047 primary_key_columns.push_back(database_tag);
1048 primary_key_columns.push_back(name);
1049 PrimaryKey primary_key(primary_key_columns);
1051 Schema table(
"hbond_fade_interval", primary_key);
1052 table.add_column(junction_type);
1053 table.add_column(min0);
1054 table.add_column(fmin);
1055 table.add_column(fmax);
1056 table.add_column(max0);
1058 table.write(db_session);
1063 sessionOP db_session
1065 using namespace basic::database::schema_generator;
1067 Column database_tag(
"database_tag",
new DbText());
1068 Column name(
"name",
new DbText());
1069 Column dimension(
"dimension",
new DbText());
1070 Column xmin(
"xmin",
new DbReal());
1071 Column xmax(
"xmax",
new DbReal());
1072 Column min_val(
"min_val",
new DbReal());
1073 Column max_val(
"max_val",
new DbReal());
1074 Column root1(
"root1",
new DbReal());
1075 Column root2(
"root2",
new DbReal());
1076 Column degree(
"degree",
new DbInteger());
1077 Column c_a(
"c_a",
new DbReal());
1078 Column c_b(
"c_b",
new DbReal());
1079 Column c_c(
"c_c",
new DbReal());
1080 Column c_d(
"c_d",
new DbReal());
1081 Column c_e(
"c_e",
new DbReal());
1082 Column c_f(
"c_f",
new DbReal());
1083 Column c_g(
"c_g",
new DbReal());
1084 Column c_h(
"c_h",
new DbReal());
1085 Column c_i(
"c_i",
new DbReal());
1086 Column c_j(
"c_j",
new DbReal());
1087 Column c_k(
"c_k",
new DbReal());
1090 Columns primary_key_columns;
1091 primary_key_columns.push_back(database_tag);
1092 primary_key_columns.push_back(name);
1093 PrimaryKey primary_key(primary_key_columns);
1095 Schema table(
"hbond_polynomial_1d", primary_key);
1096 table.add_column(dimension);
1097 table.add_column(xmin);
1098 table.add_column(xmax);
1099 table.add_column(min_val);
1100 table.add_column(max_val);
1101 table.add_column(root1);
1102 table.add_column(root2);
1103 table.add_column(degree);
1104 table.add_column(c_a);
1105 table.add_column(c_b);
1106 table.add_column(c_c);
1107 table.add_column(c_d);
1108 table.add_column(c_e);
1109 table.add_column(c_f);
1110 table.add_column(c_g);
1111 table.add_column(c_h);
1112 table.add_column(c_i);
1113 table.add_column(c_j);
1114 table.add_column(c_k);
1115 table.write(db_session);
1121 sessionOP db_session
1123 using namespace basic::database::schema_generator;
1125 Column database_tag(
"database_tag",
new DbText());
1126 Column don_chem_type(
"don_chem_type",
new DbText());
1127 Column acc_chem_type(
"acc_chem_type",
new DbText());
1128 Column separation(
"separation",
new DbText());
1129 Column AHdist_short_fade(
"AHdist_short_fade",
new DbText());
1130 Column AHdist_long_fade(
"AHdist_long_fade",
new DbText());
1131 Column cosBAH_fade(
"cosBAH_fade",
new DbText());
1132 Column cosAHD_fade(
"cosAHD_fade",
new DbText());
1133 Column AHdist(
"AHdist",
new DbText());
1134 Column cosBAH_short(
"cosBAH_short",
new DbText());
1135 Column cosBAH_long(
"cosBAH_long",
new DbText());
1136 Column cosAHD_short(
"cosAHD_short",
new DbText());
1137 Column cosAHD_long(
"cosAHD_long",
new DbText());
1138 Column weight_type(
"weight_type",
new DbText());
1140 Columns primary_key_columns;
1141 primary_key_columns.push_back(database_tag);
1142 primary_key_columns.push_back(don_chem_type);
1143 primary_key_columns.push_back(acc_chem_type);
1144 primary_key_columns.push_back(separation);
1145 PrimaryKey primary_key(primary_key_columns);
1147 Columns foreign_key_columns_AHdist_short_fade;
1148 foreign_key_columns_AHdist_short_fade.push_back(database_tag);
1149 foreign_key_columns_AHdist_short_fade.push_back(AHdist_short_fade);
1151 reference_columns_AHdist_short_fade.push_back(
"database_tag");
1152 reference_columns_AHdist_short_fade.push_back(
"name");
1153 ForeignKey foreign_key_AHdist_short_fade(
1154 foreign_key_columns_AHdist_short_fade,
1155 "hbond_fade_interval",
1156 reference_columns_AHdist_short_fade,
1159 Columns foreign_key_columns_AHdist_long_fade;
1160 foreign_key_columns_AHdist_long_fade.push_back(database_tag);
1161 foreign_key_columns_AHdist_long_fade.push_back(AHdist_long_fade);
1163 reference_columns_AHdist_long_fade.push_back(
"database_tag");
1164 reference_columns_AHdist_long_fade.push_back(
"name");
1165 ForeignKey foreign_key_AHdist_long_fade(
1166 foreign_key_columns_AHdist_long_fade,
1167 "hbond_fade_interval",
1168 reference_columns_AHdist_long_fade,
1171 Columns foreign_key_columns_cosBAH_fade;
1172 foreign_key_columns_cosBAH_fade.push_back(database_tag);
1173 foreign_key_columns_cosBAH_fade.push_back(cosBAH_fade);
1175 reference_columns_cosBAH_fade.push_back(
"database_tag");
1176 reference_columns_cosBAH_fade.push_back(
"name");
1177 ForeignKey foreign_key_cosBAH_fade(
1178 foreign_key_columns_cosBAH_fade,
1179 "hbond_fade_interval",
1180 reference_columns_cosBAH_fade,
1183 Columns foreign_key_columns_cosAHD_fade;
1184 foreign_key_columns_cosAHD_fade.push_back(database_tag);
1185 foreign_key_columns_cosAHD_fade.push_back(cosAHD_fade);
1187 reference_columns_cosAHD_fade.push_back(
"database_tag");
1188 reference_columns_cosAHD_fade.push_back(
"name");
1189 ForeignKey foreign_key_cosAHD_fade(
1190 foreign_key_columns_cosAHD_fade,
1191 "hbond_fade_interval",
1192 reference_columns_cosAHD_fade,
1195 Columns foreign_key_columns_AHdist;
1196 foreign_key_columns_AHdist.push_back(database_tag);
1197 foreign_key_columns_AHdist.push_back(AHdist);
1199 reference_columns_AHdist.push_back(
"database_tag");
1200 reference_columns_AHdist.push_back(
"name");
1201 ForeignKey foreign_key_AHdist(
1202 foreign_key_columns_AHdist,
1203 "hbond_polynomial_1d",
1204 reference_columns_AHdist,
1207 Columns foreign_key_columns_cosBAH_short;
1208 foreign_key_columns_cosBAH_short.push_back(database_tag);
1209 foreign_key_columns_cosBAH_short.push_back(cosBAH_short);
1211 reference_columns_cosBAH_short.push_back(
"database_tag");
1212 reference_columns_cosBAH_short.push_back(
"name");
1213 ForeignKey foreign_key_cosBAH_short(
1214 foreign_key_columns_cosBAH_short,
1215 "hbond_polynomial_1d",
1216 reference_columns_cosBAH_short,
1219 Columns foreign_key_columns_cosBAH_long;
1220 foreign_key_columns_cosBAH_long.push_back(database_tag);
1221 foreign_key_columns_cosBAH_long.push_back(cosBAH_long);
1223 reference_columns_cosBAH_long.push_back(
"database_tag");
1224 reference_columns_cosBAH_long.push_back(
"name");
1225 ForeignKey foreign_key_cosBAH_long(
1226 foreign_key_columns_cosBAH_long,
1227 "hbond_polynomial_1d",
1228 reference_columns_cosBAH_long,
1231 Columns foreign_key_columns_cosAHD_short;
1232 foreign_key_columns_cosAHD_short.push_back(database_tag);
1233 foreign_key_columns_cosAHD_short.push_back(cosAHD_short);
1235 reference_columns_cosAHD_short.push_back(
"database_tag");
1236 reference_columns_cosAHD_short.push_back(
"name");
1237 ForeignKey foreign_key_cosAHD_short(
1238 foreign_key_columns_cosAHD_short,
1239 "hbond_polynomial_1d",
1240 reference_columns_cosAHD_short,
1243 Columns foreign_key_columns_cosAHD_long;
1244 foreign_key_columns_cosAHD_long.push_back(database_tag);
1245 foreign_key_columns_cosAHD_long.push_back(cosAHD_long);
1247 reference_columns_cosAHD_long.push_back(
"database_tag");
1248 reference_columns_cosAHD_long.push_back(
"name");
1249 ForeignKey foreign_key_cosAHD_long(
1250 foreign_key_columns_cosAHD_long,
1251 "hbond_polynomial_1d",
1252 reference_columns_cosAHD_long,
1255 Schema table(
"hbond_evaluation_types", primary_key);
1256 table.add_foreign_key(foreign_key_AHdist_short_fade);
1257 table.add_foreign_key(foreign_key_AHdist_long_fade);
1258 table.add_foreign_key(foreign_key_cosBAH_fade);
1259 table.add_foreign_key(foreign_key_cosAHD_fade);
1260 table.add_foreign_key(foreign_key_AHdist);
1261 table.add_foreign_key(foreign_key_cosBAH_short);
1262 table.add_foreign_key(foreign_key_cosBAH_long);
1263 table.add_foreign_key(foreign_key_cosAHD_short);
1264 table.add_foreign_key(foreign_key_cosAHD_long);
1265 table.add_column(AHdist_short_fade);
1266 table.add_column(AHdist_long_fade);
1267 table.add_column(cosBAH_fade);
1268 table.add_column(cosAHD_fade);
1269 table.add_column(AHdist);
1270 table.add_column(cosBAH_short);
1271 table.add_column(cosBAH_long);
1272 table.add_column(cosAHD_short);
1273 table.add_column(cosAHD_long);
1274 table.add_column(weight_type);
1276 table.write(db_session);
1281 sessionOP db_session
1286 std::string select_string =
"SELECT * FROM hbond_evaluation_types WHERE database_tag = ?;";
1287 statement select_statement(basic::database::safely_prepare_statement(select_string,db_session));
1288 select_statement.bind(1,database_tag);
1289 result res(basic::database::safely_read_from_database(select_statement));
1290 if(res.next())
return 0;
1293 pair<string, FadeIntervalCOP> fade_name_interval;
1294 std::string hbond_interval_string =
"INSERT INTO hbond_fade_interval (database_tag, name, junction_type, min0, fmin, fmax, max0) VALUES (?,?,?,?,?,?,?);";
1295 statement hbond_interval_statement(basic::database::safely_prepare_statement(hbond_interval_string,db_session));
1297 hbond_interval_statement.bind(1,database_tag);
1298 hbond_interval_statement.bind(2,fade_name_interval.first);
1299 hbond_interval_statement.bind(3,(fade_name_interval.second->get_smooth() ?
"smooth" :
"piecewise_linear"));
1300 hbond_interval_statement.bind(4,fade_name_interval.second->get_min0());
1301 hbond_interval_statement.bind(5,fade_name_interval.second->get_fmin());
1302 hbond_interval_statement.bind(6,fade_name_interval.second->get_fmax());
1303 hbond_interval_statement.bind(7,fade_name_interval.second->get_max0());
1304 basic::database::safely_write_to_database(hbond_interval_statement);
1308 pair<string, Polynomial_1dCOP> poly_name_fn;
1309 std::string hbond_polynomial_string =
"INSERT INTO hbond_polynomial_1d (database_tag, name, dimension, xmin, xmax, min_val, max_val, root1, root2, degree, c_a, c_b, c_c, c_d, c_e, c_f, c_g, c_h, c_i, c_j, c_k) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
1310 statement hbond_polynomial_statement(basic::database::safely_prepare_statement(hbond_polynomial_string,db_session));
1312 hbond_polynomial_statement.bind(1,database_tag);
1313 hbond_polynomial_statement.bind(2,poly_name_fn.first);
1315 hbond_polynomial_statement.bind(4,poly_name_fn.second->xmin());
1316 hbond_polynomial_statement.bind(5,poly_name_fn.second->xmax());
1317 hbond_polynomial_statement.bind(6,poly_name_fn.second->min_val());
1318 hbond_polynomial_statement.bind(7,poly_name_fn.second->max_val());
1319 hbond_polynomial_statement.bind(8,poly_name_fn.second->root1());
1320 hbond_polynomial_statement.bind(9,poly_name_fn.second->root2());
1321 hbond_polynomial_statement.bind(10,poly_name_fn.second->degree());
1323 for(
Size i = 1; i <= poly_name_fn.second->degree(); ++i){
1325 hbond_polynomial_statement.bind(index,poly_name_fn.second->coefficients()[i]);
1327 for(
Size i = 1; i <= 11-poly_name_fn.second->degree(); ++i){
1329 hbond_polynomial_statement.bind_null(index);
1331 basic::database::safely_write_to_database(hbond_polynomial_statement);
1334 std::string hbond_evaluation_string =
"INSERT INTO hbond_evaluation_types (database_tag, don_chem_type, acc_chem_type, separation, AHdist_short_fade, AHdist_long_fade, cosBAH_fade, cosAHD_fade, AHdist, cosBAH_short, cosBAH_long, cosAHD_short, cosAHD_long, weight_type) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
1335 statement hbond_evaluation_statement(basic::database::safely_prepare_statement(hbond_evaluation_string,db_session));
1346 hbond_evaluation_statement.bind(1,database_tag);
1347 hbond_evaluation_statement.bind(2,don_chem_type);
1348 hbond_evaluation_statement.bind(3,acc_chem_type);
1349 hbond_evaluation_statement.bind(4,separation);
1360 basic::database::safely_write_to_database(hbond_evaluation_statement);