Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FastGapMover.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/loophash/FastGapMover.cc
11 /// @brief
12 /// @author
13 
14 // Unit Headers
16 
17 #include <basic/Tracer.hh>
18 
19 // AUTO-REMOVED #include <basic/options/option.hh>
20 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
21 // AUTO-REMOVED #include <basic/options/keys/cm.OptionKeys.gen.hh>
22 
23 #include <core/pose/Pose.hh>
24 #include <core/io/pdb/pose_io.hh>
25 // AUTO-REMOVED #include <core/pose/util.hh>
26 // AUTO-REMOVED #include <core/pose/PDBInfo.hh>
27 
31 
32 
33 #include <utility/exit.hh>
34 // AUTO-REMOVED #include <utility/file/file_sys_util.hh>
35 
36 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
37 // AUTO-REMOVED #include <core/conformation/util.hh>
38 // AUTO-REMOVED #include <core/chemical/util.hh>
39 // AUTO-REMOVED #include <core/chemical/ResidueTypeSet.hh>
40 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
41 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
44 
45 // C++ headems
46 // AUTO-REMOVED #include <ctime>
47 #include <algorithm>
48 
50 #include <utility/vector1.hh>
51 #include <basic/options/keys/OptionKeys.hh>
52 
53 //Auto Headers
55 #include <core/kinematics/Jump.hh>
56 
57 
58 
59 namespace protocols {
60 namespace loophash {
61 
62 
63 using namespace core;
64 using namespace io;
65 using namespace pdb;
66 using namespace chemical;
67 using namespace conformation;
68 using namespace protocols::loophash;
69 using namespace basic::options;
70 using namespace basic::options::OptionKeys;
71 using namespace utility;
72 
73 using core::pose::PoseOP;
74 using core::pose::PoseAP;
75 using core::pose::Pose;
76 using utility::vector1;
77 using core::Size;
78 using std::string;
79 
80 static basic::Tracer TR( "protocols.loophash.FastGapMover" );
81 
83  Mover("FastGapMover"),
84  min_loop_size_(3),
85  max_loop_size_(14),
86  max_rms_(0.3),
87  min_rms_(0.0),
88  non_ideal_(true)
89  {
90  // initialize lhlibrary
92  for (Size i = min_loop_size_; i<= max_loop_size_; i++ ) {
93  loop_sizes.push_back(i);
94  }
95 
97  lhlibrary_ = new LoopHashLibrary( loop_sizes );
98  lhlibrary_->load_mergeddb();
99 
101 }
102 
103 void
105  lhsampler_->set_max_rms( max_rms_ );
106  lhsampler_->set_nonideal( non_ideal_ );
107  lhsampler_->set_min_rms( min_rms_ );
108 
109  // copy pose
110  PoseOP working_pose = new Pose(pose);
111  //Size idx = 1;
112 
113  // convert pose to centroid pose:
114  if( working_pose->is_fullatom() ){
116  }
117  // Now go through each gap and try increasingly larger lh until something is returned
118  Size next_gap = 0;
119  Real gap_dist;
120  find_next_gap( *working_pose, next_gap, gap_dist );
121  while( next_gap != 0 ) {
122  TR << "Attempting to fix gap following residue " << next_gap << std::endl;
123  std::vector< Pose > lib_structs;
124 
125  // gogo loophash
126  // increase loophash size until we get anything returned
127  //Size loop_size = std::max((Size)(gap_dist/3.5), min_loop_size_); // no point in trying anything that cant reach across the gap
128  Size loop_size = min_loop_size_; // no point in trying anything that cant reach across the gap
129  while( lib_structs.size() == 0 && loop_size < max_loop_size_ ) {
130  TR << "Trying loopsize " << ++loop_size << std::endl;
131  lhsampler_->set_start_res( next_gap + 3 < loop_size ? 0 : next_gap + 3 - loop_size );
132  lhsampler_->set_stop_res ( next_gap );
133  lhsampler_->close_gaps( *working_pose, lib_structs, loop_size );
134  }
135  if( lib_structs.size() != 0 ) {
136  working_pose = new Pose (lib_structs[0]);
137  }
138 
139  find_next_gap( *working_pose, next_gap, gap_dist );
140  }
141  pose = *working_pose;
142 
143 } // apply
144 
145 // lifted straight from protocols/idealize/idealize.cc
146 void
148  // squared distance at which bond is considered discontinuous
149  Real const chain_break_cutoff = { 4.0 };
150  Size const nres ( pose.total_residue() );
151 
152  // find chain breaks to add to gaplist
153  kinematics::FoldTree f( pose.fold_tree() );
154  for ( Size i = idx + 1; i < nres; ++i ) {
155  //bool chain_break = false;
156  Size j = i+1;
157  conformation::Residue const & rsd = pose.residue(i);
158  conformation::Residue const & next_rsd = pose.residue(j);
159  if (rsd.is_polymer() && next_rsd.is_polymer()) {
160  Real dist_squared = rsd.atom( rsd.upper_connect_atom() ).xyz().distance_squared(next_rsd.atom( next_rsd.lower_connect_atom() ).xyz());
161  gap_distance = std::sqrt(dist_squared);
162  if (dist_squared > chain_break_cutoff || dist_squared < 0.1) {
163  //chain_break = true; // set but never used ~Labonte
164  idx = i;
165  return;
166  }
167  }
168  }
169  idx = 0;
170 }
171 string
173  return "FastGapMover";
174 }
175 
176 
177 } // namespace idealize
178 } // namespace protocols