Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GeometricSolvationFeatures.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/GeometricSolvationFeatures.cc
11 /// @brief report geometric solvation energy for each polar site to a features database
12 /// @author Matthew O'Meara
13 
14 // Unit Headers
16 
17 //External
18 #include <boost/uuid/uuid.hpp>
19 #include <boost/uuid/uuid_io.hpp>
20 
21 // Platform Headers
22 #include <core/pose/Pose.hh>
24 #include <core/types.hh>
25 
26 // Utility Headers
27 #include <utility/sql_database/DatabaseSessionManager.hh>
28 #include <utility/vector1.hh>
29 
30 // Basic Headers
31 #include <basic/options/option.hh>
32 #include <basic/options/keys/inout.OptionKeys.gen.hh>
33 #include <basic/database/sql_utils.hh>
34 
35 #include <basic/database/schema_generator/PrimaryKey.hh>
36 #include <basic/database/schema_generator/ForeignKey.hh>
37 #include <basic/database/schema_generator/Column.hh>
38 #include <basic/database/schema_generator/Schema.hh>
39 
40 
41 // External Headers
42 #include <cppdb/frontend.h>
43 // AUTO-REMOVED #include <cppdb/errors.h>
44 
45 // C++ Headers
46 #include <string>
47 
48 namespace protocols{
49 namespace features{
50 
51 using std::string;
52 using core::Size;
53 using core::Real;
54 using core::pose::Pose;
56 using utility::vector1;
57 using utility::sql_database::sessionOP;
58 using cppdb::statement;
59 using cppdb::result;
60 
62  geo_sol_energy_(ExactOccludedHbondSolEnergy())
63 {
64 
65  //I would like to simply assert that this has been called, but that
66  //currently is not possible.
67  //geo_sol_energy_.setup_for_scoring(pose, scfxn_);
68 
69 }
70 
72  GeometricSolvationFeatures const & src ) :
74  geo_sol_energy_(src.geo_sol_energy_)
75 {}
76 
77 string
78 GeometricSolvationFeatures::type_name() const { return "GeometricSolvationFeatures"; }
79 
80 void
82  sessionOP db_session
83 ) const {
85 }
86 
87 void
89  sessionOP db_session
90 ) const {
91  using namespace basic::database::schema_generator;
92 
93  Column struct_id("struct_id", new DbUUID());
94  Column hbond_site_id("hbond_site_id", new DbInteger());
95  Column geometric_solvation_exact("geometric_solvation_exact", new DbReal());
96 
97  Columns primary_key_columns;
98  primary_key_columns.push_back(struct_id);
99  primary_key_columns.push_back(hbond_site_id);
100  PrimaryKey primary_key(primary_key_columns);
101 
102  Columns foreign_key_columns;
103  foreign_key_columns.push_back(struct_id);
104  foreign_key_columns.push_back(hbond_site_id);
105  vector1< std::string > reference_columns;
106  reference_columns.push_back("struct_id");
107  reference_columns.push_back("site_id");
108  ForeignKey foreign_key(foreign_key_columns, "hbond_sites", reference_columns, true);
109 
110  Schema table("geometric_solvation", primary_key);
111  table.add_foreign_key(foreign_key);
112  table.add_column(geometric_solvation_exact);
113 
114  table.write(db_session);
115 }
116 
119  utility::vector1<std::string> dependencies;
120  dependencies.push_back("HBondFeatures");
121  return dependencies;
122 }
123 
124 Size
126  Pose const & pose,
127  vector1< bool > const &,
128  boost::uuids::uuid struct_id,
129  sessionOP db_session
130 ){
131 
132  std::string select_string =
133  "SELECT\n"
134  " site.site_id,\n"
135  " site.resNum,\n"
136  " site.atmNum\n"
137  "FROM\n"
138  " hbond_sites as site\n"
139  "WHERE\n"
140  " site.struct_id = ?;";
141  statement select_statement(basic::database::safely_prepare_statement(select_string,db_session));
142  select_statement.bind(1,struct_id);
143  result res(basic::database::safely_read_from_database(select_statement));
144 
145  while(res.next()){
146  Size site_id, resNum, atmNum;
147  res >> site_id >> resNum >> atmNum;
148 
149  Real const geometric_solvation_exact(
151  pose,
152  pose.residue(resNum),
153  atmNum));
154 
155  std::string insert_string = "INSERT INTO geometric_solvation (struct_id, hbond_site_id, geometric_solvation_exact) VALUES (?,?,?)";
156  statement insert_statement(basic::database::safely_prepare_statement(insert_string,db_session));
157  insert_statement.bind(1,struct_id);
158  insert_statement.bind(2,site_id);
159  insert_statement.bind(3,geometric_solvation_exact);
160  basic::database::safely_write_to_database(insert_statement);
161  }
162 
163  // locate the polar sites from the hbond_sites table
164 
165  return 0;
166 }
167 
168 } //namesapce
169 } //namespace