Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProteinBackboneTorsionAngleFeatures.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/ProteinBackboneTorsionAngleFeatures.cc
11 /// @brief report Backbone Torsional Angle features
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 
14 // Unit Headers
16 
17 // Project Headers
19 #include <utility/sql_database/DatabaseSessionManager.hh>
20 #include <utility/vector1.hh>
21 #include <basic/database/sql_utils.hh>
22 #include <basic/database/schema_generator/PrimaryKey.hh>
23 #include <basic/database/schema_generator/ForeignKey.hh>
24 #include <basic/database/schema_generator/Column.hh>
25 #include <basic/database/schema_generator/Schema.hh>
26 
27 
28 // Platform Headers
29 #include <core/pose/Pose.hh>
30 
31 // External Headers
32 #include <cppdb/frontend.h>
33 #include <boost/uuid/uuid_io.hpp>
34 
35 namespace protocols{
36 namespace features{
37 
38 using std::string;
39 using cppdb::statement;
40 using core::Size;
41 using core::Real;
43 using core::pose::Pose;
44 using utility::vector1;
45 using utility::sql_database::sessionOP;
46 
47 
49 
52 {}
53 
55 
56 string
57 ProteinBackboneTorsionAngleFeatures::type_name() const { return "ProteinBackboneTorsionAngleFeatures"; }
58 
59 void
61  sessionOP db_session
62 ) const {
64 }
65 
66 void
68  sessionOP db_session
69 ) const {
70  using namespace basic::database::schema_generator;
71 
72  Column struct_id("struct_id", new DbUUID());
73  Column resNum("resNum", new DbInteger());
74  Column phi("phi", new DbReal());
75  Column psi("psi", new DbReal());
76  Column omega("omega", new DbReal());
77 
78 
79  Columns primary_key_columns;
80  primary_key_columns.push_back(struct_id);
81  primary_key_columns.push_back(resNum);
82  PrimaryKey primary_key(primary_key_columns);
83 
84  Columns foreign_key_columns;
85  foreign_key_columns.push_back(struct_id);
86  foreign_key_columns.push_back(resNum);
87  vector1< std::string > reference_columns;
88  reference_columns.push_back("struct_id");
89  reference_columns.push_back("resNum");
90  ForeignKey foreign_key(foreign_key_columns, "residues", reference_columns, true);
91 
92  Schema table("protein_backbone_torsion_angles", primary_key);
93  table.add_foreign_key(foreign_key);
94  table.add_column(phi);
95  table.add_column(psi);
96  table.add_column(omega);
97 
98  table.write(db_session);
99 }
100 
103  utility::vector1<std::string> dependencies;
104  dependencies.push_back("ResidueFeatures");
105  return dependencies;
106 }
107 
108 Size
110  Pose const & pose,
111  vector1< bool > const & relevant_residues,
112  boost::uuids::uuid const struct_id,
113  sessionOP db_session
114 ){
115  std::string statement_string ="INSERT INTO protein_backbone_torsion_angles (struct_id, resNum, phi, psi, omega) VALUES (?,?,?,?,?)";
116  statement stmt(basic::database::safely_prepare_statement(statement_string,db_session));
117  for (Size i = 1; i <= pose.total_residue(); ++i) {
118  if(!relevant_residues[i]) continue;
119 
120  Residue const & resi = pose.residue(i);
121  if(!resi.is_protein()) continue;
122 
123 
124  Real phi (resi.mainchain_torsion(1));
125  Real psi (resi.mainchain_torsion(2));
126  Real omega(resi.mainchain_torsion(3));
127 
128  stmt.bind(1,struct_id);
129  stmt.bind(2,i);
130  stmt.bind(3,phi);
131  stmt.bind(4,psi);
132  stmt.bind(5,omega);
133  basic::database::safely_write_to_database(stmt);
134 
135  }
136  return 0;
137 }
138 
139 } // namesapce
140 } // namespace