Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnergyMethodOptions.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/scoring/ScoreFunction.hh
11 /// @brief Score function class
12 /// @author Phil Bradley
13 /// @author Christopher Miles (cmiles@uw.edu)
14 
15 // Unit headers
16 #include <core/types.hh>
20 
23 
24 // Utility headers
25 #include <basic/options/option.hh>
26 #include <basic/options/keys/dna.OptionKeys.gen.hh>
27 #include <basic/options/keys/score.OptionKeys.gen.hh>
28 #include <basic/database/sql_utils.hh>
29 #include <basic/database/schema_generator/PrimaryKey.hh>
30 #include <basic/database/schema_generator/Column.hh>
31 #include <basic/database/schema_generator/Schema.hh>
32 #include <utility/exit.hh>
33 #include <utility/vector1.hh>
34 
35 #include <cppdb/frontend.h>
36 
37 #include <boost/lexical_cast.hpp>
38 
39 using std::string;
40 using utility::vector1;
41 
42 namespace core {
43 namespace scoring {
44 namespace methods {
45 
47  // hard-wired default, but you can set this with etable_type( string )
48  etable_type_(FA_STANDARD_DEFAULT),
49  analytic_etable_evaluation_( false ),
50  atom_vdw_atom_type_set_name_(chemical::CENTROID), // can be set, see below
51  unfolded_energies_type_( UNFOLDED_SCORE12 ),
52  exclude_protein_protein_hack_elec_(false), // rosetta++ defaulted to true!
53  exclude_monomer_hack_elec_(false),
54  hackelec_max_dis_(5.5),
55  hackelec_min_dis_(1.5),
56  hackelec_die_(10.0),
57  hackelec_no_dis_dep_die_(false),
58  smooth_hack_elec_( false ),
59  exclude_DNA_DNA_(true), // rosetta++ default
60  hbond_options_(new hbonds::HBondOptions()),
61  cst_max_seq_sep_(core::SZ_MAX),
62  cartbonded_len_(-1.0),
63  cartbonded_ang_(-1.0),
64  cartbonded_tors_(-1.0),
65  cartbonded_proton_(-1.0),
66  cartbonded_improper_(-1.0),
67  cartbonded_linear_(false),
68  pb_bound_tag_("bound"),
69  pb_unbound_tag_("unbound"),
70  bond_angle_residue_type_param_set_(NULL)
71 {
73 }
74 
76  analytic_etable_evaluation_ = basic::options::option[ basic::options::OptionKeys::score::analytic_etable_evaluation ];
77  hackelec_max_dis_ = basic::options::option[basic::options::OptionKeys::score::hackelec_max_dis ]();
78  hackelec_min_dis_ = basic::options::option[basic::options::OptionKeys::score::hackelec_min_dis ]();
79  hackelec_die_ = basic::options::option[ basic::options::OptionKeys::score::hackelec_die ]();
80  hackelec_no_dis_dep_die_ = basic::options::option[ basic::options::OptionKeys::score::hackelec_r_option ]();
81  smooth_hack_elec_ = basic::options::option[ basic::options::OptionKeys::score::smooth_hack_elec ]();
82  exclude_DNA_DNA_ = basic::options::option[basic::options::OptionKeys::dna::specificity::exclude_dna_dna]; // adding because this parameter should absolutely be false for any structure with DNA in it and it doesn't seem to be read in via the weights file method, so now it's an option - sthyme
83 }
84 
85 /// copy constructor
87  : ReferenceCount( src )
88 {
89  *this = src;
90 }
91 
93 
94 /// copy operator
95 EnergyMethodOptions const &
97  if ( this != &src ) {
103  ss_weights_ = src.ss_weights_;
123  }
124  return *this;
125 }
126 
127 string const &
129  return etable_type_;
130 }
131 
132 void
133 EnergyMethodOptions::etable_type(string const & type ) {
134  etable_type_ = type;
135 }
136 
137 string const &
140 }
141 
142 void
145 }
146 
147 bool
150 }
151 
152 void
155 }
156 
157 bool
160 }
161 
162 void
164  exclude_monomer_hack_elec_ = setting;
165 }
166 
169  return hackelec_max_dis_;
170 }
171 
172 void
174  hackelec_max_dis_ = setting;
175 }
176 
179  return hackelec_min_dis_;
180 }
181 
182 void
184  hackelec_min_dis_ = setting;
185 }
186 
189  return hackelec_die_;
190 }
191 
192 void
194  hackelec_die_ = setting;
195 }
196 
197 bool
200 }
201 
202 void
204  hackelec_no_dis_dep_die_ = setting;
205 }
206 
207 bool
209  return smooth_hack_elec_;
210 }
211 
212 void
214 {
215  smooth_hack_elec_ = setting;
216 }
217 
218 
219 bool
221  runtime_assert( hbond_options_->exclude_DNA_DNA() == exclude_DNA_DNA_ );
222  return exclude_DNA_DNA_;
223 }
224 
225 void
227  exclude_DNA_DNA_ = setting;
228  hbond_options_->exclude_DNA_DNA( setting );
229 }
230 
231 hbonds::HBondOptions const &
233  return *hbond_options_;
234 }
235 
238  return *hbond_options_;
239 }
240 
241 void
243  hbond_options_ = new hbonds::HBondOptions( opts );
244 }
245 
246 std::string const &
248  return pb_bound_tag_;
249 }
250 std::string &
252  return pb_bound_tag_;
253 }
254 void
256  pb_bound_tag_ = tag;
257 }
258 std::string const &
260  return pb_unbound_tag_;
261 }
262 std::string &
264  return pb_unbound_tag_;
265 }
266 void
268  pb_unbound_tag_ = tag;
269 }
270 
271 /// @brief This is used in the construction of the VDW_Energy's AtomVDW object
272 string const &
275 }
276 
277 void
280 }
281 
282 void
284  int ss_lowstrand,
285  int ss_cutoff
286 ) {
287  ss_weights_.set_ss_cutoff(ss_cutoff);
288  ss_weights_.set_ss_lowstrand(ss_lowstrand);
289 }
290 
293  return ss_weights_;
294 }
295 
298  return ss_weights_;
299 }
300 
301 bool
303  return ( method_weights_.find( type ) != method_weights_.end() );
304 }
305 
306 vector1< Real > const &
308  MethodWeights::const_iterator it( method_weights_.find( type ) );
309  if ( it == method_weights_.end() ) {
310  utility_exit_with_message( "EnergyMethodOptions::method_weights do not exist: " +
311  name_from_score_type(type));
312  }
313  return it->second;
314 }
315 
316 void
318  ScoreType const & type,
319  vector1< Real > const & wts)
320 {
321  method_weights_[ type ] = wts;
322 }
323 
326  return cst_max_seq_sep_;
327 }
328 
329 void
331  cst_max_seq_sep_ = setting;
332 }
333 
334 /// deprecated
335 vector1<string> const &
338  return bond_angle_residue_type_param_set_->central_atoms_to_score();
339  }
341 }
342 
343 /// deprecated
344 void
348  bond_angle_residue_type_param_set_->central_atoms_to_score(atom_names);
349  }
350 }
351 
355 }
356 
360 }
361 
362 void
365 }
366 
367 /// used inside ScoreFunctionInfo::operator==
368 bool
370 
371  return ( ( a.etable_type_ == b.etable_type_ ) &&
375  ( a.method_weights_ == b.method_weights_ ) &&
376  ( a.ss_weights_ == b.ss_weights_ ) &&
381  ( a.hackelec_die_ == b.hackelec_die_ ) &&
384  ( a.exclude_DNA_DNA_ == b.exclude_DNA_DNA_ ) &&
385  ( * (a.hbond_options_) == * (b.hbond_options_) ) &&
386  ( a.cst_max_seq_sep_ == b.cst_max_seq_sep_ ) &&
387  ( a.cartbonded_len_ == b.cartbonded_len_ ) &&
388  ( a.cartbonded_ang_ == b.cartbonded_ang_ ) &&
389  ( a.cartbonded_tors_ == b.cartbonded_tors_ ) &&
394  ( a.pb_bound_tag_ == b.pb_bound_tag_ ) &&
395  ( a.pb_unbound_tag_ == b.pb_unbound_tag_ ) )
396  ;
397 }
398 
399 /// used inside ScoreFunctionInfo::operator==
400 bool
402  return !( a == b );
403 }
404 
405 void
406 EnergyMethodOptions::show( std::ostream & out ) const {
407  if ( etable_type_.size() ) out << "EnergyMethodOptions::show: etable_type: " << etable_type_ <<'\n';
408  out << "analytic_etable_evaluation: " << analytic_etable_evaluation_ << '\n';
409  for ( MethodWeights::const_iterator it=method_weights_.begin(), ite = method_weights_.end(); it != ite; ++it ) {
410  out << "EnergyMethodOptions::show: method_weights: " << it->first;
411  for ( Size i=1; i<= it->second.size(); ++i ) {
412  out << ' ' << it->second[i];
413  }
414  out << '\n';
415  }
416  out << "EnergyMethodOptions::show: unfolded_energies_type: " << unfolded_energies_type_ << std::endl;
417  out << "EnergyMethodOptions::show: atom_vdw_atom_type_set_name: " << atom_vdw_atom_type_set_name_ << std::endl;
418  out << "EnergyMethodOptions::show: exclude_protein_protein_hack_elec: "
419  << (exclude_protein_protein_hack_elec_ ? "true" : "false") << std::endl;
420  out << "EnergyMethodOptions::show: exclude_monomer_hack_elec: "
421  << (exclude_monomer_hack_elec_ ? "true" : "false") << std::endl;
422  out << "EnergyMethodOptions::show: hackelec_max_dis: " << hackelec_max_dis_ << std::endl;
423  out << "EnergyMethodOptions::show: hackelec_min_dis: " << hackelec_min_dis_ << std::endl;
424  out << "EnergyMethodOptions::show: hackelec_die: " << hackelec_die_ << std::endl;
425  out << "EnergyMethodOptions::show: hackelec_no_dis_dep_die: "
426  << (hackelec_no_dis_dep_die_ ? "true" : "false") << std::endl;
427  out << "EnergyMethodOptions::show: smooth_hack_elec: " << ( smooth_hack_elec_ ? "true" : "false" ) << std::endl;
428  out << "EnergyMethodOptions::show: exclude_DNA_DNA: "
429  << (exclude_DNA_DNA_ ? "true" : "false") << std::endl;
430  out << "EnergyMethodOptions::show: cst_max_seq_sep: " << cst_max_seq_sep_ << std::endl;
431  out << "EnergyMethodOptions::show: pb_bound_tag: " << pb_bound_tag_ << std::endl;
432  out << "EnergyMethodOptions::show: pb_unbound_tag: " << pb_unbound_tag_ << std::endl;
433  out << "EnergyMethodOptions::show: bond_angle_central_atoms_to_score:";
435  out << "setting ignored";
436  } else {
437  for ( Size i=1; i <= bond_angle_central_atoms_to_score_.size(); ++i ) {
438  out << " \"" << bond_angle_central_atoms_to_score_[i] << "\"";
439  }
440  }
441  out << std::endl;
442  out << "EnergyMethodOptions::show: bond_angle_residue_type_param_set: "
443  << (bond_angle_residue_type_param_set_ ? "in use" : "none") << std::endl;
445  out << " central_atoms_to_score:";
446  if (!bond_angle_residue_type_param_set_->central_atoms_to_score().size()) out << "all";
447  for ( Size i=1; i <= bond_angle_residue_type_param_set_->central_atoms_to_score().size(); ++i ) {
448  out << " \"" << bond_angle_residue_type_param_set_->central_atoms_to_score()[i] << "\"";
449  }
450  out << std::endl;
451  out << " use_residue_type_theta0: "
452  << (bond_angle_residue_type_param_set_->use_residue_type_theta0() ? "true" : "false") << std::endl;
453  }
454  out << *hbond_options_;
455 }
456 
457 std::ostream& operator<<(std::ostream & out, EnergyMethodOptions const & options) {
458  options.show( out );
459  return out;
460 }
461 
462 void
464  utility::sql_database::sessionOP db_session
465 ) {
466  using namespace basic::database::schema_generator;
467 
468  Column batch_id("batch_id", new DbInteger(), true);
469  Column score_function_name("score_function_name", new DbText(), true);
470  Column option_key("option_key", new DbText(), true);
471  Column option_value("option_value", new DbText(), true);
472 
473  utility::vector1<Column> pkey_cols;
474  pkey_cols.push_back(batch_id);
475  pkey_cols.push_back(score_function_name);
476  pkey_cols.push_back(option_key);
477 
478  Columns foreign_key_columns;
479  foreign_key_columns.push_back(batch_id);
480  vector1< string > reference_columns;
481  reference_columns.push_back("batch_id");
482  ForeignKey foreign_key(foreign_key_columns, "batches", reference_columns, true);
483 
484 
485  Schema table("score_function_method_options", PrimaryKey(pkey_cols));
486  table.add_foreign_key(foreign_key);
487  table.add_column(option_value);
488 
489  table.write(db_session);
490 
491 }
492 
493 
494 void
496  Size batch_id,
497  std::string const & score_function_name,
498  utility::sql_database::sessionOP db_session
499 ) const {
500 
501  vector1< std::string > option_keys;
502  vector1< std::string > option_values;
503  if(etable_type_.size()){
504  option_keys.push_back("etable_type");
505  option_values.push_back(etable_type_);
506  }
507  option_keys.push_back("analytic_etable_evaluation");
508  option_values.push_back(analytic_etable_evaluation_ ? "1" : "0");
509 
510  option_keys.push_back("atom_vdw_atom_type_set_name");
511  option_values.push_back(atom_vdw_atom_type_set_name_);
512 
513  option_keys.push_back("unfolded_energies_type");
514  option_values.push_back(unfolded_energies_type_);
515 
516  option_keys.push_back("exclude_protein_protein_hack_elec");
517  option_values.push_back(exclude_protein_protein_hack_elec_ ? "1" : "0");
518 
519  option_keys.push_back("exclude_monomer_hack_elec");
520  option_values.push_back(exclude_monomer_hack_elec_ ? "1" : "0");
521 
522  option_keys.push_back("hackelec_max_dis");
523  option_values.push_back(boost::lexical_cast<std::string>(hackelec_max_dis_));
524 
525  option_keys.push_back("hackelec_min_dis");
526  option_values.push_back(boost::lexical_cast<std::string>(hackelec_min_dis_));
527 
528  option_keys.push_back("hackelec_die");
529  option_values.push_back(boost::lexical_cast<std::string>(hackelec_die_));
530 
531  option_keys.push_back("hackelec_no_dis_dep_die");
532  option_values.push_back(hackelec_no_dis_dep_die_ ? "1" : "0");
533 
534  option_keys.push_back("exclude_DNA_DNA");
535  option_values.push_back(exclude_DNA_DNA_ ? "1" : "0");
536 
537  option_keys.push_back("cst_max_seq_sep");
538  option_values.push_back(boost::lexical_cast<std::string>(cst_max_seq_sep_));
539 
540  option_keys.push_back("cartbonded_len");
541  option_values.push_back(boost::lexical_cast<std::string>(cartbonded_len_));
542 
543  option_keys.push_back("cartbonded_ang");
544  option_values.push_back(boost::lexical_cast<std::string>(cartbonded_ang_));
545 
546  option_keys.push_back("cartbonded_tors");
547  option_values.push_back(boost::lexical_cast<std::string>(cartbonded_tors_));
548 
549  option_keys.push_back("cartbonded_proton");
550  option_values.push_back(boost::lexical_cast<std::string>(cartbonded_proton_));
551 
552  option_keys.push_back("cartbonded_linear");
553  option_values.push_back(cartbonded_linear_ ? "1" : "0");
554 
555  string statement_string;
556  switch(db_session->get_db_mode()){
557  case utility::sql_database::DatabaseMode::sqlite3:
558  statement_string = "INSERT OR IGNORE INTO score_function_method_options (batch_id, score_function_name, option_key, option_value) VALUES (?,?,?,?);";
559  break;
560  case utility::sql_database::DatabaseMode::mysql:
561  case utility::sql_database::DatabaseMode::postgres:
562  statement_string = "INSERT IGNORE INTO score_function_weights (batch_id, score_function_name, option_key, option_value) VALUES (?,?,?,?);";
563  break;
564  default:
565  utility_exit_with_message(
566  "Unrecognized database mode: '" +
567  name_from_database_mode(db_session->get_db_mode()) + "'");
568  }
569 
570  cppdb::statement stmt(
571  basic::database::safely_prepare_statement(statement_string, db_session));
572 
573  for(Size i=1; i <= option_keys.size(); ++i){
574  stmt.bind(1, batch_id);
575  stmt.bind(2, score_function_name);
576  stmt.bind(3, option_keys[i]);
577  stmt.bind(4, option_values[i]);
578  basic::database::safely_write_to_database(stmt);
579  }
580 }
581 
582 
583 
584 }
585 }
586 }