Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OrbitalsFeatures.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/OrbitalsFeatures.cc
11 /// @brief report orbital geometry and scores to features statistics scientific benchmark
12 /// @author Matthew O'Meara
13 
14 // Unit Headers
16 
17 // Project Headers
20 #include <core/pose/Pose.hh>
22 #include <core/types.hh>
23 #include <basic/database/sql_utils.hh>
24 #include <basic/database/schema_generator/PrimaryKey.hh>
25 #include <basic/database/schema_generator/ForeignKey.hh>
26 #include <basic/database/schema_generator/Column.hh>
27 #include <basic/database/schema_generator/Schema.hh>
30 //Numeric Headers
31 #include <numeric/xyzVector.hh>
32 #include <numeric/xyz.functions.hh>
33 
34 
35 //Utility Headers
36 #include <utility/vector1.hh>
37 #include <utility/sql_database/DatabaseSessionManager.hh>
38 
39 // Boost Headers
40 #include <boost/foreach.hpp>
41 #define foreach BOOST_FOREACH
42 
43 // External Headers
44 #include <cppdb/frontend.h>
45 #include <boost/uuid/uuid_io.hpp>
46 
47 #include <utility/exit.hh>
48 
49 #include <basic/options/keys/OptionKeys.hh>
50 #include <basic/options/keys/in.OptionKeys.gen.hh>
51 #include <basic/options/option.hh>
52 
53 namespace protocols{
54 namespace features{
55 
56 using std::string;
58 using core::pose::Pose;
59 using core::Size;
60 using core::Real;
63 using numeric::xyzVector;
64 using utility::vector1;
65 using utility::sql_database::sessionOP;
66 using cppdb::statement;
67 
69 {
70  if(basic::options::option[ basic::options::OptionKeys::in::add_orbitals] != 1){
71  utility_exit_with_message( "Trying to run features test without orbitals! Pass the flag -add_orbitals!" );
72  }
73 }
74 
77 {
78  if(basic::options::option[ basic::options::OptionKeys::in::add_orbitals] != 1){
79  utility_exit_with_message( "Trying to run features test without orbitals! Pass the flag -add_orbitals!" );
80  }
81 }
82 
84 
85 string
86 OrbitalsFeatures::type_name() const { return "OrbitalsFeatures"; }
87 void
89  sessionOP db_session
90 ) 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 resNum1("resNum1", new DbInteger());
104  Column resName1("resName1", new DbText());
105  Column orbNum1("orbNum1", new DbInteger());
106  Column orbName1("orbName1", new DbText());
107  Column resNum2("resNum2", new DbInteger());
108  Column resName2("resName2", new DbText());
109  Column hpolNum2("hpolNum2", new DbInteger());
110  Column htype2("htype2", new DbText());
111  Column OrbHdist("OrbHdist", new DbReal());
112  Column cosAOH("cosAOH", new DbReal());
113  Column cosDHO("cosDHO", new DbReal());
114  Column chiBAOH("chiBAOH", new DbReal());
115  Column chiBDHO("chiBDHO", new DbReal());
116  Column AOH_angle("AOH_angle", new DbReal());
117  Column DHO_angle("DHO_angle", new DbReal());
118  Column chiBAHD("chiBAHD", new DbReal());
119  Column cosAHD("cosAHD", new DbReal());
120 
121  Columns primary_key_columns;
122  primary_key_columns.push_back(struct_id);
123  primary_key_columns.push_back(resNum1);
124  primary_key_columns.push_back(orbName1);
125  primary_key_columns.push_back(resNum2);
126  primary_key_columns.push_back(hpolNum2);
127  PrimaryKey primary_key(primary_key_columns);
128 
129  Columns foreign_key_columns1;
130  foreign_key_columns1.push_back(struct_id);
131  foreign_key_columns1.push_back(resNum1);
132  vector1< std::string > reference_columns1;
133  reference_columns1.push_back("struct_id");
134  reference_columns1.push_back("resNum");
135  ForeignKey foreign_key1(foreign_key_columns1, "residues", reference_columns1, true);
136 
137  Columns foreign_key_columns2;
138  foreign_key_columns2.push_back(struct_id);
139  foreign_key_columns2.push_back(resNum2);
140  vector1< std::string > reference_columns2;
141  reference_columns2.push_back("struct_id");
142  reference_columns2.push_back("resNum");
143  ForeignKey foreign_key2(foreign_key_columns2, "residues", reference_columns2, true);
144 
145 
146  Schema table("HPOL_orbital", primary_key);
147  table.add_foreign_key(foreign_key1);
148  table.add_foreign_key(foreign_key2);
149  table.add_column(resName1);
150  table.add_column(orbNum1);
151  table.add_column(resName2);
152  table.add_column(hpolNum2);
153  table.add_column(htype2);
154  table.add_column(OrbHdist);
155  table.add_column(cosAOH);
156  table.add_column(cosDHO);
157  table.add_column(chiBAOH);
158  table.add_column(chiBDHO);
159  table.add_column(AOH_angle);
160  table.add_column(DHO_angle);
161  table.add_column(chiBAHD);
162  table.add_column(cosAHD);
163 
164  table.write(db_session);
165 }
166 
167 void
169  sessionOP db_session
170 ) const {
171  using namespace basic::database::schema_generator;
172 
173  Column struct_id("struct_id", new DbUUID());
174  Column resNum1("resNum1", new DbInteger());
175  Column resName1("resName1", new DbText());
176  Column orbNum1("orbNum1", new DbInteger());
177  Column orbName1("orbName1", new DbText());
178  Column resNum2("resNum2", new DbInteger());
179  Column resName2("resName2", new DbText());
180  Column haroNum2("haroNum2", new DbInteger());
181  Column htype2("htype2", new DbText());
182  Column OrbHdist("orbHdist", new DbReal());
183  Column cosAOH("cosAOH", new DbReal());
184  Column cosDHO("cosDHO", new DbReal());
185  Column chiBAOH("chiBAOH", new DbReal());
186  Column chiBDHO("chiBDHO", new DbReal());
187  Column AOH_angle("AOH_angle", new DbReal());
188  Column DHO_angle("DHO_angle", new DbReal());
189  Column chiBAHD("chiBAHD", new DbReal());
190  Column cosAHD("cosAHD", new DbReal());
191 
192  Columns primary_key_columns;
193  primary_key_columns.push_back(struct_id);
194  primary_key_columns.push_back(resNum1);
195  primary_key_columns.push_back(orbName1);
196  primary_key_columns.push_back(resNum2);
197  primary_key_columns.push_back(haroNum2);
198  PrimaryKey primary_key(primary_key_columns);
199 
200  Columns foreign_key_columns1;
201  foreign_key_columns1.push_back(struct_id);
202  foreign_key_columns1.push_back(resNum1);
203  vector1< std::string > reference_columns1;
204  reference_columns1.push_back("struct_id");
205  reference_columns1.push_back("resNum");
206  ForeignKey foreign_key1(foreign_key_columns1, "residues", reference_columns1, true);
207 
208  Columns foreign_key_columns2;
209  foreign_key_columns2.push_back(struct_id);
210  foreign_key_columns2.push_back(resNum2);
211  vector1< std::string > reference_columns2;
212  reference_columns2.push_back("struct_id");
213  reference_columns2.push_back("resNum");
214  ForeignKey foreign_key2(foreign_key_columns2, "residues", reference_columns2, true);
215 
216 
217  Schema table("HARO_orbital", primary_key);
218  table.add_foreign_key(foreign_key1);
219  table.add_foreign_key(foreign_key2);
220  table.add_column(resName1);
221  table.add_column(orbNum1);
222  table.add_column(resName2);
223  table.add_column(haroNum2);
224  table.add_column(htype2);
225  table.add_column(OrbHdist);
226  table.add_column(cosAOH);
227  table.add_column(cosDHO);
228  table.add_column(chiBAOH);
229  table.add_column(chiBDHO);
230  table.add_column(AOH_angle);
231  table.add_column(DHO_angle);
232  table.add_column(chiBAHD);
233  table.add_column(cosAHD);
234 
235  table.write(db_session);
236 }
237 
238 void
240  sessionOP db_session
241 ) const {
242  using namespace basic::database::schema_generator;
243 
244  Column struct_id("struct_id", new DbUUID());
245  Column resNum1("resNum1", new DbInteger());
246  Column resName1("resName1", new DbText());
247  Column orbNum1("orbNum1", new DbInteger());
248  Column orbName1("orbName1", new DbText());
249  Column resNum2("resNum2", new DbInteger());
250  Column resName2("resName2", new DbText());
251  Column orbNum2("orbNum2", new DbInteger());
252  Column orbName2("orbName2", new DbText());
253  Column orbOrbdist("orbOrbdist", new DbReal());
254  Column cosAOO("cosAOO", new DbReal());
255  Column cosDOO("cosDOO", new DbReal());
256  Column chiBAOO("chiBAOO", new DbReal());
257  Column chiBDOO("chiBDOO", new DbReal());
258  Column AOO_angle("AOO_angle", new DbReal());
259  Column DOO_angle("DOO_angle", new DbReal());
260  Column DOA_angle("DOA_angle", new DbReal());
261  Column AOD_angle("AOD_angle", new DbReal());
262  Column chiBAHD("chiBAHD", new DbReal());
263  Column cosAHD("cosAHD", new DbReal());
264 
265  Columns primary_key_columns;
266  primary_key_columns.push_back(struct_id);
267  primary_key_columns.push_back(resNum1);
268  primary_key_columns.push_back(orbName1);
269  primary_key_columns.push_back(resNum2);
270  primary_key_columns.push_back(orbNum2);
271  PrimaryKey primary_key(primary_key_columns);
272 
273  Columns foreign_key_columns1;
274  foreign_key_columns1.push_back(struct_id);
275  foreign_key_columns1.push_back(resNum1);
276  vector1< std::string > reference_columns1;
277  reference_columns1.push_back("struct_id");
278  reference_columns1.push_back("resNum");
279  ForeignKey foreign_key1(foreign_key_columns1, "residues", reference_columns1, true);
280 
281  Columns foreign_key_columns2;
282  foreign_key_columns2.push_back(struct_id);
283  foreign_key_columns2.push_back(resNum2);
284  vector1< std::string > reference_columns2;
285  reference_columns2.push_back("struct_id");
286  reference_columns2.push_back("resNum");
287  ForeignKey foreign_key2(foreign_key_columns2, "residues", reference_columns2, true);
288 
289 
290  Schema table("orbital_orbital", primary_key);
291  table.add_foreign_key(foreign_key1);
292  table.add_foreign_key(foreign_key2);
293  table.add_column(resName1);
294  table.add_column(orbNum1);
295  table.add_column(resName2);
296  table.add_column(orbName2);
297  table.add_column(orbOrbdist);
298  table.add_column(cosAOO);
299  table.add_column(cosDOO);
300  table.add_column(chiBAOO);
301  table.add_column(chiBDOO);
302  table.add_column(AOO_angle);
303  table.add_column(DOO_angle);
304  table.add_column(DOA_angle);
305  table.add_column(AOD_angle);
306  table.add_column(chiBAHD);
307  table.add_column(cosAHD);
308 
309  table.write(db_session);
310 }
311 
314  utility::vector1<std::string> dependencies;
315  dependencies.push_back("ResidueFeatures");
316  return dependencies;
317 }
318 
319 
320 Size
322  Pose const & pose,
323  vector1< bool > const & relevant_residues,
324  boost::uuids::uuid const struct_id,
325  sessionOP db_session
326 ){
327  report_hpol_orbital_interactions( pose, relevant_residues, struct_id, db_session );
328  //report_haro_orbital_interactions( pose, relevant_residues, struct_id, db_session );
329  return 0;
330 }
331 
332 
333 ///@brief get statistics based upon polar hydrogen to orbital distance/angle
334 void
336  Pose const & pose,
337  vector1< bool > const &,
338  boost::uuids::uuid const struct_id,
339  sessionOP db_session
340 ){
341  std::string orbita_H_string = "INSERT INTO HPOL_orbital (struct_id, resNum1, orbName1, resNum2, hpolNum2, resName1, orbNum1, resName2, htype2, OrbHdist, cosAOH, cosDHO, chiBAOH, chiBDHO, AOH_angle, DHO_angle, chiBAHD, cosAHD) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
342  statement orbital_H_statement(basic::database::safely_prepare_statement(orbita_H_string,db_session));
343  std::string orbita_orbital_string = "INSERT INTO orbital_orbital (struct_id, resNum1, orbName1, resNum2, orbNum2, resName1, orbNum1, resName2, orbName2, orbOrbdist, cosAOO, cosDOO, chiBAOO, chiBDOO, AOO_angle, DOO_angle, DOA_angle, AOD_angle, chiBAHD, cosAHD) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
344  statement orbital_orbital_statement(basic::database::safely_prepare_statement(orbita_orbital_string,db_session));
345  std::string orbita_Haro_string = "INSERT INTO HARO_orbital (struct_id, resNum1, orbName1, resNum2, haroNum2, resName1, orbNum1, resName2, htype2, orbHdist, cosAOH, cosDHO, chiBAOH, chiBDHO, AOH_angle, DHO_angle, chiBAHD, cosAHD) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
346  statement orbital_Haro_statement(basic::database::safely_prepare_statement(orbita_Haro_string,db_session));
347 
348 
349 
350  for(Size resNum1 = 1; resNum1 <= pose.n_residue(); ++resNum1){
351  Residue res1 = pose.residue(resNum1);
352  Size resNum2(0);
353  string orbName1;
354  string htype2;
355  string resName1=res1.name3();
356  string res2name;
357  Size orbNum1(0);
358  Size hpolNum2(0);
359  //Size atm(0);
360  Size haroNum2(0);
361  Real cosAOH(0);
362  Real cosDHO(0);
363  Real chiBDHO(0);
364  Real chiBAOH(0);
365  Real AOH_angle(0);
366  Real DHO_angle(0);
367  Real chiBAHD(0);
368  Real cosAHD(0);
369  Size OrbNum2(0);
370  string OrbName2;
371  //Real OrbOrbdist(0);
372  Real cosAOO(0);
373  Real cosDOO(0);
374  Real chiBAOO(0);
375  Real chiBDOO(0);
376  Real AOO_angle(0);
377  Real DOO_angle(0);
378  Real DOA_angle(0);
379  Real AOD_angle(0);
380  Real OrbHdist(10.1); // min distance used to derive statistics. Should be the shortest distance between an orbital and hydrogen
381  bool orb_orb=false;
382  bool orb_haro=false;
383  bool orb_hpol=false;
384  for(Size res_num2 = 1; res_num2 <= pose.n_residue(); ++res_num2){
385  Residue res2 = pose.residue(res_num2);
386  if(resNum1 != res_num2){
387  foreach(Size const Aindex, res1.atoms_with_orb_index()){
388  foreach(Size const Dindex, res2.atoms_with_orb_index()){
389  if(res1.atom_is_backbone(Aindex) || res2.atom_is_backbone(Dindex)){
390  continue;//just say no to backbone backbone interactions!
391  }else{
392  foreach(Size const Orbindex1, res1.bonded_orbitals(Aindex)){
393  foreach(Size const Orbindex2, res2.bonded_orbitals(Dindex)){
394  xyzVector<Real> const res1_Orbxyz(res1.orbital_xyz(Orbindex1));
395  xyzVector<Real> const res2_Orbxyz(res2.orbital_xyz(Orbindex2));
396  Real const container(res1_Orbxyz.distance(res2_Orbxyz));
397  //this will actually set OrbHdist to a new low if the container is less than OrbHdist
398  //making this type of interaction a pi-pi interaction for cation-pi, not a pi-hpol cation-pi interaction
399  if(container <= OrbHdist){
400  set_OrbOrb_features_data(res1, res2, Aindex, Dindex, Orbindex1, Orbindex2, res1_Orbxyz, res2_Orbxyz, resNum2,
401  orbName1, res2name, OrbName2, orbNum1, OrbNum2, cosAOO, cosDOO, chiBAOO, chiBDOO, AOO_angle,
402  DOO_angle, OrbHdist, DOA_angle, AOD_angle, chiBAHD, cosAHD);
403  orb_orb=true; //registering with the features reporter that we have a cation_pi interaction
404  orb_hpol=false;
405  orb_haro=false;
406  }
407  }
408  }
409  }
410  }
411  }
412  foreach(Size const Aindex, res1.atoms_with_orb_index()){
413  foreach(Size const Orbindex, res1.bonded_orbitals(Aindex)){
414  xyzVector<Real> const Orbxyz(res1.orbital_xyz(Orbindex));
415  foreach(Size const Hindex, res2.Haro_index()){
416  xyzVector<Real> Hxyz(res2.atom(Hindex).xyz());
417  Real const container(Orbxyz.distance(Hxyz));
418  if(container <= OrbHdist){
419  set_OrbH_features_data(res1, res2, Aindex, Hindex, Orbindex, Orbxyz, resNum2, orbName1, htype2, res2name,
420  orbNum1, haroNum2, cosAOH, cosDHO, chiBDHO, chiBAOH, AOH_angle, DHO_angle, chiBAHD,cosAHD, OrbHdist );
421  orb_haro=true;
422  orb_hpol=false;
423  orb_orb=false;
424 
425  }
426  }
427  }
428 
429  }
430  foreach(Size const Aindex, res1.atoms_with_orb_index()){
431  foreach(Size const Orbindex, res1.bonded_orbitals(Aindex)){
432  xyzVector<Real> const Orbxyz(res1.orbital_xyz(Orbindex));
433 
434  foreach(Size const Hindex, res2.Hpol_index()){
435  Size Dindex(res2.bonded_neighbor(Hindex)[1]);
436  if(res1.atom_is_backbone(Aindex) && res2.atom_is_backbone(Dindex)){
437  continue;//do nothing. Dont really want to calculate bb-bb interactions
438  }else{
439  xyzVector<Real> Hxyz(res2.atom(Hindex).xyz());
440  Real const container(Orbxyz.distance(Hxyz));
441  if(container <= OrbHdist){
442  set_OrbH_features_data(res1, res2, Aindex, Hindex, Orbindex, Orbxyz, resNum2, orbName1, htype2, res2name,
443  orbNum1, hpolNum2, cosAOH, cosDHO, chiBDHO, chiBAOH, AOH_angle, DHO_angle, chiBAHD,cosAHD, OrbHdist );
444  orb_hpol=true;
445  orb_orb=false;
446  orb_haro=false;
447  }
448  }
449  }
450 
451  }
452  }
453  //we have to check cation pi interactions. This type of interaction for an arg/aromatic
454  //can be between the polar hydrogen of the arg and the pi-orbital of the aromatic ring
455  //or it can be between the pi orbital on the arg and the pi-orbital on the aromatic ring
456  //this is a special case. Lys does not have a pi-orbital on its nitrogen, therefore, lys
457  //can go go on through the if loop that checks distances
458  //NOTE this does not take into consideration cation-pi interactions between a ligand
459  //something more elegant is needed for that
460 
461  }
462  }
463  if(OrbHdist <=10.0 && orb_hpol == true){
464  orbital_H_statement.bind(1,struct_id);
465  orbital_H_statement.bind(2, resNum1);
466  orbital_H_statement.bind(3, orbName1);
467  orbital_H_statement.bind(4, resNum2);
468  orbital_H_statement.bind(5, hpolNum2);
469  orbital_H_statement.bind(6, resName1);
470  orbital_H_statement.bind(7,orbNum1 );
471  orbital_H_statement.bind(8, res2name);
472  orbital_H_statement.bind(9, htype2);
473  orbital_H_statement.bind(10, OrbHdist);
474  orbital_H_statement.bind(11, cosAOH);
475  orbital_H_statement.bind(12, cosDHO);
476  orbital_H_statement.bind(13, chiBAOH);
477  orbital_H_statement.bind(14, chiBDHO);
478  orbital_H_statement.bind(15, AOH_angle);
479  orbital_H_statement.bind(16, DHO_angle);
480  orbital_H_statement.bind(17, chiBAHD);
481  orbital_H_statement.bind(18, cosAHD);
482  basic::database::safely_write_to_database(orbital_H_statement);
483  }
484  if(OrbHdist <=10.0 && orb_orb== true){
485  orbital_orbital_statement.bind(1,struct_id);
486  orbital_orbital_statement.bind(2, resNum1);
487  orbital_orbital_statement.bind(3, orbName1);
488  orbital_orbital_statement.bind(4, resNum2);
489  orbital_orbital_statement.bind(5, OrbNum2);
490  orbital_orbital_statement.bind(6, resName1);
491  orbital_orbital_statement.bind(7, orbNum1);
492  orbital_orbital_statement.bind(8, res2name);
493  orbital_orbital_statement.bind(9, OrbName2);
494  orbital_orbital_statement.bind(10, OrbHdist);
495  orbital_orbital_statement.bind(11, cosAOO);
496  orbital_orbital_statement.bind(12, cosDOO);
497  orbital_orbital_statement.bind(13, chiBAOO);
498  orbital_orbital_statement.bind(14, chiBDOO);
499  orbital_orbital_statement.bind(15, AOO_angle);
500  orbital_orbital_statement.bind(16, DOO_angle);
501  orbital_orbital_statement.bind(17, DOA_angle);
502  orbital_orbital_statement.bind(18, AOD_angle);
503  orbital_orbital_statement.bind(19, chiBAHD);
504  orbital_orbital_statement.bind(18, cosAHD);
505 
506 
507  basic::database::safely_write_to_database(orbital_orbital_statement);
508  }
509  if(OrbHdist <=10.0 && orb_haro == true){
510  orbital_Haro_statement.bind(1,struct_id);
511  orbital_Haro_statement.bind(2, resNum1);
512  orbital_Haro_statement.bind(3, orbName1);
513  orbital_Haro_statement.bind(4, resNum2);
514  orbital_Haro_statement.bind(5, hpolNum2);
515  orbital_Haro_statement.bind(6, resName1);
516  orbital_Haro_statement.bind(7, orbNum1);
517  orbital_Haro_statement.bind(8, res2name);
518  orbital_Haro_statement.bind(9, htype2);
519  orbital_Haro_statement.bind(10, OrbHdist);
520  orbital_Haro_statement.bind(11, cosAOH);
521  orbital_Haro_statement.bind(12, cosDHO);
522  orbital_Haro_statement.bind(13, chiBAOH);
523  orbital_Haro_statement.bind(14, chiBDHO);
524  orbital_Haro_statement.bind(15, AOH_angle);
525  orbital_Haro_statement.bind(16, DHO_angle);
526  orbital_Haro_statement.bind(17, chiBAHD);
527  orbital_Haro_statement.bind(18, cosAHD);
528  basic::database::safely_write_to_database(orbital_Haro_statement);
529  }
530  }
531 }
532 
533 
534 
535 ///@brief get statistics based upon aromatic hydrogen to orbital distance/angle
536 void
538  Pose const & /* pose */,
539  vector1< bool > const &,
540  boost::uuids::uuid const /* struct_id */,
541  sessionOP /* db_session */
542 ){
543 /* std::string orbita_H_string = "INSERT INTO HARO_orbital (struct_id, resNum1, orbName1, resNum2, haroNum2, resName1, orbNum1, resName2, htype2, orbHdist, cosAOH, cosDHO, chiBAOH, chiBDHO, AOH_angle, DHO_angle, chiBAHD, cosAHD) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
544  statement orbital_H_statement(basic::database::safely_prepare_statement(orbita_H_string,db_session));
545 
546 
547  for(Size resNum1 = 1; resNum1 <= pose.n_residue(); ++resNum1){
548  Residue res1 = pose.residue(resNum1);
549  Size resNum2(0);
550  string orbName1;
551  string htype2;
552  string res1name;
553  string res2name;
554  Size orbNum1(0);
555  Size haroNum2(0);
556  Size atm(0);
557  Real cosAOH(0);
558  Real cosDHO(0);
559  Real chiBDHO(0);
560  Real chiBAOH(0);
561  Real AOH_angle(0);
562  Real DHO_angle(0);
563  Real chiBAHD(0);
564  Real cosAHD(0);
565  Real OrbHdist(10.1); // min distance used to derive statistics. Should be the shortest distance between an orbital and hydrogen
566  for(Size res_num2 = 1; res_num2 <= pose.n_residue(); ++res_num2){
567  Residue res2 = pose.residue(res_num2);
568  foreach(Size const Aindex, res1.atoms_with_orb_index()){
569  foreach(Size const Orbindex, res1.bonded_orbitals(Aindex)){
570  xyzVector<Real> const Orbxyz(res1.orbital_xyz(Orbindex));
571 
572  if(resNum1 != res_num2){
573  foreach(Size const Hindex, res2.Haro_index()){
574  xyzVector<Real> Hxyz(res2.atom(Hindex).xyz());
575  Real const container(Orbxyz.distance(Hxyz));
576  if(container <= OrbHdist){
577  set_OrbH_features_data(res1, res2, Aindex, Hindex, Orbindex, Orbxyz, resNum2, orbName1, htype2, res2name,
578  orbNum1, haroNum2, cosAOH, cosDHO, chiBDHO, chiBAOH, AOH_angle, DHO_angle, chiBAHD,cosAHD, OrbHdist );
579 
580  }
581  }
582  }
583  }
584 
585  }
586  }
587  if(OrbHdist <=10.0){
588  orbital_H_statement.bind(1,struct_id);
589  orbital_H_statement.bind(2, resNum1);
590  orbital_H_statement.bind(3, res1name);
591  orbital_H_statement.bind(4,orbNum1 );
592  orbital_H_statement.bind(5, orbName1);
593  orbital_H_statement.bind(6, resNum2);
594  orbital_H_statement.bind(7, res2name);
595  orbital_H_statement.bind(8, haroNum2);
596  orbital_H_statement.bind(9, htype2);
597  orbital_H_statement.bind(10, OrbHdist);
598  orbital_H_statement.bind(11, cosAOH);
599  orbital_H_statement.bind(12, cosDHO);
600  orbital_H_statement.bind(13, chiBAOH);
601  orbital_H_statement.bind(14, chiBDHO);
602  orbital_H_statement.bind(15, AOH_angle);
603  orbital_H_statement.bind(16, DHO_angle);
604  orbital_H_statement.bind(17, chiBAHD);
605  orbital_H_statement.bind(18, cosAHD);
606 
607  basic::database::safely_write_to_database(orbital_H_statement);
608  }
609  }*/
610 }
611 
612 
613 
614 void
616  Residue & res1,
617  Residue & res2,
618  Size const Aindex,
619  Size const Hindex,
620  Size const Orbindex,
621  xyzVector<Real> const Orbxyz,
622  Size & resNum2,
623  string & orbName1,
624  string & htype2,
625  string & res2name,
626  Size & orbNum1,
627  Size & hpolNum2,
628  Real & cosAOH,
629  Real & cosDHO,
630  Real & chiBDHO,
631  Real & chiBAOH,
632  Real & AOH_angle,
633  Real & DHO_angle,
634  Real & chiBAHD,
635  Real & cosAHD,
636  Real & OrbHdist
637  ){
638  xyzVector<Real> Hxyz(res2.atom(Hindex).xyz());
639  orbName1=res1.orbital_type(Orbindex).name();
640  htype2=res2.atom_type(Hindex).name();
641  Real const container(Orbxyz.distance(Hxyz));
642  xyzVector<Real> Axyz(res1.atom(Aindex).xyz());
643  core::Size Dindex(res2.bonded_neighbor(Hindex)[1]);
644  xyzVector<Real> Dxyz(res2.xyz(Dindex));
645  AOH_angle = cos_of(Axyz, Orbxyz, Hxyz );
646  DHO_angle = cos_of(Dxyz, Hxyz, Orbxyz);
647  OrbHdist=container;
648  resNum2=res2.seqpos();
649  hpolNum2=Hindex;
650  std::string res1name=res1.name3();
651  orbNum1=Orbindex;
652  res2name= res2.name3();
653 
654  xyzVector<Real> Bxyz(res2.atom(res2.atom_base(Dindex)).xyz());
655 
656  if(res2name == "PHE" || res2name == "TYR" || res2name == "TRP" || res2name == "HIS"){
657  res2.update_actcoord();
658  Bxyz= res2.actcoord();
659 
660  }
661  if(res2name == "ARG"){
662  Bxyz = res2.atom(res2.atom_index(" CZ ")).xyz();;
663  }
664 
665  xyzVector<Real> AHunit = Orbxyz - Hxyz;
666  AHunit.normalize();
667 
668  xyzVector<Real> BAunit = Hxyz - Dxyz;
669  BAunit.normalize();
670 
671  cosDHO = dot( BAunit, AHunit );
672  chiBDHO = numeric::dihedral_radians(Bxyz, Dxyz, Hxyz,Orbxyz);
673 
674  //BAOH_chi
675  Bxyz = res1.atom(res1.atom_base(Aindex)).xyz();
676 
677  if(res1name == "PHE" || res1name == "TYR" || res1name == "TRP" || res1name == "HIS"){
678  res1.update_actcoord();
679  Bxyz= res1.actcoord();
680  if(Orbindex <= 2){
681  Bxyz = Axyz;
682  Axyz = res1.actcoord();
683  }
684  }
685  if(res1name == "ARG"){
686  Bxyz = res1.atom(res1.atom_index(" CZ ")).xyz();;
687  }
688  AHunit = Hxyz - Orbxyz;
689  AHunit.normalize();
690 
691  BAunit = Orbxyz - Axyz;
692  BAunit.normalize();
693 
694  cosAOH = dot( BAunit, AHunit );
695  chiBAOH = numeric::dihedral_radians(Bxyz,Axyz , Orbxyz,Hxyz);
696 
697  AHunit = Dxyz - Hxyz;
698  AHunit.normalize();
699  BAunit = Hxyz - Axyz;
700  BAunit.normalize();
701 
702  cosAHD = dot(BAunit, AHunit);
703  chiBAHD = numeric::dihedral_radians(Bxyz, Axyz, Hxyz, Dxyz);
704 
705 }
706 
707 void
709  Residue & res1,
710  Residue & res2,
711  Size Aindex,
712  Size Dindex,
713  Size Orbindex1,
714  Size Orbindex2,
715  xyzVector<Real> const & Orbxyz1,
716  xyzVector<Real> const & Orbxyz2,
717  Size & resNum2,
718  string & orbName1,
719  string & res2name,
720  string & OrbName2,
721  Size & orbNum1,
722  Size & OrbNum2,
723  Real & cosAOO,
724  Real & cosDOO,
725  Real & chiBAOO,
726  Real & chiBDOO,
727  Real & AOO_angle,
728  Real & DOO_angle,
729  Real & OrbHdist,
730  Real & DOA_angle,
731  Real & AOD_angle,
732  Real & /* chiBAHD */,
733  Real & /* cosAHD */
734  ){
735  Real const container(Orbxyz1.distance(Orbxyz2));
736  xyzVector<Real> const Axyz(res1.atom(Aindex).xyz());
737  xyzVector<Real> Dxyz(res2.xyz(Dindex));
738  AOO_angle = cos_of(Axyz, Orbxyz1, Orbxyz2 );
739  DOO_angle = cos_of(Dxyz, Orbxyz2, Orbxyz1);
740  OrbHdist=container;
741  resNum2=res2.seqpos();
742  orbName1=res1.orbital_type(Orbindex1).name();
743  OrbName2=res2.orbital_type(Orbindex2).name();
744  AOD_angle = cos_of(Axyz, Orbxyz1, Dxyz);
745  DOA_angle = cos_of(Dxyz, Orbxyz2, Axyz);
746  orbNum1=Orbindex1;
747  OrbNum2=Orbindex2;
748  std::string res1name = res1.name3();
749  res2name= res2.name3();
750 
751  xyzVector<Real> Bxyz(res2.atom(res2.atom_base(Dindex)).xyz());
752 
753  //res2 will never be phe or tyr or trp
754  xyzVector<Real> AHunit = Orbxyz1 - Orbxyz2;
755  AHunit.normalize();
756 
757 
758  xyzVector<Real> BAunit = Orbxyz2 - Dxyz;
759  BAunit.normalize();
760 
761  cosDOO = dot( BAunit, AHunit );
762  chiBDOO = numeric::dihedral_radians(Bxyz, Dxyz, Orbxyz2,Orbxyz1);
763 
764  //BAOH_chi
765  Bxyz = res1.atom(res1.atom_base(Aindex)).xyz();
766 
767  if(res1name == "PHE" || res1name == "TYR" || res1name == "TRP" || res1name == "HIS"){
768  res1.update_actcoord();
769  Bxyz= res1.actcoord();
770  }
771 
772  AHunit = Orbxyz2 - Orbxyz1;
773  AHunit.normalize();
774 
775  BAunit = Orbxyz1 - Axyz;
776  BAunit.normalize();
777 
778  cosAOO = dot( BAunit, AHunit );
779  chiBAOO = numeric::dihedral_radians(Bxyz,Axyz, Orbxyz1,Orbxyz2);
780  Bxyz = res1.atom(res1.atom_base(Aindex)).xyz();
781 
782 /*
783  if(res1name == "PHE" || res1name == "TYR" || res1name == "TRP" || res1name == "HIS"){
784  res1.update_actcoord();
785  Bxyz= res1.actcoord();
786  }
787 
788  AHunit = Dxyz - Hxyz;
789  AHunit.normalize();
790  BAunit = Hxyz - Axyz;
791  BAunit.normalize();
792 
793  cosAHD = dot(BAunit, AHunit);
794  chiBAHD = numeric::dihedral_radians(Bxyz, Axyz, Hxyz, Dxyz);
795 */
796 
797 }
798 
799 
800 } // namesapce
801 } // namespace
802