Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StrandBundleFeatures.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 // :notabs=false:tabSize=4:indentsize=4:
4 //
5 // (c) copyright rosetta commons member institutions.
6 // (c) this file is part of the rosetta software suite and is made available under license.
7 // (c) the rosetta software is developed by the contributing members of the rosetta commons.
8 // (c) for more information, see http://www.rosettacommons.org. questions about this can be
9 // (c) addressed to university of washington uw techtransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/features/strand_assembly/StrandBundleFeatures.cc
12 /// @brief Search through a pose for sets of 2 strands
13 /// @author Doo Nam Kim (based on Tim Jacobs' helixAssembly)
14 
15 
16 //Core
17 #include <core/types.hh>
20 
21 //External
22 #include <boost/uuid/uuid.hpp>
23 
24 //Devel
27 
28 //Utility and basic
29 #include <basic/database/sql_utils.hh>
30 #include <utility/sql_database/DatabaseSessionManager.hh>
31 #include <numeric/xyz.functions.hh> // for torsion calculations
32 
33 //C library
34 #include <string>
35 #include <math.h>
36 
37 
38 //External Headers
39 #include <cppdb/frontend.h>
40 
41 //Basic
42 #include <basic/Tracer.hh>
43 #include <basic/options/util.hh>
44 #include <basic/options/keys/strand_assembly.OptionKeys.gen.hh>
45 #include <basic/database/schema_generator/PrimaryKey.hh>
46 #include <basic/database/schema_generator/ForeignKey.hh>
47 #include <basic/database/schema_generator/Column.hh>
48 #include <basic/database/schema_generator/Schema.hh>
49 #include <basic/database/schema_generator/Constraint.hh>
50 
52 #include <core/scoring/ScoreFunction.hh> // ScoreFunction.hh seems required for compilation of InterfaceAnalyzerMover.hh
53 
54 static basic::Tracer TR("protocols.features.strand_assembly.StrandBundleFeatures");
55 
56 namespace protocols {
57 namespace features {
58 namespace strand_assembly {
59 
60 using namespace std;
61 using namespace core;
62 using core::pose::Pose;
63 using utility::vector1;
64 using utility::sql_database::sessionOP;
65 using cppdb::statement;
66 using cppdb::result;
67 
69 min_strand_size_(4),
70 max_strand_size_(15),
71 min_O_N_dis_(2.6),
72 max_O_N_dis_(3.1),
73 min_sheet_dis_(7.0),
74 max_sheet_dis_(14.0), // 15 Angstrom may seem OK, but I set it to 14, because 15 cases are not easy to make assemblies as of now
75 min_sheet_torsion_(-40.0), // according to swissmodel.expasy.org/course/text/chapter4.htm, -20 < torsion < -50, but I set it to -40, because -50 cases are not easy to make assemblies as of now
76 max_sheet_torsion_(-20.0)
77 {
79 }
80 
82  using namespace basic::options;
83 
84  if(option[OptionKeys::strand_assembly::min_strand_size].user()){
85  min_strand_size_ = option[OptionKeys::strand_assembly::min_strand_size];
86  }
87  if(option[OptionKeys::strand_assembly::max_strand_size].user()){
88  max_strand_size_ = option[OptionKeys::strand_assembly::max_strand_size];
89  }
90  if(option[OptionKeys::strand_assembly::min_O_N_dis].user()){
91  min_O_N_dis_ = option[OptionKeys::strand_assembly::min_O_N_dis];
92  }
93  if(option[OptionKeys::strand_assembly::max_O_N_dis].user()){
94  max_O_N_dis_ = option[OptionKeys::strand_assembly::max_O_N_dis];
95  }
96  if(option[OptionKeys::strand_assembly::min_sheet_dis].user()){
97  min_sheet_dis_ = option[OptionKeys::strand_assembly::min_sheet_dis];
98  }
99  if(option[OptionKeys::strand_assembly::max_sheet_dis].user()){
100  max_sheet_dis_ = option[OptionKeys::strand_assembly::max_sheet_dis];
101  }
102  if(option[OptionKeys::strand_assembly::min_sheet_torsion].user()){
103  min_sheet_torsion_ = option[OptionKeys::strand_assembly::min_sheet_torsion];
104  }
105  if(option[OptionKeys::strand_assembly::max_sheet_torsion].user()){
106  max_sheet_torsion_ = option[OptionKeys::strand_assembly::max_sheet_torsion];
107  }
108 }
109 
112  utility::vector1<std::string> dependencies;
113  dependencies.push_back("ResidueFeatures");
114  dependencies.push_back("ProteinResidueConformationFeatures");
115  dependencies.push_back("ResidueSecondaryStructureFeatures");
116  return dependencies;
117 }
118 
119 void
120 StrandBundleFeatures::write_schema_to_db(utility::sql_database::sessionOP db_session) const{
121  using namespace basic::database::schema_generator;
122 
123  /****** write strand_pairs ******/
124 
125  // PrimaryKey
126  // id of strand_pairs
127  Column pairs_id ("pairs_id", new DbInteger(), false /*not null*/, true /*autoincrement*/);
128 
129  // bool_parallel is PrimaryKey just because it doesn't point to any foreign values
130  Column bool_parallel ("bool_parallel", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
131 
132  // unique key of original PDB file
133  Column struct_id ("struct_id", new DbUUID(), false /*not null*/, false /*don't autoincrement*/);
134 
135  // ForeignKey
136  Column i_strand_residue_start("i_strand_residue_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
137  Column i_strand_residue_end ("i_strand_residue_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
138  Column j_strand_residue_start("j_strand_residue_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
139  Column j_strand_residue_end ("j_strand_residue_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
140 
141  // Schema
142  // PrimaryKey
143  Schema strand_pairs("strand_pairs", PrimaryKey(pairs_id));
144 // Schema strand_pairs("bool_parallel", PrimaryKey(bool_parallel));
145 
146  // ForeignKey
147 
148  strand_pairs.add_foreign_key(ForeignKey(struct_id, "structures", "struct_id", true /*defer*/));
149  // (reference) wiki.rosettacommons.org/index.php/MultiBodyFeaturesReporters#StructureFeatures
150 
151  // fkey_reference_cols -> one definition of fkey_reference_cols is enough since it will be used repeatedly
152  utility::vector1<std::string> fkey_reference_cols;
153  fkey_reference_cols.push_back("struct_id");
154  fkey_reference_cols.push_back("resNum");
155 
156  // i_start_fkey_cols
157  utility::vector1<Column> i_start_fkey_cols;
158  i_start_fkey_cols.push_back(struct_id);
159  i_start_fkey_cols.push_back(i_strand_residue_start);
160 
161  strand_pairs.add_foreign_key(ForeignKey(i_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
162  // (reference) wiki.rosettacommons.org/index.php/OneBodyFeaturesReporters#ResidueFeatures
163 
164  // i_end_fkey_cols
165  utility::vector1<Column> i_end_fkey_cols;
166  i_end_fkey_cols.push_back(struct_id);
167  i_end_fkey_cols.push_back(i_strand_residue_end);
168 
169  strand_pairs.add_foreign_key(ForeignKey(i_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
170 
171  // j_start_fkey_cols
172  utility::vector1<Column> j_start_fkey_cols;
173  j_start_fkey_cols.push_back(struct_id);
174  j_start_fkey_cols.push_back(j_strand_residue_start);
175 
176  strand_pairs.add_foreign_key(ForeignKey(j_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
177 
178  // j_end_fkey_cols
179  utility::vector1<Column> j_end_fkey_cols;
180  j_end_fkey_cols.push_back(struct_id);
181  j_end_fkey_cols.push_back(j_strand_residue_end);
182 
183  strand_pairs.add_foreign_key(ForeignKey(j_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
184 
185  strand_pairs.write(db_session);
186 
187 
188  /****** write sheet_pairs ******/
189 
190  // PrimaryKey
191  Column sheet_pairs_id ("sheet_pairs_id", new DbInteger(), false /*not null*/, true /*autoincrement*/);
192 
193  // group1 (g1) should be close pair with each other, group2 should be close pair with each other
194  // ForeignKey
195  // group 1
196  // strand 1
197  Column g1_strand_1_res_start ("g1_strand_1_res_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
198  Column g1_strand_1_res_end ("g1_strand_1_res_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
199  // strand 2
200  Column g1_strand_2_res_start ("g1_strand_2_res_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
201  Column g1_strand_2_res_end ("g1_strand_2_res_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
202 
203  // group 2
204  Column g2_strand_1_res_start ("g2_strand_1_res_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
205  Column g2_strand_1_res_end ("g2_strand_1_res_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
206  Column g2_strand_2_res_start ("g2_strand_2_res_start", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
207  Column g2_strand_2_res_end ("g2_strand_2_res_end", new DbInteger(), false /*not null*/, false /*don't autoincrement*/);
208 
209  Column shortest_sc_dis ("shortest_sc_dis", new DbDouble(), false /*not null*/, false /*don't autoincrement*/);
210 
211  // Schema
212  // PrimaryKey
213  Schema sheet_pairs("sheet_pairs", PrimaryKey(sheet_pairs_id));
214 
215  // ForeignKey
216  sheet_pairs.add_foreign_key(ForeignKey(struct_id, "structures", "struct_id", true /*defer*/));
217 
218  // g1_s1_start_fkey_cols
219  utility::vector1<Column> g1_s1_start_fkey_cols;
220  g1_s1_start_fkey_cols.push_back(struct_id);
221  g1_s1_start_fkey_cols.push_back(g1_strand_1_res_start);
222 
223  sheet_pairs.add_foreign_key(ForeignKey(g1_s1_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
224 
225  // g1_s1_end_fkey_cols
226  utility::vector1<Column> g1_s1_end_fkey_cols;
227  g1_s1_end_fkey_cols.push_back(struct_id);
228  g1_s1_end_fkey_cols.push_back(g1_strand_1_res_end);
229 
230  sheet_pairs.add_foreign_key(ForeignKey(g1_s1_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
231 
232 
233  // g1_s2_start_fkey_cols
234  utility::vector1<Column> g1_s2_start_fkey_cols;
235  g1_s2_start_fkey_cols.push_back(struct_id);
236  g1_s2_start_fkey_cols.push_back(g1_strand_2_res_start);
237 
238  sheet_pairs.add_foreign_key(ForeignKey(g1_s2_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
239 
240  // g1_s2_end_fkey_cols
241  utility::vector1<Column> g1_s2_end_fkey_cols;
242  g1_s2_end_fkey_cols.push_back(struct_id);
243  g1_s2_end_fkey_cols.push_back(g1_strand_2_res_end);
244 
245  sheet_pairs.add_foreign_key(ForeignKey(g1_s2_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
246 
247  // g2_s1_start_fkey_cols
248  utility::vector1<Column> g2_s1_start_fkey_cols;
249  g2_s1_start_fkey_cols.push_back(struct_id);
250  g2_s1_start_fkey_cols.push_back(g2_strand_1_res_start);
251 
252  sheet_pairs.add_foreign_key(ForeignKey(g2_s1_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
253 
254  // g2_s1_end_fkey_cols
255  utility::vector1<Column> g2_s1_end_fkey_cols;
256  g2_s1_end_fkey_cols.push_back(struct_id);
257  g2_s1_end_fkey_cols.push_back(g2_strand_1_res_end);
258 
259  sheet_pairs.add_foreign_key(ForeignKey(g2_s1_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
260 
261  // g2_s2_start_fkey_cols
262  utility::vector1<Column> g2_s2_start_fkey_cols;
263  g2_s2_start_fkey_cols.push_back(struct_id);
264  g2_s2_start_fkey_cols.push_back(g2_strand_2_res_start);
265 
266  sheet_pairs.add_foreign_key(ForeignKey(g2_s2_start_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
267 
268  // g2_s2_end_fkey_cols
269  utility::vector1<Column> g2_s2_end_fkey_cols;
270  g2_s2_end_fkey_cols.push_back(struct_id);
271  g2_s2_end_fkey_cols.push_back(g2_strand_2_res_end);
272 
273  sheet_pairs.add_foreign_key(ForeignKey(g2_s2_end_fkey_cols, "residues", fkey_reference_cols, true /*defer*/));
274 
275  sheet_pairs.add_column(shortest_sc_dis);
276 
277  sheet_pairs.write(db_session);
278 
279 }
280 
281 //Select all strand segments reported by the ResidueSecondaryStructureFeatures and save them in a vector
282 utility::vector1<StrandFragment> StrandBundleFeatures::get_full_strands(boost::uuids::uuid struct_id, sessionOP db_session){
283  std::string select_string =
284  "SELECT\n"
285  " strands.beta_id,\n"
286  " strands.residue_begin,\n"
287  " strands.residue_end\n"
288  "FROM\n"
289  " beta_segments as strands\n"
290  "WHERE\n"
291  " strands.struct_id = ?;";
292 
293  statement select_statement(basic::database::safely_prepare_statement(select_string,db_session));
294  select_statement.bind(1,struct_id);
295  result res(basic::database::safely_read_from_database(select_statement));
296 
298  while(res.next()){
299  Size strand_id, residue_begin, residue_end;
300  res >> strand_id >> residue_begin >> residue_end;
301  all_strands.push_back(StrandFragment(residue_begin, residue_end));
302  }
303 
304  return all_strands;
305 }
306 
307 //Select all i strand reported by the StrandBundleFeatures::get_full_strands and save them in a vector
309  std::string select_string =
310  "SELECT\n"
311  " strand_pairs_table.pairs_id,\n"
312  " strand_pairs_table.i_strand_residue_start,\n"
313  " strand_pairs_table.i_strand_residue_end\n"
314  "FROM\n"
315  " strand_pairs as strand_pairs_table\n"
316  "WHERE\n"
317  " strand_pairs_table.struct_id = ?;";
318 
319  statement select_statement(basic::database::safely_prepare_statement(select_string,db_session));
320  select_statement.bind(1,struct_id);
321  result res(basic::database::safely_read_from_database(select_statement));
322 
324  while(res.next()){
325  Size strand_pairs_id, i_strand_residue_start, i_strand_residue_end;
326  res >> strand_pairs_id >> i_strand_residue_start >> i_strand_residue_end;
327  i_strand.push_back(StrandFragment(i_strand_residue_start, i_strand_residue_end));
328  }
329  return i_strand;
330 }
331 
332 //Select all j strand reported by the StrandBundleFeatures::get_full_strands and save them in a vector
334  std::string select_string =
335  "SELECT\n"
336  " strand_pairs_table.pairs_id,\n"
337  " strand_pairs_table.j_strand_residue_start,\n"
338  " strand_pairs_table.j_strand_residue_end\n"
339  "FROM\n"
340  " strand_pairs as strand_pairs_table\n"
341  "WHERE\n"
342  " strand_pairs_table.struct_id = ?;";
343 
344  statement select_statement(basic::database::safely_prepare_statement(select_string,db_session));
345  select_statement.bind(1,struct_id);
346  result res(basic::database::safely_read_from_database(select_statement));
347 
349  while(res.next()){
350  Size strand_pairs_id, j_strand_residue_start, j_strand_residue_end;
351  res >> strand_pairs_id >> j_strand_residue_start >> j_strand_residue_end;
352  j_strand.push_back(StrandFragment(j_strand_residue_start, j_strand_residue_end));
353  }
354  return j_strand;
355 }
356 
357 
358 
359 bool
361  Pose const & pose,
362  StrandFragment strand_i,
363  StrandFragment strand_j
364  )
365 {
366 // TR.Info << "strand_i.get_start() : " << strand_i.get_start() << endl;
367 // TR.Info << "strand_i.get_end() : " << strand_i.get_end() << endl;
368 // TR.Info << "strand_j.get_start() : " << strand_j.get_start() << endl;
369 // TR.Info << "strand_j.get_end() : " << strand_j.get_end() << endl;
370 
371  // seeing distances between 'O' of strand "i" and 'N' of strand "j"
372  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
373  {
374  Size i_resnum = strand_i.get_start()+strand_i_res;
375  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
376  {
377 
378  Size j_resnum = strand_j.get_start()+strand_j_res;
379  // TR.Info << "residue number (strand_i.get_start()+strand_i_res): " << i_resnum << endl;
380  // TR.Info << "residue number (strand_j.get_start()+strand_j_res): " << j_resnum << endl;
381  // TR.Info << "pose.residue(i_resnum): " << pose.residue(i_resnum) << endl;
382  // TR.Info << "pose.residue(j_resnum): " << pose.residue(j_resnum) << endl;
383 
384  Real dis_N_O = pose.residue(i_resnum).atom("N").xyz().distance(pose.residue(j_resnum).atom("O").xyz());
385 // TR.Info << "distance between resnum("<< i_resnum << ")'s N and resnum(" << j_resnum << ")'s O = " << dis_N_O << endl;
386  if (dis_N_O > min_O_N_dis_ && dis_N_O < max_O_N_dis_) {
387 // TR.Info << "<first check of anti-parallel> distance between N and O is within " <<min_O_N_dis_ << " and " << max_O_N_dis_ << endl;
388  Real dis_O_N_confirm_antiparallel = pose.residue(i_resnum).atom("O").xyz().distance(pose.residue(j_resnum).atom("N").xyz());
389 // TR.Info << "distance between resnum("<< i_resnum << ")'s O and resnum(" << j_resnum << ")'s N = " << dis_O_N_confirm_antiparallel << endl;
390  if (dis_O_N_confirm_antiparallel > min_O_N_dis_ && dis_O_N_confirm_antiparallel < max_O_N_dis_) {
391 // TR.Info << "<second check of antiparallel> distance between O and N is within " <<min_O_N_dis_ << " and " << max_O_N_dis_ << " too, anti-parallel found!" << endl;
392  return true;
393  }
394  }
395  }
396  }
397  return false;
398 } //StrandBundleFeatures::find_antiparallel
399 
400 
401 bool
403  Pose const & pose,
404  StrandFragment strand_i,
405  StrandFragment strand_j
406  )
407 {
408  // seeing distances between 'O' of strand "i" and 'N' of strand "j"
409  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
410  {
411  Size i_resnum = strand_i.get_start()+strand_i_res;
412  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
413  {
414 
415  Size j_resnum = strand_j.get_start()+strand_j_res;
416 // TR.Info << "residue number (strand_i.get_start()+strand_i_res): " << i_resnum << endl;
417 // TR.Info << "residue number (strand_j.get_start()+strand_j_res): " << j_resnum << endl;
418 // TR.Info << "pose.residue(i_resnum): " << pose.residue(i_resnum) << endl;
419 // TR.Info << "pose.residue(j_resnum): " << pose.residue(j_resnum) << endl;
420 
421  Real dis_O_N = pose.residue(i_resnum).atom("O").xyz().distance(pose.residue(j_resnum).atom("N").xyz());
422  // TR.Info << "distance between resnum("<< i_resnum << ")'s O and resnum(" << j_resnum << ")'s N = " << dis_O_N << endl;
423  if (dis_O_N > min_O_N_dis_ && dis_O_N < max_O_N_dis_) {
424  // TR.Info << "<first check of parallel> distance between O and N within min_O_N_dis_ and max_O_N_dis_" << endl;
425  Real dis_N_O_confirm_parallel = pose.residue(i_resnum+2).atom("N").xyz().distance(pose.residue(j_resnum).atom("O").xyz());
426  // TR.Info << "distance between resnum("<< i_resnum+2 << ")'s N and resnum(" << j_resnum << ")'s O = " << dis_N_O_confirm_parallel << endl;
427  if (dis_N_O_confirm_parallel > min_O_N_dis_ && dis_N_O_confirm_parallel < max_O_N_dis_) {
428  // TR.Info << "<second check of parallel> distance between N and O within min_O_N_dis_ and max_O_N_dis_ too, parallel found!" << endl;
429  return true;
430  }
431  }
432  }
433  }
434  return false;
435 } //StrandBundleFeatures::find_parallel
436 
437 
438 
439 
440 Real
442  Pose const & pose,
443  StrandFragment strand_i,
444  StrandFragment strand_j
445  )
446 {
447  // check anti-parallel sheet distance
448 
449 // TR.Info << "strand_i size : " << strand_i.get_size() << endl;
450 // TR.Info << "strand_i first residue number : " << strand_i.get_start() << endl;
451 // TR.Info << "strand_i ending residue number : " << strand_i.get_end() << endl;
452 
453 // TR.Info << "strand_j size : " << strand_j.get_size() << endl;
454 // TR.Info << "strand_j first residue number : " << strand_j.get_start() << endl;
455 // TR.Info << "strand_j ending residue number : " << strand_j.get_end() << endl;
456 
457  // first, check the shortest distance between the two strand_pairs
458  // seeing distances between 'CA' of strand "i" and 'CA' of strand "j"
459  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
460  {
461  Size i_resnum = strand_i.get_start()+strand_i_res;
462  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
463  {
464  Size j_resnum = strand_j.get_start()+strand_j_res;
465 
466  Real dis_CA_CA = pose.residue(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
467  // TR.Info << "distance between resnum("<< i_resnum << ")'s CA and resnum(" << j_resnum << ")'s CA = " << dis_CA_CA << endl;
468 
469  if (dis_CA_CA < 6.0)
470  {
471  // TR.Info << "these two pair of strands are within 6 Angstrom <check_sheet_dis_antiparallel>" << endl;
472  return -99;
473  }
474  }
475  }
476 
477 // TR.Info << "OK, these two strand_pairs are farther than 6 Angstrom <check_sheet_dis_antiparallel>" << endl;
478 
479 // TR.Info << "let me see distances between strands " << endl;
480 // TR.Info << "pose: " << pose << endl;
481  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
482  {
483  Size i_resnum = strand_i.get_start()+strand_i_res;
484  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
485  {
486  Size j_resnum = strand_j.get_start()+strand_j_res;
487  //TR.Info << "residue number (strand_i.get_start()+strand_i_res): " << i_resnum << endl;
488  //TR.Info << "residue number (strand_j.get_start()+strand_j_res): " << j_resnum << endl;
489  //TR.Info << "pose.residue(i_resnum): " << pose.residue(i_resnum) << endl;
490  //TR.Info << "pose.residue(j_resnum): " << pose.residue(j_resnum) << endl;
491 
492 
493  Real dis_CA_CA_1 = pose.residue(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
494  //TR.Info << "distance between resnum("<< i_resnum << ")'s CA and resnum(" << j_resnum << ")'s CA = " << dis_CA_CA << endl;
495  if (dis_CA_CA_1 > min_sheet_dis_ && dis_CA_CA_1 < max_sheet_dis_)
496  {
497  //TR.Info << "<1st check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
498  Size current_i_resnum = i_resnum+1;
499  Size current_j_resnum = j_resnum-1;
500  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
501  {
502  Real dis_CA_CA_2 = pose.residue(i_resnum+1).atom("CA").xyz().distance(pose.residue(j_resnum-1).atom("CA").xyz());
503  //TR.Info << "distance between resnum("<< i_resnum+1 << ")'s CA and resnum(" << j_resnum-1 << ")'s CA = " << dis_CA_CA << endl;
504  if (dis_CA_CA_2 > min_sheet_dis_ && dis_CA_CA_2 < max_sheet_dis_)
505  {
506  // TR.Info << "<2nd check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
507  Size current_i_resnum = i_resnum+2;
508  Size current_j_resnum = j_resnum-2;
509  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
510  {
511  Real dis_CA_CA_3 = pose.residue(i_resnum+2).atom("CA").xyz().distance(pose.residue(j_resnum-2).atom("CA").xyz());
512  // TR.Info << "distance between resnum("<< i_resnum+2 << ")'s CA and resnum(" << j_resnum-2 << ")'s CA = " << dis_CA_CA << endl;
513  if (dis_CA_CA_3 > min_sheet_dis_ && dis_CA_CA_2 < max_sheet_dis_)
514  {
515  // TR.Info << "<3rd check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
516  Size current_i_resnum = i_resnum+3;
517  Size current_j_resnum = j_resnum-3;
518  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
519  {
520  Real dis_CA_CA_4 = pose.residue(i_resnum+3).atom("CA").xyz().distance(pose.residue(j_resnum-3).atom("CA").xyz());
521  // TR.Info << "distance between resnum("<< i_resnum+3 << ")'s CA and resnum(" << j_resnum-3 << ")'s CA = " << dis_CA_CA << endl;
522  if (dis_CA_CA_4 > min_sheet_dis_ && dis_CA_CA_4 < max_sheet_dis_)
523  {
524  // TR.Info << "<4th check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
525  Real avg_dis_CA_CA = (dis_CA_CA_1 + dis_CA_CA_2 + dis_CA_CA_3 + dis_CA_CA_4)/4;
526  return avg_dis_CA_CA;
527  }
528  }
529  else
530  {
531  TR.Info << "maybe no residue here" << endl;
532  return -99;
533  }
534  }
535  }
536  else
537  {
538  TR.Info << "maybe no residue here" << endl;
539  return -99;
540  }
541  }
542  }
543  else
544  {
545  TR.Info << "maybe no residue here" << endl;
546  return -99;
547  }
548  }
549  }
550  }
551  return -99;
552 } //StrandBundleFeatures::check_sheet_dis_antiparallel
553 
554 
555 
556 Real
558  Pose const & pose,
559  StrandFragment strand_i,
560  StrandFragment strand_j
561  ) // check parallel sheet distance
562 {
563 
564 
565 // TR.Info << "strand_i size : " << strand_i.get_size() << endl;
566 // TR.Info << "strand_i first residue number : " << strand_i.get_start() << endl;
567 // TR.Info << "strand_i ending residue number : " << strand_i.get_end() << endl;
568 
569 // TR.Info << "strand_j size : " << strand_j.get_size() << endl;
570 // TR.Info << "strand_j first residue number : " << strand_j.get_start() << endl;
571 // TR.Info << "strand_j ending residue number : " << strand_j.get_end() << endl;
572 
573 
574  // first, check the shortest distance between the two strand_pairs
575  // seeing distances between 'CA' of strand "i" and 'CA' of strand "j"
576  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
577  {
578  Size i_resnum = strand_i.get_start()+strand_i_res;
579  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
580  {
581  Size j_resnum = strand_j.get_start()+strand_j_res;
582 
583  Real dis_CA_CA = pose.residue(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
584  // TR.Info << "distance between resnum("<< i_resnum << ")'s CA and resnum(" << j_resnum << ")'s CA = " << dis_CA_CA << endl;
585 
586  if (dis_CA_CA < 6.0)
587  {
588  // TR.Info << "these two pair of strands are within 6 Angstrom <check_sheet_dis_parallel>" << endl;
589  return -99;
590  }
591  }
592  }
593 
594 // TR.Info << "OK, these two strand_pairs are farther than 6 Angstrom <check_sheet_dis_parallel>" << endl;
595 
596  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
597  {
598  Size i_resnum = strand_i.get_start()+strand_i_res;
599  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
600  {
601  Size j_resnum = strand_j.get_start()+strand_j_res;
602  // TR.Info << "residue number (strand_i.get_start()+strand_i_res): " << i_resnum << endl;
603  // TR.Info << "residue number (strand_j.get_start()+strand_j_res): " << j_resnum << endl;
604  // TR.Info << "pose.residue(i_resnum): " << pose.residue(i_resnum) << endl;
605  // TR.Info << "pose.residue(j_resnum): " << pose.residue(j_resnum) << endl;
606 
607 
608 
609  Real dis_CA_CA_1 = pose.residue(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
610  // TR.Info << "distance between resnum("<< i_resnum << ")'s CA and resnum(" << j_resnum << ")'s CA = " << dis_CA_CA << endl;
611  if (dis_CA_CA_1 > min_sheet_dis_ && dis_CA_CA_1 < max_sheet_dis_)
612  {
613  // TR.Info << "<1st check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
614  Size current_i_resnum = i_resnum+1;
615  Size current_j_resnum = j_resnum+1;
616  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
617  {
618  Real dis_CA_CA_2 = pose.residue(i_resnum+1).atom("CA").xyz().distance(pose.residue(j_resnum+1).atom("CA").xyz());
619  // TR.Info << "distance between resnum("<< i_resnum+1 << ")'s CA and resnum(" << j_resnum+1 << ")'s CA = " << dis_CA_CA << endl;
620  if (dis_CA_CA_2 > min_sheet_dis_ && dis_CA_CA_2 < max_sheet_dis_)
621  {
622  // TR.Info << "<2nd check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
623  Size current_i_resnum = i_resnum+2;
624  Size current_j_resnum = j_resnum+2;
625  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
626  {
627  Real dis_CA_CA_3 = pose.residue(i_resnum+2).atom("CA").xyz().distance(pose.residue(j_resnum+2).atom("CA").xyz());
628  // TR.Info << "distance between resnum("<< i_resnum+2 << ")'s CA and resnum(" << j_resnum+2 << ")'s CA = " << dis_CA_CA << endl;
629  if (dis_CA_CA_3 > min_sheet_dis_ && dis_CA_CA_3 < max_sheet_dis_)
630  {
631  // TR.Info << "<3rd check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
632  Size current_i_resnum = i_resnum+3;
633  Size current_j_resnum = j_resnum+3;
634  if (current_i_resnum > 0 && current_i_resnum <= pose.total_residue() && current_j_resnum > 0 && current_j_resnum <= pose.total_residue())
635  {
636  Real dis_CA_CA_4 = pose.residue(i_resnum+3).atom("CA").xyz().distance(pose.residue(j_resnum+3).atom("CA").xyz());
637  // TR.Info << "distance between resnum("<< i_resnum+3 << ")'s CA and resnum(" << j_resnum+3 << ")'s CA = " << dis_CA_CA << endl;
638  if (dis_CA_CA_4 > min_sheet_dis_ && dis_CA_CA_4 < max_sheet_dis_)
639  {
640  // TR.Info << "<4th check of sheet> distance between CA and CA is within " << min_sheet_dis_ << " and " << max_sheet_dis_ << endl;
641 
642  Real avg_dis_CA_CA = (dis_CA_CA_1 + dis_CA_CA_2 + dis_CA_CA_3 + dis_CA_CA_4)/4;
643  return avg_dis_CA_CA;
644  }
645  }
646  else
647  {
648  TR.Info << "maybe no residue here" << endl;
649  return -99;
650  }
651  }
652  }
653  else
654  {
655  TR.Info << "maybe no residue here" << endl;
656  return -99;
657  }
658  }
659  }
660  else
661  {
662  TR.Info << "maybe no residue here" << endl;
663  return -99;
664  }
665  }
666  }
667  }
668  return -99;
669 } //StrandBundleFeatures::check_sheet_dis_parallel
670 
671 
672 Real
674  Pose const & pose,
675  StrandFragment strand_i,
676  StrandFragment strand_j
677  )
678 {
679  // check anti-parallel sheet
680  //TR.Info << "strand_i size : " << strand_i.get_size() << endl;
681  // TR.Info << "strand_i first residue number : " << strand_i.get_start() << endl;
682  //TR.Info << "pose.residue(strand_i.get_start()): " << pose.residue(strand_i.get_start()) << endl;
683  // TR.Info << "strand_i ending residue number : " << strand_i.get_end() << endl;
684  //TR.Info << "pose.residue(strand_i.get_end()): " << pose.residue(strand_i.get_end()) << endl;
685 
686  // TR.Info << "strand_j size : " << strand_j.get_size() << endl;
687  // TR.Info << "strand_j first residue number : " << strand_j.get_start() << endl;
688  //TR.Info << "pose.residue(strand_j.get_start()): " << pose.residue(strand_j.get_start()) << endl;
689  // TR.Info << "strand_j ending residue number : " << strand_j.get_end() << endl;
690  //TR.Info << "pose.residue(strand_j.get_end()): " << pose.residue(strand_j.get_end()) << endl;
691 
692  //I need to define 4 terminal residues correctly for torsion calculation
693  Real dis_i_end_and_j_start = pose.residue(strand_i.get_end()).atom("CA").xyz().distance(pose.residue(strand_j.get_start()).atom("CA").xyz());
694  Real dis_i_end_and_j_end = pose.residue(strand_i.get_end()).atom("CA").xyz().distance(pose.residue(strand_j.get_end()).atom("CA").xyz());
695  if (dis_i_end_and_j_start < dis_i_end_and_j_end)
696  {
697  //TR.Info << "dis_i_end_and_j_start < dis_i_end_and_j_end" << endl;
698 
699  Vector const& first_xyz ( pose.residue(strand_i.get_start()).xyz("CA") );
700  // TR.Info << "first_xyz : " << first_xyz << endl;
701  // TR.Info << "pose.residue(strand_i.get_start()).xyz(CA) : " << pose.residue(strand_i.get_start()).xyz("CA") << endl;
702 
703  Vector const& second_xyz ( pose.residue(strand_i.get_end()).xyz("CA") );
704  Vector const& third_xyz ( pose.residue(strand_j.get_start()).xyz("CA") );
705  Vector const& fourth_xyz ( pose.residue(strand_j.get_end()).xyz("CA") );
706 
707  // calculates a torsion angles between four atoms of 'CA' of strand "i" and 'CA' of strand "j"
708  Real torsion_i_j = numeric::dihedral_degrees(first_xyz, second_xyz, third_xyz, fourth_xyz);
709  // TR.Info << "torsion_i_j : " << torsion_i_j << endl;
710 
711  return torsion_i_j;
712 
713  }
714 
715  else
716  {
717  //TR.Info << "dis_i_end_and_j_start >= dis_i_end_and_j_end" << endl;
718  Vector const& first_xyz ( pose.residue(strand_i.get_start()).xyz("CA") );
719  Vector const& second_xyz ( pose.residue(strand_i.get_end()).xyz("CA") );
720  Vector const& third_xyz ( pose.residue(strand_j.get_end()).xyz("CA") );
721  Vector const& fourth_xyz ( pose.residue(strand_j.get_start()).xyz("CA") );
722 
723 
724  // calculates a torsion angles between four atoms of 'CA' of strand "i" and 'CA' of strand "j"
725  Real torsion_i_j = numeric::dihedral_degrees(first_xyz, second_xyz, third_xyz, fourth_xyz);
726  //TR.Info << "torsion_i_j : " << torsion_i_j << endl;
727 
728  return torsion_i_j;
729  }
730 
731 } //StrandBundleFeatures::sheet_torsion
732 
733 Real
735  Pose const & pose,
736  StrandFragment strand_i,
737  StrandFragment strand_j
738  ) // calculate shortest distances for each pair
739 {
740  Real temp_shortest_dis = 9999;
741 
742  //TR.Info << "strand_i size : " << strand_i.get_size() << endl;
743  //TR.Info << "strand_i first residue number : " << strand_i.get_start() << endl;
744  //TR.Info << "strand_i ending residue number : " << strand_i.get_end() << endl;
745 
746  //TR.Info << "strand_j size : " << strand_j.get_size() << endl;
747  //TR.Info << "strand_j first residue number : " << strand_j.get_start() << endl;
748  //TR.Info << "strand_j ending residue number : " << strand_j.get_end() << endl;
749 
750 
751  for(Size strand_i_res=0; strand_i_res < strand_i.get_size(); strand_i_res++)
752  {
753  Size i_resnum = strand_i.get_start()+strand_i_res;
754 
755  for(Size strand_j_res=0; strand_j_res < strand_j.get_size(); strand_j_res++)
756  {
757  //TR.Info << "pose.residue_type(i_resnum).all_sc_atoms(): " << pose.residue_type(i_resnum).all_sc_atoms() << endl;
758 
759  Size j_resnum = strand_j.get_start()+strand_j_res;
760 
761  //TR.Info << "i_resnum : " << i_resnum << endl;
762  //TR.Info << "pose.residue_type(i_resnum).name3(): " << pose.residue_type(i_resnum).name3() << endl;
763 
764  //TR.Info << "j_resnum : " << j_resnum << endl;
765  //TR.Info << "pose.residue_type(j_resnum).name3(): " << pose.residue_type(j_resnum).name3() << endl;
766 
767  //TR.Info << "pose.residue(i_resnum).xyz(1): " << pose.residue(i_resnum).xyz(1) << endl;
768  //TR.Info << "pose.residue(i_resnum).xyz(2): " << pose.residue(i_resnum).xyz(2) << endl;
769 
770  //TR.Info << " pose.residue(i_resnum).natoms(): " << pose.residue(i_resnum).natoms() << endl;
771  //TR.Info << " pose.residue(i_resnum).nheavyatoms(): " << pose.residue(i_resnum).nheavyatoms() << endl;
772 
773  //TR.Info << " pose.residue(j_resnum).natoms(): " << pose.residue(j_resnum).natoms() << endl;
774  //TR.Info << " pose.residue(j_resnum).nheavyatoms(): " << pose.residue(j_resnum).nheavyatoms() << endl;
775 
776  for (Size i_AtomNum=1; i_AtomNum < pose.residue(i_resnum).natoms(); i_AtomNum++)
777  {
778 
779  for (Size j_AtomNum=1; j_AtomNum < pose.residue(j_resnum).natoms(); j_AtomNum++)
780  {
781 
782  //TR.Info << "i_AtomNum : " << i_AtomNum << endl;
783  //TR.Info << "j_AtomNum : " << j_AtomNum << endl;
784 
785  //TR.Info << "pose.residue(i_resnum).atom_type_index(i_AtomNum) : " << pose.residue(i_resnum).atom_type_index(i_AtomNum) << endl;
786  //TR.Info << "pose.residue(j_resnum).atom_type_index(j_AtomNum) : " << pose.residue(j_resnum).atom_type_index(j_AtomNum) << endl;
787  Real dis_sc_sc = pose.residue(i_resnum).xyz(i_AtomNum).distance(pose.residue(j_resnum).xyz(j_AtomNum));
788  //TR.Info << "dis_sc_sc: " << dis_sc_sc << endl;
789  if (temp_shortest_dis > dis_sc_sc)
790  {
791  temp_shortest_dis = dis_sc_sc;
792  }
793 
794  }
795 
796  }
797  //TR.Info << "temp_shortest_dis between these sheet pairs until " << pose.residue_type(i_resnum).name3() << i_resnum << " and " << pose.residue_type(j_resnum).name3() << j_resnum << ": " << temp_shortest_dis << endl;
798 
799 
800 // for (Size i_AtomNum=0; pose.residue_type(i_resnum).nheavyatoms(); i_AtomNum++)
801 // {
802  // Real dis_sc_sc = pose.residue_type(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
803 // }
804 
805 
806  /*Real dis_sc_sc = pose.residue(i_resnum).atom("CA").xyz().distance(pose.residue(j_resnum).atom("CA").xyz());
807  TR.Info << "dis_sc_sc (CA): " << dis_sc_sc << endl;
808  if (temp_shortest_dis > dis_sc_sc)
809  temp_shortest_dis = dis_sc_sc;
810 
811  Real dis_sc_sc = pose.residue(i_resnum).atom("C").xyz().distance(pose.residue(j_resnum).atom("C").xyz());
812  TR.Info << "dis_sc_sc (C): " << dis_sc_sc << endl;
813  if (temp_shortest_dis > dis_sc_sc)
814  temp_shortest_dis = dis_sc_sc;*/
815  }
816  }
817 
818  return temp_shortest_dis;
819 
820 } //StrandBundleFeatures::shortest_dis_sidechain
821 
822 
823 Real
825  Real val_shortest_dis_sidechain_1,
826  Real val_shortest_dis_sidechain_2,
827  Real val_shortest_dis_sidechain_3,
828  Real val_shortest_dis_sidechain_4
829  ) // shortest of shortest distances
830 {
831  Real temp_shortest_dis = val_shortest_dis_sidechain_1;
832 
833  if (temp_shortest_dis > val_shortest_dis_sidechain_2)
834  {
835  {
836  temp_shortest_dis = val_shortest_dis_sidechain_2;
837  if (temp_shortest_dis > val_shortest_dis_sidechain_3)
838  {
839  temp_shortest_dis = val_shortest_dis_sidechain_3;
840  if (temp_shortest_dis > val_shortest_dis_sidechain_4)
841  {
842  temp_shortest_dis = val_shortest_dis_sidechain_4;
843  }
844 
845  }
846  else
847  {
848  if (temp_shortest_dis > val_shortest_dis_sidechain_4)
849  {
850  temp_shortest_dis = val_shortest_dis_sidechain_4;
851  }
852  }
853 
854  }
855  }
856 
857  else
858  {
859  if (temp_shortest_dis > val_shortest_dis_sidechain_3)
860  {
861  temp_shortest_dis = val_shortest_dis_sidechain_3;
862  if (temp_shortest_dis > val_shortest_dis_sidechain_4)
863  {
864  temp_shortest_dis = val_shortest_dis_sidechain_4;
865  }
866  }
867  else
868  {
869  if (temp_shortest_dis > val_shortest_dis_sidechain_4)
870  {
871  temp_shortest_dis = val_shortest_dis_sidechain_4;
872  }
873  }
874  }
875 
876  return temp_shortest_dis;
877 
878 } //StrandBundleFeatures::shortest_dis_sidechain (with four parameters)
879 
880 
881 
882 Real
884  Real return_of_check_sheet_dis_antiparallel_1,
885  Real return_of_check_sheet_dis_antiparallel_2,
886  Real return_of_check_sheet_dis_antiparallel_3,
887  Real return_of_check_sheet_dis_antiparallel_4
888  ) // find the shortest distances between strands for Tim's way of finding nearest strand pairs
889 {
890  Real temp_shortest_dis = return_of_check_sheet_dis_antiparallel_1;
891 
892  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_2)
893  {
894  {
895  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_2;
896  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_3)
897  {
898  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_3;
899  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_4)
900  {
901  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_4;
902  }
903 
904  }
905  else
906  {
907  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_4)
908  {
909  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_4;
910  }
911  }
912 
913  }
914  }
915 
916  else
917  {
918  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_3)
919  {
920  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_3;
921  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_4)
922  {
923  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_4;
924  }
925  }
926  else
927  {
928  if (temp_shortest_dis > return_of_check_sheet_dis_antiparallel_4)
929  {
930  temp_shortest_dis = return_of_check_sheet_dis_antiparallel_4;
931  }
932  }
933  }
934 
935  return temp_shortest_dis;
936 
937 } //StrandBundleFeatures::shortest_dis_pairs (to find closer group of strand pairs)
938 
939 
940 ///@brief collect all the feature data for the pose
943  core::pose::Pose const & pose,
944  utility::vector1<bool> const &,
945  boost::uuids::uuid struct_id,
946  utility::sql_database::sessionOP db_session)
947 {
948  TR.Info << "======================= <report_features begin> =========================" << endl;
949 // TR.Info << "pose: " << pose << endl;
950 
951 
952 
953  utility::vector1<StrandFragment> all_strands = get_full_strands(struct_id, db_session);
954  //TR.Info << "--------------- <sql> all strands are read --------------- " << endl;
955 
956  //TR.Info << "all_strands.size(): " << all_strands.size() << endl;
957 
958  // strand pairing begins
959  for(Size i=1; i<all_strands.size(); ++i) // I don't need the last strand since this double for loops are exhaustive search for all pairs of strands
960  {
961 // TR.Info << "i: " << i << endl;
962 // TR.Info << "all_strands[i].get_size(): " << all_strands[i].get_size() << endl;
963 // TR.Info << "all_strands[i].get_start(): " << all_strands[i].get_start() << endl;
964 // TR.Info << "all_strands[i].get_end(): " << all_strands[i].get_end() << endl;
965  if (all_strands[i].get_size() >= min_strand_size_ && all_strands[i].get_size() <= max_strand_size_) // the legnth of this beta strand is between min_strand_size_ and max_strand_size_
966  {
967  for(Size j=i+1; j<=all_strands.size(); ++j) // I need the last strand for this second for loop
968  {
969  // TR.Info << "j: " << j << endl;
970  // TR.Info << "all_strands[j].get_size(): " << all_strands[j].get_size() << endl;
971  if (all_strands[j].get_size() >= min_strand_size_ && all_strands[j].get_size() <= max_strand_size_) // the legnth of this beta strand is between min_strand_size_ and max_strand_size_ too
972  {
973  // TR.Info << "-- both strands are long enough to be considered for strands pairing --" << endl;
974 
975  StrandFragment temp_strand_i(all_strands[i].get_start(), all_strands[i].get_end());
976  StrandFragment temp_strand_j(all_strands[j].get_start(), all_strands[j].get_end());
977 
978  //TR.Info << "-- anti-parallel check between i(" << i << ")'s strand and j(" << j << ")'s strand begins --- " << endl;
979  bool return_of_find_antiparallel = find_antiparallel (pose, temp_strand_i, temp_strand_j);
980  if (return_of_find_antiparallel)
981  {
982 
983  // TR.Info << "!!!!! i(" << i << ") strand and j(" << j << ") strand are antiparallel to each other !!!!! " << endl;
984  // TR.Info << "=========== saving antiparallel strand pairs =========== " << endl;
985  string pair_insert = "INSERT INTO strand_pairs (struct_id, i_strand_residue_start, i_strand_residue_end, j_strand_residue_start, j_strand_residue_end) VALUES (?,?,?,?,?);";
986  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert,db_session));
987  pair_insert_stmt.bind(1,struct_id);
988  pair_insert_stmt.bind(2,all_strands[i].get_start());
989  pair_insert_stmt.bind(3,all_strands[i].get_end());
990  pair_insert_stmt.bind(4,all_strands[j].get_start());
991  pair_insert_stmt.bind(5,all_strands[j].get_end());
992  basic::database::safely_write_to_database(pair_insert_stmt);
993  }
994  else
995  {
996  // TR.Info << "<parallel check between i(" << i << ")'s strand and j(" << j << ")'s strand begins>" << endl;
997  bool return_of_find_parallel = find_parallel (pose, temp_strand_i, temp_strand_j);
998  if (return_of_find_parallel)
999  {
1000 
1001  // TR.Info << "!!!!! i(" << i << ") strand and j(" << j << ") strand are parallel to each other !!!!! " << endl;
1002  // TR.Info << "=========== saving parallel strand pairs =========== " << endl;
1003  string pair_insert = "INSERT INTO strand_pairs (struct_id, i_strand_residue_start, i_strand_residue_end, j_strand_residue_start, j_strand_residue_end) VALUES (?,?,?,?,?);";
1004  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert,db_session));
1005  pair_insert_stmt.bind(1,struct_id);
1006  pair_insert_stmt.bind(2,all_strands[i].get_start());
1007  pair_insert_stmt.bind(3,all_strands[i].get_end());
1008  pair_insert_stmt.bind(4,all_strands[j].get_start());
1009  pair_insert_stmt.bind(5,all_strands[j].get_end());
1010  basic::database::safely_write_to_database(pair_insert_stmt);
1011  }
1012 
1013  }
1014 /* archive to be kept for bool_parallel
1015  TR.Info << "!!!!! i(" << i << ") strand and j(" << j << ") strand are antiparallel to each other !!!!! " << endl;
1016  // TR.Info << "=========== saving antiparallel strand pairs =========== " << endl;
1017  string pair_insert = "INSERT INTO strand_pairs (struct_id, bool_parallel, i_strand_residue_start, i_strand_residue_end, j_strand_residue_start, j_strand_residue_end) VALUES (?,?,?,?,?,?);";
1018  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert,db_session));
1019  pair_insert_stmt.bind(1,struct_id);
1020  pair_insert_stmt.bind(2,"FALSE");
1021  pair_insert_stmt.bind(3,all_strands[i].get_start());
1022  pair_insert_stmt.bind(4,all_strands[i].get_end());
1023  pair_insert_stmt.bind(5,all_strands[j].get_start());
1024  pair_insert_stmt.bind(6,all_strands[j].get_end());
1025  basic::database::safely_write_to_database(pair_insert_stmt);
1026  }
1027  else{
1028  // TR.Info << "-parallel check between i(" << i << ")'s strand and j(" << j << ")'s strand begins- " << endl;
1029  bool return_of_find_parallel = find_parallel (pose, temp_strand_i, temp_strand_j);
1030  if (return_of_find_parallel) {
1031  TR.Info << "!!!!! i(" << i << ") strand and j(" << j << ") strand are parallel to each other !!!!!! " << endl;
1032  // TR.Info << "=========== saving parallel strand pairs =========== " << endl;
1033  string pair_insert = "INSERT INTO strand_pairs (struct_id, bool_parallel, i_strand_residue_start, i_strand_residue_end, j_strand_residue_start, j_strand_residue_end) VALUES (?,?,?,?,?,?);";
1034  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert,db_session));
1035  pair_insert_stmt.bind(1,struct_id);
1036  pair_insert_stmt.bind(2,"TRUE");
1037  pair_insert_stmt.bind(3,all_strands[i].get_start());
1038  pair_insert_stmt.bind(4,all_strands[i].get_end());
1039  pair_insert_stmt.bind(5,all_strands[j].get_start());
1040  pair_insert_stmt.bind(6,all_strands[j].get_end());
1041  basic::database::safely_write_to_database(pair_insert_stmt);
1042  }
1043  }
1044  */
1045  }
1046  }
1047  }
1048  }
1049  TR << "============== (Done) saving pairs of strands ==========" << endl;
1050  // strand pairing ends
1051 
1052  // sheet pairing begins
1053  utility::vector1<StrandFragment> i_strand_from_full_strand_pairs = get_i_strand_from_full_strand_pairs(struct_id, db_session);
1054  //TR.Info << "--------------- <sql> i_strand_from_full_strand_pairs are read --------------- " << endl;
1055 
1056  for(Size ii=1; ii<i_strand_from_full_strand_pairs.size(); ++ii) // I don't need the last pair of strands in this first 'for' loop
1057  {
1058  //TR.Info << "ii: " << ii << endl;
1059  //TR.Info << "i_strand_from_full_strand_pairs[ii].get_size() : " << i_strand_from_full_strand_pairs[ii].get_size() << endl;
1060  //TR.Info << "i_strand_from_full_strand_pairs[ii].get_start(): " << i_strand_from_full_strand_pairs[ii].get_start() << endl;
1061  //TR.Info << "i_strand_from_full_strand_pairs[ii].get_end() : " << i_strand_from_full_strand_pairs[ii].get_end() << endl;
1062 
1063  utility::vector1<StrandFragment> j_strand_from_full_strand_pairs = get_j_strand_from_full_strand_pairs(struct_id, db_session);
1064 
1065  for(Size jj=ii+1; jj<=i_strand_from_full_strand_pairs.size(); ++jj) // I need the last pair of strands in this second 'for' loop
1066  {
1067 
1068  //TR.Info << "jj: " << jj << endl;
1069  //TR.Info << "j_strand_from_full_strand_pairs[jj].get_size() : " << j_strand_from_full_strand_pairs[jj].get_size() << endl;
1070  //TR.Info << "j_strand_from_full_strand_pairs[jj].get_start(): " << j_strand_from_full_strand_pairs[jj].get_start() << endl;
1071  //TR.Info << "j_strand_from_full_strand_pairs[jj].get_end() : " << j_strand_from_full_strand_pairs[jj].get_end() << endl;
1072 
1073  //TR.Info << "<anti-parallel sheet check by distance> begins between " << ii << " th pair of strand_pair (i) and " << jj << " th strand_pair (j)" << endl;
1074 
1075  // all four possible combinations search
1076  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1077  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1078  Real return_of_check_sheet_dis_antiparallel_1 = check_sheet_dis_antiparallel (pose, temp_strand_i, temp_strand_j); // first check of distance between strand i and strand j
1079  if (return_of_check_sheet_dis_antiparallel_1 != -99)
1080  {
1081  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1082  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1083  Real return_of_check_sheet_dis_antiparallel_2 = check_sheet_dis_antiparallel (pose, temp_strand_i, temp_strand_j); // since the first distance between strands is within range, calculate the second distance between strands interchangeably
1084  if (return_of_check_sheet_dis_antiparallel_2 != -99)
1085  {
1086  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1087  StrandFragment temp_strand_j(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1088  Real return_of_check_sheet_dis_antiparallel_3 = check_sheet_dis_antiparallel (pose, temp_strand_i, temp_strand_j); // since the 1st and 2nd distances between strands are within range, calculate the 3rd distance between i strands
1089  if (return_of_check_sheet_dis_antiparallel_3 != -99)
1090  {
1091  StrandFragment temp_strand_i(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1092  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1093  Real return_of_check_sheet_dis_antiparallel_4 = check_sheet_dis_antiparallel (pose, temp_strand_i, temp_strand_j); // since 1st,2nd,3rd distances between strands are within range, calculate the 4th distance between j strands
1094  if (return_of_check_sheet_dis_antiparallel_4 != -99)
1095  {
1096  //TR.Info << "return_of_check_sheet_dis_antiparallel_1~4: " << return_of_check_sheet_dis_antiparallel_1 << ", " << return_of_check_sheet_dis_antiparallel_2 << ", " << return_of_check_sheet_dis_antiparallel_3 << ", " << return_of_check_sheet_dis_antiparallel_4 << endl;
1097  //TR.Info << "<sheet by distance found (by anti-parallel way)> " << ii << " th strand_pair (i) and " << jj << " th strand_pair (j) are within " << min_sheet_dis_ << " Angstrom and " << max_sheet_dis_ << " Angstrom" << endl;
1098 
1099  //TR.Info << "<check sheet by torsion begins (by anti-parallel way)> between " << ii << " th pair of strand_pair (i) and " << jj << " th strand_pair (j)" << endl;
1100 
1101  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1102  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1103  Real sheet_torsion_1 = sheet_torsion(pose, temp_strand_i, temp_strand_j);
1104 
1105  StrandFragment temp_strand_k(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1106  StrandFragment temp_strand_l(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1107  Real sheet_torsion_2 = sheet_torsion(pose, temp_strand_k, temp_strand_l);
1108 
1109  StrandFragment temp_strand_m(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1110  StrandFragment temp_strand_n(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1111  Real sheet_torsion_3 = sheet_torsion(pose, temp_strand_m, temp_strand_n);
1112 
1113  StrandFragment temp_strand_o(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1114  StrandFragment temp_strand_p(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1115  Real sheet_torsion_4 = sheet_torsion(pose, temp_strand_o, temp_strand_p);
1116 
1117  if (sheet_torsion_1 < 0 && sheet_torsion_2 < 0 && sheet_torsion_3 < 0 && sheet_torsion_4 < 0)
1118  {
1119  // TR.Info << "torsions are : " << sheet_torsion_1 << ", " << sheet_torsion_2 << ", " << sheet_torsion_3 << ", " << sheet_torsion_4 << endl;
1120  Real sheet_torsion_avg = (sheet_torsion_1 + sheet_torsion_2 + sheet_torsion_3 + sheet_torsion_4)/4;
1121  // TR.Info << "sheet_torsion_avg (by anti-parallel way) : " << sheet_torsion_avg << endl;
1122 
1123  if (sheet_torsion_avg > min_sheet_torsion_ && sheet_torsion_avg < max_sheet_torsion_)
1124  {
1125 
1126  TR.Info << "<sheet by torsion found (by anti-parallel way)> the average torsion between " << ii << " th strand_pair (i) and " << jj << " th strand_pair (j) is within " << min_sheet_torsion_ << " and " << max_sheet_torsion_ << endl;
1127 
1128  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1129  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1130 
1131  Real val_shortest_dis_sidechain_1 = shortest_dis_sidechain (pose, temp_strand_i, temp_strand_j);
1132  //TR.Info << "one shortest_distance_sidechain_1 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_1 << endl;
1133 
1134 
1135  StrandFragment temp_strand_k(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1136  StrandFragment temp_strand_l(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1137 
1138  Real val_shortest_dis_sidechain_2 = shortest_dis_sidechain (pose, temp_strand_k, temp_strand_l);
1139  //TR.Info << "one shortest_distance_sidechain_2 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_2 << endl;
1140 
1141 
1142  StrandFragment temp_strand_m(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1143  StrandFragment temp_strand_n(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1144 
1145  Real val_shortest_dis_sidechain_3 = shortest_dis_sidechain (pose, temp_strand_m, temp_strand_n);
1146  //TR.Info << "one shortest_distance_sidechain_3 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_3 << endl;
1147 
1148 
1149  StrandFragment temp_strand_o(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1150  StrandFragment temp_strand_p(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1151 
1152  Real val_shortest_dis_sidechain_4 = shortest_dis_sidechain (pose, temp_strand_o, temp_strand_p);
1153  //TR.Info << "one shortest_distance_sidechain_4 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_4 << endl;
1154 
1155 
1156 
1157  Real val_shortest_dis_sidechain = shortest_dis_sidechain(val_shortest_dis_sidechain_1, val_shortest_dis_sidechain_2, val_shortest_dis_sidechain_3, val_shortest_dis_sidechain_4);
1158 
1159  //TR.Info << "the shortest_distance_sidechain between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain << endl;
1160 
1161  //TR.Info << "pose: " << pose << endl;
1162 
1163  //protocols::simple_filters::InterfaceSasaFilter ob_SASA_filter;
1164  //core::pose::Pose non_const_pose = pose;
1165  //ob_SASA_filter.apply(non_const_pose);
1166 
1167 
1168  /* InterfaceAnalyzerMover
1169  //protocols::analysis::InterfaceAnalyzerMover ob_SASA_Mover;
1170  //core::pose::Pose non_const_pose = pose;
1171  //ob_SASA_Mover.apply(non_const_pose);
1172  //TR.Info << "ob_SASA_Mover.get_interface_delta_sasa(): " << ob_SASA_Mover.get_interface_delta_sasa() << endl;
1173  */
1174 
1175  // to find i-i and j-i by calculating distances between pairs
1176  Real val_shortest_dis_pairs = shortest_dis_pairs(return_of_check_sheet_dis_antiparallel_1, return_of_check_sheet_dis_antiparallel_2, return_of_check_sheet_dis_antiparallel_3, return_of_check_sheet_dis_antiparallel_4);
1177 
1178 
1179 
1180  string pair_insert =
1181  "INSERT INTO sheet_pairs (struct_id, g1_strand_1_res_start, g1_strand_1_res_end, g1_strand_2_res_start, g1_strand_2_res_end, g2_strand_1_res_start, g2_strand_1_res_end, g2_strand_2_res_start, g2_strand_2_res_end, shortest_sc_dis) VALUES (?, ?,?,?,?, ?,?,?,?, ?);";
1182  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert, db_session));
1183  pair_insert_stmt.bind(1, struct_id);
1184 
1185  // I need to store closer strands together as a group for Tim's graph based assembly application
1186 
1187  if (val_shortest_dis_pairs == return_of_check_sheet_dis_antiparallel_1) // first check of distance between strand i and strand j
1188  {
1189  { // these two strands should be closer
1190  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1191  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1192  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1193  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1194  }
1195 
1196  { // these two strands should be closer
1197  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1198  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1199  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1200  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1201  }
1202  }
1203 
1204 
1205  else if (val_shortest_dis_pairs == return_of_check_sheet_dis_antiparallel_2) // 2nd check of distance between strand i and strand j
1206  {
1207  { // these two strands should be closer
1208  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1209  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1210  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1211  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1212  }
1213 
1214  { // these two strands should be closer
1215  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1216  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1217  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1218  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1219  }
1220  }
1221 
1222  else if (val_shortest_dis_pairs == return_of_check_sheet_dis_antiparallel_3) // 3rd check of distance between strand i and strand j
1223  {
1224  { // these two strands should be closer
1225  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1226  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1227  pair_insert_stmt.bind(4, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1228  pair_insert_stmt.bind(5, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1229  }
1230 
1231  { // these two strands should be closer
1232  pair_insert_stmt.bind(6, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1233  pair_insert_stmt.bind(7, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1234  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1235  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1236  }
1237  }
1238 
1239  else
1240  {
1241  { // these two strands should be closer
1242  pair_insert_stmt.bind(2, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1243  pair_insert_stmt.bind(3, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1244  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1245  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1246  }
1247 
1248  { // these two strands should be closer
1249  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1250  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1251  pair_insert_stmt.bind(8, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1252  pair_insert_stmt.bind(9, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1253  }
1254  }
1255 
1256 
1257  pair_insert_stmt.bind(10, val_shortest_dis_sidechain);
1258  basic::database::safely_write_to_database(pair_insert_stmt);
1259  }
1260 
1261  /*else
1262  {
1263  TR.Info << "avg torsion angle is not within range " << endl;
1264  }*/
1265 
1266  }
1267  /*else
1268  {
1269  TR.Info << "<check sheet (by anti-parallel way)> not right-handed beta sheet" << endl;
1270  }*/
1271 
1272  }
1273  }
1274  }
1275  }
1276 
1277 
1278 
1279  else // check by parallel way
1280  {
1281  //TR.Info << "<parallel sheet check by distance> begins between " << i << " th pair of strand_pair (i) and " << j << " th strand_pair (j)" << endl;
1282 
1283  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1284  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1285  Real return_of_check_sheet_dis_parallel_1 = check_sheet_dis_parallel (pose, temp_strand_i, temp_strand_j);
1286  if (return_of_check_sheet_dis_parallel_1 != -99)
1287  {
1288  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1289  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1290  Real return_of_check_sheet_dis_parallel_2 = check_sheet_dis_parallel (pose, temp_strand_i, temp_strand_j);
1291  if (return_of_check_sheet_dis_parallel_2 != -99)
1292  {
1293  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1294  StrandFragment temp_strand_j(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1295  Real return_of_check_sheet_dis_parallel_3 = check_sheet_dis_parallel (pose, temp_strand_i, temp_strand_j);
1296  if (return_of_check_sheet_dis_parallel_3 != -99)
1297  {
1298  StrandFragment temp_strand_i(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1299  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1300  Real return_of_check_sheet_dis_parallel_4 = check_sheet_dis_parallel (pose, temp_strand_i, temp_strand_j);
1301  if (return_of_check_sheet_dis_parallel_4 != -99)
1302  {
1303  // TR.Info << "<sheet by distance found (by parallel way)> " << ii << " th strand_pair (i) and " << jj << " th strand_pair (j) are within " << min_sheet_dis_ << " Angstrom and " << max_sheet_dis_ << " Angstrom" << endl;
1304 
1305  // TR.Info << "<check sheet by torsion begins (by parallel way)> between " << ii << " th pair of strand_pair (i) and " << jj << " th strand_pair (j)" << endl;
1306 
1307  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1308  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1309  Real sheet_torsion_1 = sheet_torsion(pose, temp_strand_i, temp_strand_j);
1310 
1311  StrandFragment temp_strand_k(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1312  StrandFragment temp_strand_l(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1313  Real sheet_torsion_2 = sheet_torsion(pose, temp_strand_k, temp_strand_l);
1314 
1315  StrandFragment temp_strand_m(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1316  StrandFragment temp_strand_n(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1317  Real sheet_torsion_3 = sheet_torsion(pose, temp_strand_m, temp_strand_n);
1318 
1319  StrandFragment temp_strand_o(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1320  StrandFragment temp_strand_p(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1321  Real sheet_torsion_4 = sheet_torsion(pose, temp_strand_o, temp_strand_p);
1322 
1323  if (sheet_torsion_1 < 0 && sheet_torsion_2 < 0 && sheet_torsion_3 < 0 && sheet_torsion_4 < 0)
1324  {
1325 
1326 // TR.Info << "torsions are : " << sheet_torsion_1 << ", " << sheet_torsion_2 << ", " << sheet_torsion_3 << ", " << sheet_torsion_4 << endl;
1327  Real sheet_torsion_avg = (sheet_torsion_1 + sheet_torsion_2 + sheet_torsion_3 + sheet_torsion_4)/4;
1328 // TR.Info << "sheet_torsion_avg (by parallel way) : " << sheet_torsion_avg << endl;
1329 
1330  if (sheet_torsion_avg > min_sheet_torsion_ && sheet_torsion_avg < max_sheet_torsion_)
1331  {
1332 
1333  //TR.Info << "<sheet by torsion found (by parallel way)> the average torsion between " << ii << " th strand_pair (i) and " << jj << " th strand_pair (j) is within " << min_sheet_torsion_ << " and " << max_sheet_torsion_ << endl;
1334  StrandFragment temp_strand_i(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1335  StrandFragment temp_strand_j(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1336 
1337  Real val_shortest_dis_sidechain_1 = shortest_dis_sidechain (pose, temp_strand_i, temp_strand_j);
1338  //TR.Info << "one shortest_distance_sidechain_1 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_1 << endl;
1339 
1340 
1341  StrandFragment temp_strand_k(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1342  StrandFragment temp_strand_l(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1343 
1344  Real val_shortest_dis_sidechain_2 = shortest_dis_sidechain (pose, temp_strand_k, temp_strand_l);
1345  //TR.Info << "one shortest_distance_sidechain_2 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_2 << endl;
1346 
1347 
1348  StrandFragment temp_strand_m(i_strand_from_full_strand_pairs[ii].get_start(), i_strand_from_full_strand_pairs[ii].get_end());
1349  StrandFragment temp_strand_n(i_strand_from_full_strand_pairs[jj].get_start(), i_strand_from_full_strand_pairs[jj].get_end());
1350 
1351  Real val_shortest_dis_sidechain_3 = shortest_dis_sidechain (pose, temp_strand_m, temp_strand_n);
1352  //TR.Info << "one shortest_distance_sidechain_3 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_3 << endl;
1353 
1354 
1355  StrandFragment temp_strand_o(j_strand_from_full_strand_pairs[jj].get_start(), j_strand_from_full_strand_pairs[jj].get_end());
1356  StrandFragment temp_strand_p(j_strand_from_full_strand_pairs[ii].get_start(), j_strand_from_full_strand_pairs[ii].get_end());
1357 
1358  Real val_shortest_dis_sidechain_4 = shortest_dis_sidechain (pose, temp_strand_o, temp_strand_p);
1359  //TR.Info << "one shortest_distance_sidechain_4 between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain_4 << endl;
1360 
1361 
1362  Real val_shortest_dis_sidechain = shortest_dis_sidechain(val_shortest_dis_sidechain_1, val_shortest_dis_sidechain_2, val_shortest_dis_sidechain_3, val_shortest_dis_sidechain_4);
1363  //TR.Info << "the shortest_distance_sidechain between " << ii << " th strand_pair and " << jj << " th strand_pair : " << val_shortest_dis_sidechain << endl;
1364 
1365 
1366  // to find i-i and j-i by calculating distances between pairs
1367  Real val_shortest_dis_pairs = shortest_dis_pairs(return_of_check_sheet_dis_parallel_1, return_of_check_sheet_dis_parallel_2, return_of_check_sheet_dis_parallel_3, return_of_check_sheet_dis_parallel_4);
1368 
1369 
1370 
1371  TR.Info << "=========== saving (parallel) sheet pairs =========== " << endl;
1372  string pair_insert =
1373  "INSERT INTO sheet_pairs (struct_id, g1_strand_1_res_start, g1_strand_1_res_end, g1_strand_2_res_start, g1_strand_2_res_end, g2_strand_1_res_start, g2_strand_1_res_end, g2_strand_2_res_start, g2_strand_2_res_end, shortest_sc_dis) VALUES (?, ?,?,?,?, ?,?,?,?, ?);";
1374  statement pair_insert_stmt(basic::database::safely_prepare_statement(pair_insert, db_session));
1375  pair_insert_stmt.bind(1, struct_id);
1376 
1377  // I need to store closer strands together as a group for Tim's graph based assembly application
1378 
1379  if (val_shortest_dis_pairs == return_of_check_sheet_dis_parallel_1) // first check of distance between strand i and strand j
1380  {
1381  { // these two strands should be closer
1382  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1383  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1384  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1385  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1386  }
1387 
1388  { // these two strands should be closer
1389  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1390  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1391  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1392  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1393  }
1394  }
1395 
1396 
1397  else if (val_shortest_dis_pairs == return_of_check_sheet_dis_parallel_2) // 2nd check of distance between strand i and strand j
1398  {
1399  { // these two strands should be closer
1400  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1401  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1402  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1403  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1404  }
1405 
1406  { // these two strands should be closer
1407  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1408  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1409  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1410  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1411  }
1412  }
1413 
1414  else if (val_shortest_dis_pairs == return_of_check_sheet_dis_parallel_3) // 3rd check of distance between strand i and strand j
1415  {
1416  { // these two strands should be closer
1417  pair_insert_stmt.bind(2, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1418  pair_insert_stmt.bind(3, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1419  pair_insert_stmt.bind(4, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1420  pair_insert_stmt.bind(5, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1421  }
1422 
1423  { // these two strands should be closer
1424  pair_insert_stmt.bind(6, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1425  pair_insert_stmt.bind(7, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1426  pair_insert_stmt.bind(8, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1427  pair_insert_stmt.bind(9, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1428  }
1429  }
1430 
1431  else
1432  {
1433  { // these two strands should be closer
1434  pair_insert_stmt.bind(2, j_strand_from_full_strand_pairs[jj].get_start()); // start residue of j-j strand
1435  pair_insert_stmt.bind(3, j_strand_from_full_strand_pairs[jj].get_end()); // end residue of j-j strand
1436  pair_insert_stmt.bind(4, j_strand_from_full_strand_pairs[ii].get_start()); // start residue of j-i strand
1437  pair_insert_stmt.bind(5, j_strand_from_full_strand_pairs[ii].get_end()); // end residue of j-i strand
1438  }
1439 
1440  { // these two strands should be closer
1441  pair_insert_stmt.bind(6, i_strand_from_full_strand_pairs[ii].get_start()); // start residue of i-i strand
1442  pair_insert_stmt.bind(7, i_strand_from_full_strand_pairs[ii].get_end()); // end residue of i-i strand
1443  pair_insert_stmt.bind(8, i_strand_from_full_strand_pairs[jj].get_start()); // start residue of i-j strand
1444  pair_insert_stmt.bind(9, i_strand_from_full_strand_pairs[jj].get_end()); // end residue of i-j strand
1445  }
1446  }
1447 
1448  pair_insert_stmt.bind(10, val_shortest_dis_sidechain);
1449  basic::database::safely_write_to_database(pair_insert_stmt);
1450  }
1451  /*else
1452  {
1453  // TR.Info << "<check sheet (by parallel way)> : avg torsion angle is not within range " << endl;
1454  }*/
1455  }
1456  /*else
1457  {
1458  // TR.Info << "not right-handed beta sheet" << endl;
1459  }*/
1460  }
1461  }
1462  }
1463  }
1464  }
1465  }
1466  }
1467 
1468  TR << "============== (Done) saving \"ideal\" pairs of sheets ==========" << endl;
1469  // sheet pairing ends
1470 
1471  return 0;
1472 } //StrandBundleFeatures::report_features
1473 
1474 
1475 } //namespace strand_assembly
1476 } //namespace features
1477 } //namespace protocols