36 #include <numeric/random/random.hh>
37 #include <utility/exit.hh>
38 #include <basic/Tracer.hh>
40 #include <utility/tag/Tag.hh>
52 #include <utility/vector0.hh>
53 #include <utility/vector1.hh>
59 #include <utility/excn/Exceptions.hh>
60 #include <boost/foreach.hpp>
61 #define foreach BOOST_FOREACH
65 namespace ligand_docking {
67 static basic::Tracer
minimize_backbone_tracer(
"protocols.ligand_docking.ligand_options.MinimizeBackbone", basic::t_debug);
83 return "MinimizeBackbone";
87 protocols::moves::Mover(),
92 protocols::moves::Mover(),
93 interface_builder_(interface_builder)
98 protocols::moves::Mover( that ),
99 interface_builder_(that.interface_builder_)
113 return "MinimizeBackbone";
126 if ( tag->getName() !=
"MinimizeBackbone" )
throw utility::excn::EXCN_RosettaScriptsOption(
"This should be impossible");
128 if ( ! tag->hasOption(
"interface") )
throw utility::excn::EXCN_RosettaScriptsOption(
"'HighResDocker' requires 'interface' tag (comma separated chains to dock)");
141 minimize_backbone_tracer.Debug <<
"interface for fold_tree: "<<
interface << std::endl;
154 assert(fold_tree_copy.check_edges_for_atom_info());
155 minimize_backbone_tracer.Debug <<
"Initial foldtree " << fold_tree_copy << std::endl;
157 assert(better_ligand_jumps->check_edges_for_atom_info());
158 minimize_backbone_tracer.Debug <<
"foldtree with ligand jumps from attach pts" << *better_ligand_jumps << std::endl;
160 minimize_backbone_tracer.Debug <<
"foldtree with cutpoints" << *with_cutpoints << std::endl;
161 assert(with_cutpoints->check_edges_for_atom_info());
162 with_cutpoints->delete_extra_vertices();
163 assert(with_cutpoints->check_edges_for_atom_info());
164 minimize_backbone_tracer.Debug <<
"foldtree with less vertices" << *with_cutpoints << std::endl;
165 assert(with_cutpoints->check_edges_for_atom_info());
167 minimize_backbone_tracer.Debug <<
"Final loops foldtree " << *with_cutpoints << std::endl;
168 if (!with_cutpoints->check_fold_tree()) {
169 utility_exit_with_message(
"Invalid fold tree after trying to set up for minimization!");
171 assert(with_cutpoints->check_edges_for_atom_info());
187 utility_exit_with_message(
"Every residue is mobile! We need a non-mobile residue");
197 int new_jump = f->num_jump();
201 edge_itr != f->end();
205 if (!edge_itr->is_polymer()) {
206 f_new->add_edge(*edge_itr);
212 const int e_start = edge_itr->start();
213 const int e_stop = edge_itr->stop();
215 int last_rigid = e_start;
216 for (
Size i = 1; i <= loops.size(); ++i) {
218 int first = std::max(
int(e_start),
int(l.
start() - 1));
219 int last = std::min(
int(e_stop),
int(l.
stop() + 1));
220 if (first != last_rigid) {
230 if (last_rigid !=
int(e_stop)) {
242 static numeric::random::RandomGenerator
my_RG(4376910);
244 utility_exit_with_message(
"Not prepared to deal with backwards fold tree edges!");
253 minimize_backbone_tracer.Debug <<
"start,stop:"<< start <<
','<< stop << std::endl;
254 minimize_backbone_tracer.Debug <<
"edge.start,edge.stop:"<< edge.
start() <<
','<< edge.
stop() << std::endl;
255 runtime_assert( stop >= start );
256 if ((stop - start + 1) < 4) {
257 minimize_backbone_tracer.Debug
258 <<
"WARNING: for backbone minimization to work properly, a stretch of at least 4 residues needs to be allowed to move. Stretch between "
259 << start <<
" and " << stop <<
" is too short. This should never happen after extending the interface"
269 runtime_assert( cut_start <= cut_end );
278 if( static_cast<int>(stop) == edge.
stop())
break;
291 std::map<core::Size, core::Size> jump_to_attach =
find_attach_pts(interface, pose);
298 edge_end = f_const->end();
302 std::map<core::Size, core::Size>::const_iterator
const jump_attach = jump_to_attach.find(e->label());
303 if (jump_attach != jump_to_attach.end()) {
304 core::Size const jump_id = jump_attach->first;
305 core::Size const attach_pt = jump_attach->second;
307 new_fold_tree->add_edge(attach_pt, ligand_residue_id, jump_id);
315 new_fold_tree->add_edge(e->start(), e->stop(), e->start_atom(), e->stop_atom());
317 new_fold_tree->add_edge(e->start(), e->stop(), e->label());
322 if (!new_fold_tree->check_fold_tree())
323 utility_exit_with_message(
"Fold tree did not pass check!");
324 if (!new_fold_tree->check_edges_for_atom_info())
325 utility_exit_with_message(
"Fold tree has chemical edge problems!");
326 if (f_const->nres() != new_fold_tree->nres())
327 utility_exit_with_message(
"Number of residues changed?!");
328 if (f_const->num_jump() != new_fold_tree->num_jump())
329 utility_exit_with_message(
"Number of jumps changed?!");
330 if (!new_fold_tree->connected())
331 utility_exit_with_message(
"Fold tree not connected?!");
332 return new_fold_tree;
341 minimize_backbone_tracer.Debug <<
interface << std::endl;
342 for (
core::Size residue_id = 1; residue_id <= interface.size(); ++residue_id) {
356 char const & ligand_chain= interface[residue_id].chain;
357 std::map<char, LigandAreaOP>
const & ligand_areas=
interface_builder_->get_ligand_areas();
358 std::map<char, LigandAreaOP>::const_iterator found= ligand_areas.find(ligand_chain);
359 assert( found != ligand_areas.end() );
372 minimize_backbone_tracer.Debug <<
"Restraining C-alpha of residue " << residue_id <<
" with "<< ligand_area->Calpha_restraints_<< std::endl;
380 std::map<core::Size, core::Size> jumpToAttach;
381 std::map<char, LigandAreaOP>
const ligand_areas=
interface_builder_->get_ligand_areas();
383 foreach(LigandAreas::value_type ligand_area_pair, ligand_areas){
401 std::map<core::Size, core::Size>
const jump_to_attach
403 std::map<core::Size, core::Size>::const_iterator index =
404 jump_to_attach.begin();
405 std::map<core::Size, core::Size>::const_iterator
const end =
406 jump_to_attach.end();
407 for (; index !=
end; ++index) {
408 int const attach_pt = (
int) index->second;
410 if (start < attach_pt && attach_pt < stop){
411 return index->second;
413 if (stop < attach_pt && attach_pt < start){
414 return index->second;
435 core::Real const new_dist2 = lig_nbr_vector.distance_squared(
437 if (new_dist2 < shortest_dist2) {
438 shortest_dist2 = new_dist2;
451 for(
core::Size i=1; i <= interface.size(); ++i){