Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RotamerBoltzmannWeightFeatures.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 protocols/features/RotamerBoltzmannWeightFeatures.cc
11 /// @brief report residue burial to features statistics scientific benchmark
12 /// @author Matthew O'Meara
13 
14 // Unit Headers
16 
17 // Project Headers
18 #include <core/pose/Pose.hh>
20 #include <core/types.hh>
23 #include <utility/sql_database/DatabaseSessionManager.hh>
24 #include <utility/vector1.hh>
25 #include <utility/tag/Tag.hh>
26 #include <basic/database/sql_utils.hh>
27 
28 #include <basic/database/schema_generator/PrimaryKey.hh>
29 #include <basic/database/schema_generator/ForeignKey.hh>
30 #include <basic/database/schema_generator/Column.hh>
31 #include <basic/database/schema_generator/Schema.hh>
32 
33 
34 
35 // External Headers
36 #include <cppdb/frontend.h>
37 #include <boost/uuid/uuid_io.hpp>
38 
39 // C++ Headers
40 #include <sstream>
41 
42 #include <utility/excn/Exceptions.hh>
43 #include <utility/vector0.hh>
44 
45 
46 namespace protocols{
47 namespace features{
48 
49 using std::string;
50 using std::endl;
51 using std::stringstream;
52 using core::Size;
53 using core::Real;
54 using core::pose::Pose;
62 using utility::sql_database::sessionOP;
63 using utility::vector1;
65 using cppdb::statement;
66 
68  rotamer_boltzmann_weight_(new RotamerBoltzmannWeight())
69 {}
70 
72  ScoreFunctionOP scfxn) :
73  rotamer_boltzmann_weight_(new RotamerBoltzmannWeight())
74 {
75  rotamer_boltzmann_weight_->scorefxn(scfxn);
76  rotamer_boltzmann_weight_->type("monomer");
77 }
78 
81  rotamer_boltzmann_weight_(src.rotamer_boltzmann_weight_)
82 {}
83 
85 
86 string
87 RotamerBoltzmannWeightFeatures::type_name() const { return "RotamerBoltzmannWeightFeatures"; }
88 
89 void
91  sessionOP db_session
92 ) const {
94 }
95 
96 void
98  sessionOP db_session
99 ) const {
100  using namespace basic::database::schema_generator;
101 
102  Column struct_id("struct_id", new DbUUID());
103  Column resNum("resNum", new DbInteger());
104  Column boltzmann_weight("boltzmann_weight", new DbReal());
105 
106  Columns primary_key_columns;
107  primary_key_columns.push_back(struct_id);
108  primary_key_columns.push_back(resNum);
109  PrimaryKey primary_key(primary_key_columns);
110 
111  Columns foreign_key_columns;
112  foreign_key_columns.push_back(struct_id);
113  foreign_key_columns.push_back(resNum);
114  vector1< std::string > reference_columns;
115  reference_columns.push_back("struct_id");
116  reference_columns.push_back("resNum");
117  ForeignKey foreign_key(foreign_key_columns, "residues", reference_columns, true);
118 
119  Schema table("rotamer_boltzmann_weight", primary_key);
120  table.add_foreign_key(foreign_key);
121  table.add_column(boltzmann_weight);
122 
123  table.write(db_session);
124 }
125 
128  utility::vector1<std::string> dependencies;
129  dependencies.push_back("ResidueFeatures");
130  return dependencies;
131 }
132 
133 void
135  TagPtr const tag,
136  DataMap & data,
137  Filters_map const & /*filters*/,
138  Movers_map const & /*movers*/,
139  Pose const & /*pose*/
140 ) {
141  if(tag->hasOption("scorefxn")){
142  string scorefxn_name = tag->getOption<string>("scorefxn");
143  rotamer_boltzmann_weight_->scorefxn(
144  data.get<ScoreFunction*>("scorefxns", scorefxn_name));
145  } else {
146  stringstream error_msg;
147  error_msg
148  << "The " << type_name() << " reporter requires a 'scorefxn' tag:" << endl
149  << endl
150  << " <feature name=" << type_name() <<" scorefxn=(name_of_score_function) />" << endl;
151  throw utility::excn::EXCN_RosettaScriptsOption(error_msg.str());
152  }
153 }
154 
155 
156 Size
158  Pose const & pose,
159  vector1< bool > const & relevant_residues,
160  boost::uuids::uuid const struct_id,
161  sessionOP db_session
162 ){
163 
164  std::string statement_string = "INSERT INTO rotamer_boltzmann_weight (struct_id, resNum, boltzmann_weight) VALUES (?,?,?);";
165  statement stmt(basic::database::safely_prepare_statement(statement_string,db_session));
166  for(Size resNum=1; resNum <= pose.total_residue(); ++resNum){
167  if(!relevant_residues[resNum]) continue;
168  Real const boltzmann_weight(
169  rotamer_boltzmann_weight_->compute_Boltzmann_weight(pose, resNum));
170 
171  stmt.bind(1,struct_id);
172  stmt.bind(2,resNum);
173  stmt.bind(3,boltzmann_weight);
174  basic::database::safely_write_to_database(stmt);
175 
176  }
177  return 0;
178 }
179 
180 } // namespace
181 } // namespace