Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProteinBackboneAtomAtomPairFeatures.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/ProteinBackboneAtomAtomPairFeatures.cc
11 /// @brief report atom-atom pair distances between atoms in protein backbones to features Statistics Scientific Benchmark
12 /// @author Matthew O'Meara (mattjomeara@gmail.com)
13 
14 // Unit Headers
16 
17 // Project Headers
18 #include <core/chemical/AA.hh>
22 #include <core/graph/Graph.hh>
23 #include <core/pose/Pose.hh>
25 #include <core/scoring/Energies.hh>
26 #include <core/types.hh>
27 #include <utility/sql_database/DatabaseSessionManager.hh>
28 #include <utility/vector1.hh>
29 #include <basic/database/sql_utils.hh>
30 
31 #include <basic/database/schema_generator/PrimaryKey.hh>
32 #include <basic/database/schema_generator/ForeignKey.hh>
33 #include <basic/database/schema_generator/Column.hh>
34 #include <basic/database/schema_generator/Schema.hh>
35 
36 
37 // External Headers
38 #include <cppdb/frontend.h>
39 #include <boost/uuid/uuid_io.hpp>
40 
41 namespace protocols{
42 namespace features{
43 
44 using std::string;
47 using core::pose::Pose;
48 using core::Size;
49 using core::Distance;
50 using core::Vector;
51 using core::graph::Graph;
54 using utility::sql_database::sessionOP;
55 using utility::vector1;
56 using cppdb::statement;
57 
59 
62 {}
63 
65 
66 string
67 ProteinBackboneAtomAtomPairFeatures::type_name() const { return "ProteinBackboneAtomAtomPairFeatures"; }
68 
69 void
71  sessionOP db_session
72 ) const {
74 }
75 
76 void
78  sessionOP db_session
79 ) const {
80  using namespace basic::database::schema_generator;
81 
82  Column struct_id("struct_id", new DbUUID());
83  Column resNum1("resNum1", new DbInteger());
84  Column resNum2("resNum2", new DbInteger());
85  Column N_N_dist("N_N_dist", new DbReal());
86  Column N_Ca_dist("N_Ca_dist", new DbReal());
87  Column N_C_dist("N_C_dist", new DbReal());
88  Column N_O_dist("N_O_dist", new DbReal());
89  Column N_Ha_dist("N_Ha_dist", new DbReal());
90  Column Ca_N_dist("Ca_N_dist", new DbReal());
91  Column Ca_Ca_dist("Ca_Ca_dist", new DbReal());
92  Column Ca_C_dist("Ca_C_dist", new DbReal());
93  Column Ca_O_dist("Ca_O_dist", new DbReal());
94  Column Ca_Ha_dist("Ca_Ha_dist", new DbReal());
95  Column C_N_dist("C_N_dist", new DbReal());
96  Column C_Ca_dist("C_Ca_dist", new DbReal());
97  Column C_C_dist("C_C_dist", new DbReal());
98  Column C_O_dist("C_O_dist", new DbReal());
99  Column C_Ha_dist("C_Ha_dist", new DbReal());
100  Column O_N_dist("O_N_dist", new DbReal());
101  Column O_Ca_dist("O_Ca_dist", new DbReal());
102  Column O_C_dist("O_C_dist", new DbReal());
103  Column O_O_dist("O_O_dist", new DbReal());
104  Column O_Ha_dist("O_Ha_dist", new DbReal());
105  Column Ha_N_dist("Ha_N_dist", new DbReal());
106  Column Ha_Ca_dist("Ha_Ca_dist", new DbReal());
107  Column Ha_C_dist("Ha_C_dist", new DbReal());
108  Column Ha_O_dist("Ha_O_dist", new DbReal());
109  Column Ha_Ha_dist("Ha_Ha_dist", new DbReal());
110 
111  Columns primary_key_columns;
112  primary_key_columns.push_back(struct_id);
113  primary_key_columns.push_back(resNum1);
114  primary_key_columns.push_back(resNum2);
115  PrimaryKey primary_key(primary_key_columns);
116 
117  Columns foreign_key_columns1;
118  foreign_key_columns1.push_back(struct_id);
119  foreign_key_columns1.push_back(resNum1);
120  vector1< std::string > reference_columns1;
121  reference_columns1.push_back("struct_id");
122  reference_columns1.push_back("resNum");
123  ForeignKey foreign_key1(foreign_key_columns1, "residues", reference_columns1, true);
124 
125  Columns foreign_key_columns2;
126  foreign_key_columns2.push_back(struct_id);
127  foreign_key_columns2.push_back(resNum2);
128  vector1< std::string > reference_columns2;
129  reference_columns2.push_back("struct_id");
130  reference_columns2.push_back("resNum");
131  ForeignKey foreign_key2(foreign_key_columns2, "residues", reference_columns2, true);
132 
133  Schema table("protein_backbone_atom_atom_pairs", primary_key);
134  table.add_foreign_key(foreign_key1);
135  table.add_foreign_key(foreign_key2);
136  table.add_column(N_N_dist);
137  table.add_column(N_Ca_dist);
138  table.add_column(N_C_dist);
139  table.add_column(N_O_dist);
140  table.add_column(N_Ha_dist);
141  table.add_column(Ca_N_dist);
142  table.add_column(Ca_Ca_dist);
143  table.add_column(Ca_C_dist);
144  table.add_column(Ca_O_dist);
145  table.add_column(Ca_Ha_dist);
146  table.add_column(C_N_dist);
147  table.add_column(C_Ca_dist);
148  table.add_column(C_C_dist);
149  table.add_column(C_O_dist);
150  table.add_column(C_Ha_dist);
151  table.add_column(O_N_dist);
152  table.add_column(O_Ca_dist);
153  table.add_column(O_C_dist);
154  table.add_column(O_O_dist);
155  table.add_column(O_Ha_dist);
156  table.add_column(Ha_N_dist);
157  table.add_column(Ha_Ca_dist);
158  table.add_column(Ha_C_dist);
159  table.add_column(Ha_O_dist);
160  table.add_column(Ha_Ha_dist);
161 
162  table.write(db_session);
163 }
164 
167  utility::vector1<std::string> dependencies;
168  dependencies.push_back("ResidueFeatures");
169  return dependencies;
170 }
171 
172 /// @details These atom-atom pairs follow the analysis done in:
173 ///
174 /// Song Y, Tyka M, Leaver-Fay A, Thompson J, Baker D. Structure
175 /// guided forcefield optimization. Proteins: Structure, Function,
176 /// and Bioinformatics. 2011:n/a-n/a. Available at:
177 /// http://doi.wiley.com/10.1002/prot.23013 [Accessed April 4, 2011].
178 ///
179 /// The HBond geometries are recoded in the HBondFeatures reporter
180 Size
182  Pose const & pose,
183  vector1< bool > const & relevant_residues,
184  boost::uuids::uuid const struct_id,
185  sessionOP db_session
186 ){
187  TenANeighborGraph const & tenA(pose.energies().tenA_neighbor_graph());
188 
189  std::string statement_string = "INSERT INTO protein_backbone_atom_atom_pairs (struct_id, resNum1, resNum2, N_N_dist, N_Ca_dist, N_C_dist, N_O_dist, N_Ha_dist, Ca_N_dist, Ca_Ca_dist, Ca_C_dist, Ca_O_dist, Ca_Ha_dist, C_N_dist, C_Ca_dist, C_C_dist, C_O_dist, C_Ha_dist, O_N_dist, O_Ca_dist, O_C_dist, O_O_dist, O_Ha_dist, Ha_N_dist, Ha_Ca_dist, Ha_C_dist, Ha_O_dist, Ha_Ha_dist) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
190  statement stmt(basic::database::safely_prepare_statement(statement_string,db_session));
191 
192  for(Size resNum1=1; resNum1 <= pose.total_residue(); ++resNum1){
193  if(!relevant_residues[resNum1]) continue;
194  Residue const & res1 = pose.residue(resNum1);
195  if(!res1.is_protein()) continue;
196 
197  Vector const & N1(res1.xyz("N"));
198  Vector const & Ca1(res1.xyz("CA"));
199  Vector const & C1(res1.xyz("C"));
200  Vector const & O1(res1.xyz("O"));
201  // For glysine, use the hydrogen that is in the same chiral
202  // position as HA on other amino acids
203  Vector const & HA1(
204  res1.aa() != core::chemical::aa_gly ? res1.xyz("HA") : res1.xyz("2HA"));
205 
207  ir = tenA.get_node( resNum1 )->const_edge_list_begin(),
208  ire = tenA.get_node( resNum1 )->const_edge_list_end();
209  ir != ire; ++ir ) {
210  Size resNum2( (*ir)->get_other_ind(resNum1) );
211  if(!relevant_residues[resNum2] || (resNum1 >= resNum2)) continue;
212  Residue const & res2 = pose.residue(resNum2);
213  if(!res2.is_protein()) continue;
214 
215  Vector const & N2(res2.xyz("N"));
216  Vector const & Ca2(res2.xyz("CA"));
217  Vector const & C2(res2.xyz("C"));
218  Vector const & O2(res2.xyz("O"));
219  // For glysine, use the hydrogen that is in the same chiral
220  // position as HA on other amino acids
221  Vector const & HA2(
222  res2.aa() != core::chemical::aa_gly ? res2.xyz("HA") : res2.xyz("2HA"));
223 
224  stmt.bind(1,struct_id);
225  stmt.bind(2,resNum1);
226  stmt.bind(3,resNum2);
227  stmt.bind(4,N1.distance(N2));
228  stmt.bind(5,N1.distance(Ca2));
229  stmt.bind(6,N1.distance(C2));
230  stmt.bind(7,N1.distance(O2));
231  stmt.bind(8,N1.distance(HA2));
232  stmt.bind(9,Ca1.distance(N2));
233  stmt.bind(10,Ca1.distance(Ca2));
234  stmt.bind(11,Ca1.distance(C2));
235  stmt.bind(12,Ca1.distance(O2));
236  stmt.bind(13,Ca1.distance(HA2));
237  stmt.bind(14,C1.distance(N2));
238  stmt.bind(15,C1.distance(Ca2));
239  stmt.bind(16,C1.distance(C2));
240  stmt.bind(17,C1.distance(O2));
241  stmt.bind(18,C1.distance(HA2));
242  stmt.bind(19,O1.distance(N2));
243  stmt.bind(20,O1.distance(Ca2));
244  stmt.bind(21,O1.distance(C2));
245  stmt.bind(22,O1.distance(O2));
246  stmt.bind(23,O1.distance(HA2));
247  stmt.bind(24,HA1.distance(N2));
248  stmt.bind(25,HA1.distance(Ca2));
249  stmt.bind(26,HA1.distance(C2));
250  stmt.bind(27,HA1.distance(O2));
251  stmt.bind(28,HA1.distance(HA2));
252 
253 
254  basic::database::safely_write_to_database(stmt);
255  } //res2
256  } //res1
257  return 0;
258 }
259 } // namesapce
260 } // namespace