Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MoveMapBuilder.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 core/pack/task/ResfileReader.cc
11 /// @brief implementation of resfile reader and its command classes
12 /// @author Gordon Lemmon (glemmon@gmail.com), adapted from the ResfileReader code
13 /// by Steven Lewis (smlewi@unc.edu) and Andrew Leaver-Fay
14 
15 // Unit Headers
17 #include <core/pose/util.hh>
19 
20 //Project Headers
23 #include <core/pose/Pose.hh>
24 #include <core/kinematics/Edge.hh>
27 
28 // Utility Headers
29 #include <utility/exit.hh>
30 #include <basic/Tracer.hh>
31 #include <core/types.hh>
32 // AUTO-REMOVED #include <utility/string_util.hh>
33 
34 // Scripter Headers
35 #include <utility/tag/Tag.hh>
36 
37 // Boost Headers
38 #include <boost/foreach.hpp>
39 
42 #include <utility/vector0.hh>
43 #include <utility/excn/Exceptions.hh>
44 #include <utility/vector1.hh>
45 
46 #define foreach BOOST_FOREACH
47 
48 using basic::T;
49 using basic::Error;
50 using basic::Warning;
51 
52 //STL headers
53 
54 namespace protocols {
55 namespace ligand_docking {
56 
57 static basic::Tracer MoveMapBuilder_tracer("protocols.ligand_docking.ligand_options.MoveMapBuilder", basic::t_debug);
58 
59 void
61  core::pose::Pose const & pose, core::kinematics::MoveMapOP movemap,
62  LigandAreas ligand_areas
63 ){
64  foreach(LigandAreas::value_type ligand_area_pair, ligand_areas){
65  char const & chain= ligand_area_pair.first;
67  foreach(core::Size jump_id, jump_ids){
68  movemap->set_jump(jump_id, true);
69  }
70  }
71 }
72 
74  ReferenceCount(),
75  sc_interface_builder_(NULL),
76  bb_interface_builder_(NULL),
77  minimize_water_(false)
78 {}
79 
81  ReferenceCount(),
82  sc_interface_builder_(that.sc_interface_builder_),
83  bb_interface_builder_(that.sc_interface_builder_),
84  minimize_water_(that.minimize_water_)
85 {}
86 
88 
89 //@brief parse XML (specifically in the context of the parser/scripting scheme)
90 void
92  utility::tag::TagPtr const tag,
94 ){
95  if ( tag->hasOption("sc_interface") ){
96  std::string sc_interface_name= tag->getOption<std::string>("sc_interface");
97  sc_interface_builder_= datamap.get< protocols::ligand_docking::InterfaceBuilder * >( "interface_builders", sc_interface_name);
98  }
99  if ( tag->hasOption("bb_interface") ){
100  std::string bb_interface_name= tag->getOption<std::string>("bb_interface");
101  bb_interface_builder_= datamap.get< protocols::ligand_docking::InterfaceBuilder * >( "interface_builders", bb_interface_name);
102  }
103 
104  if ( tag->hasOption("minimize_water") ){
105  if(tag->getOption<std::string>("minimize_water") == "true")
106  minimize_water_= true;
107  else if(tag->getOption<std::string>("minimize_water") != "false")
108  throw utility::excn::EXCN_RosettaScriptsOption("'minimize_water' option is true or false");
109  }
110 }
111 
115 
116  LigandAreas const & ligand_areas1 = sc_interface_builder_->get_ligand_areas();
117  LigandAreas const & ligand_areas2 = sc_interface_builder_->get_ligand_areas();
118 
119  set_jumps(pose, movemap, ligand_areas1);
120  set_jumps(pose, movemap, ligand_areas2);
121 
122  if(sc_interface_builder_) set_all_chi(pose, movemap);
123  if(bb_interface_builder_) set_all_bb(pose, movemap);
124 
125  if( minimize_water_ ) {
126  for(core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i) {
127  if( ! pose.residue(i).has_property("WATER") ) continue;
128  core::kinematics::Edge const & e = pose.fold_tree().get_residue_edge(i);
129  if( ! e.is_jump() ) continue;
130  movemap->set_jump( e.label(), true );
131  MoveMapBuilder_tracer << "Minimize water jump " << e.label() << " to residue " << i << " " << pose.residue_type(i).name3() << std::endl;
132  }
133  }
134  return movemap;
135 }
136 
139  assert( sc_interface_builder_); // does the pointer point
140  return sc_interface_builder_;
141 }
142 
145  assert( bb_interface_builder_); // does the pointer point
146  return bb_interface_builder_;
147 }
148 
149 void
151  core::pose::Pose const & pose,
153 )const{
154  ligand_options::Interface side_chain_interface= sc_interface_builder_->build(pose);
155  MoveMapBuilder_tracer.Debug<< "moveMap interface: "<< side_chain_interface << std::endl;
156  for(core::Size i=1; i <= side_chain_interface.size(); ++i) {
157  if ( side_chain_interface[i].type != ligand_options::InterfaceInfo::non_interface) { // Allow residue to minimize
158  movemap->set_chi(i, true);
159  }
160  }
161  // remove ligands with a minimize_ligand value of zero
162  for ( core::Size chain_id = 1; chain_id <= pose.conformation().num_chains(); ++chain_id){
163  char const chain= core::pose::get_chain_from_chain_id(chain_id, pose);
164  LigandAreas const & ligand_areas= sc_interface_builder_->get_ligand_areas();
165  LigandAreas::const_iterator ligand_area= ligand_areas.find(chain);
166  if(ligand_area == ligand_areas.end()) continue;
167  if(ligand_area->second->minimize_ligand_ > 0) continue;
168  // else if we aren't minimizing the ligand set_chi for this ligand to false
169  core::Size begin = pose.conformation().chain_begin( chain_id);
170  core::Size const end = pose.conformation().chain_end( chain_id );
171  for(; begin <= end; ++begin) movemap->set_chi(begin, false);
172  }
173 }
174 
175 ///@details You MUST call set_all_chi first
176 void
178  core::pose::Pose const & pose,
180 )const{
181  ligand_options::Interface bb_interface = bb_interface_builder_->build(pose);
182 
183  for(core::Size i=1; i <= bb_interface.size(); ++i) {
184  // bb allowed only if sc is allowed.
185  if ( bb_interface[i].type != ligand_options::InterfaceInfo::non_interface
186  && pose.residue(i).is_protein()
187  && movemap->get_chi(i)
188  ) { // Allow residue to minimize
189  movemap->set_bb(i, true);
190  }
191  }
192 }
193 
194 bool
196  return (bool) bb_interface_builder_;
197 }
198 
199 
200 } //namespace ligand_docking
201 } //namespace protocols