Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlacementMinimizationMover.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 sw=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/protein_interface_design/movers/PlacementMinimizationMover.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu)
13 
14 // Unit headers
17 
18 // Package headers
22 
23 // Project headers
24 #include <core/types.hh>
25 #include <core/pose/Pose.hh>
26 #include <utility/tag/Tag.hh>
27 // AUTO-REMOVED #include <protocols/docking/DockingProtocol.hh>
28 
31 
32 #include <protocols/moves/Mover.hh>
35 #include <basic/options/keys/hotspot.OptionKeys.gen.hh>
36 #include <basic/options/option.hh>
37 // Unit Headers
38 
40 #include <core/id/AtomID.hh>
41 #include <core/chemical/AA.hh>
42 #include <numeric/xyzVector.hh>
43 
44 // Unit Headers
46 #include <basic/Tracer.hh>
49 
50 // C++ headers
51 #include <map>
52 #include <boost/foreach.hpp>
53 #define foreach BOOST_FOREACH
54 
56 #include <utility/vector0.hh>
57 #include <utility/vector1.hh>
58 
59 //Auto Headers
62 
63 using namespace protocols::protein_interface_design;
64 
65 static basic::Tracer TR( "protocols.protein_interface_design.movers.PlacementMinimizationMover" );
66 
67 namespace protocols {
68 namespace protein_interface_design {
69 namespace movers {
70 
71 using namespace protocols::moves;
72 using namespace core;
73 
75 PlacementMinimizationMoverCreator::keyname() const
76 {
77  return PlacementMinimizationMoverCreator::mover_name();
78 }
79 
81 PlacementMinimizationMoverCreator::create_mover() const {
82  return new PlacementMinimizationMover;
83 }
84 
86 PlacementMinimizationMoverCreator::mover_name()
87 {
88  return "PlacementMinimization";
89 }
90 
93  return( protocols::moves::MoverOP( new PlacementMinimizationMover( *this ) ) );
94 }
95 
96 void
97 PlacementMinimizationMover::refresh_bbstub_constraints( core::pose::Pose & pose )
98 {
99  using namespace protocols::hotspot_hashing;
100  using namespace core::pack::task;
101  using namespace core::kinematics;
102 
103 //setting up a deflt foldtree for the constraints to work with
104  FoldTree const orig_foldtree( pose.fold_tree() );
105  FoldTree new_ft;
106  new_ft.clear();
107  new_ft.add_edge( pose.conformation().chain_begin( 1 ), pose.conformation().chain_end( 1 ), Edge::PEPTIDE );
108  new_ft.add_edge( pose.conformation().chain_begin( 2 ), pose.conformation().chain_end( 2 ), Edge::PEPTIDE );
109  new_ft.add_edge( pose.conformation().chain_end( 1 ), pose.conformation().chain_begin( 2 ), 1 );
110  new_ft.reorder(1);
111  pose.fold_tree( new_ft );
113  core::Size fixed_res(1);
114  if( host_chain_ == 1 ) fixed_res = pose.total_residue();
115  core::id::AtomID const fixed_atom_id = core::id::AtomID( pose.residue(fixed_res).atom_index("CA"), fixed_res );
116  HotspotStubSetOP all_stubs = new HotspotStubSet;
117  foreach( StubSetStubPos const stubset_pos_pair, stub_sets_ )
118  all_stubs->add_stub_set( *stubset_pos_pair.first );
119 
120  PackerTaskOP restricted_packer_task;
121  if( task_factory() )
122  restricted_packer_task = task_factory()->create_task_and_apply_taskoperations( pose );
123  else
124  restricted_packer_task = TaskFactory::create_packer_task( pose );
125  core::pack::task::PackerTaskOP stub_task = all_stubs->prepare_hashing_packer_task_( pose, host_chain_ );
126  core::Size const host_chain_begin( pose.conformation().chain_begin( host_chain_ ) );
127  core::Size const host_chain_end ( pose.conformation().chain_end ( host_chain_ ) );
128 
129  for( core::Size resi( host_chain_begin ); resi<=host_chain_end; ++resi ){
130  using namespace core::chemical;
131  using namespace basic::options;
132  using namespace basic::options::OptionKeys;
133  if( std::find( prevent_repacking_.begin(), prevent_repacking_.end(), resi ) != prevent_repacking_.end() ||
134  !restricted_packer_task->nonconst_residue_task( resi ).being_packed() )
135  stub_task->nonconst_residue_task( resi ).prevent_repacking();
136  if( (pose.residue( resi ).aa() == aa_gly && !option[hotspot::allow_gly]() ) || ( pose.residue( resi ).aa() == aa_pro && !option[hotspot::allow_proline ] ))
137  stub_task->nonconst_residue_task( resi ).prevent_repacking();
138  }
139 
140  runtime_assert( cb_force_ > -0.000001 );
141  all_stubs->add_hotspot_constraints_to_pose( pose, fixed_atom_id, stub_task, all_stubs, cb_force_, 0/*worst allowed stub bonus*/, false/*apply self energies*/, 10.0/*bump cutoff*/, true/*apply ambiguous constraints*/ );
142 
143  core::scoring::constraints::ConstraintCOPs stub_constraints( pose.add_constraints( all_stubs->constraints() ) );
144  core::Size const constraint_num( stub_constraints.size() );
145  TR<<"adding "<<constraint_num<<" stub constraints to pose"<<std::endl;
146  pose.fold_tree( orig_foldtree );
147 }
148 
149 void
150 PlacementMinimizationMover::apply( core::pose::Pose & pose )
151 {
152  core::pose::Pose const saved_pose( pose ); // the pose should not actually be changed within this function
153 
154  using namespace protocols::hotspot_hashing;
155  using namespace core::scoring;
156 
157  ScoreFunctionOP bbcst_scorefxn( new ScoreFunction );
158  bbcst_scorefxn->reset();
159  bbcst_scorefxn->set_weight( backbone_stub_constraint, 1.0 );
160  (*bbcst_scorefxn)( pose );
161 
162  // Remove old hotspot constraints from pose
164  refresh_bbstub_constraints( pose );
165  // Switch to Ala unless we are doing place scaffold as a replacement for docking
166  BuildAlaPose toAla( host_chain_ == 1/*partner1*/, host_chain_ == 2 /*partner2*/ );
168  if( !prevent_repacking().empty() ) no_repack = prevent_repacking();
169  if( !no_repack.empty() ){
170  std::sort( no_repack.begin(), no_repack.end() );
171  std::unique( no_repack.begin(), no_repack.end() );
172  toAla.prevent_repacking( no_repack );
173  }
174  toAla.task_factory( task_factory() );
175  TR<<"switching interface to alanine\n";
176  toAla.apply( pose );
177 
178  setup_packer_and_movemap( pose ); // for min_sc below
180  //for minimization (rb and sc of previous placed stubs)
181  utility::vector1< bool > const no_min( pose.total_residue(), false );
182 
184  MinimizeInterface( pose, stub_scorefxn, no_min/*bb*/, curr_min_sc_, min_rb(), optimize_foldtree(), no_targets, true/*simultaneous optimization*/);
185  TR.flush();
186 }
187 
188 void
189 PlacementMinimizationMover::cb_force( core::Real const cf )
190 {
191  cb_force_ = cf;
192 }
193 
194 void
195 PlacementMinimizationMover::host_chain( core::Size const hc ){
196  host_chain_ = hc;
197 }
198 
199 void
200 PlacementMinimizationMover::stub_sets( utility::vector1< StubSetStubPos > const & stub_sets ){
201  stub_sets_ = stub_sets;
202 }
203 
204 void
205 PlacementMinimizationMover::parse_my_tag( TagPtr const tag,
206  DataMap &data,
208  Movers_map const &,
209  core::pose::Pose const & pose )
210 {
211  host_chain( tag->getOption<core::Size>( "host_chain", 2 ) );
212  cb_force( tag->getOption< core::Real >( "cb_force", 0.5 ) );
213  utility::vector0< TagPtr > const branch_tags( tag->getTags() );
214 /// PlaceSim calls this parse_my_tag with its own tag, and there, cb_force is
215 /// set within a child tag
216  foreach( TagPtr const btag, branch_tags ){
217  if( btag->hasOption( "cb_force" ) )
218  cb_force( btag->getOption< core::Real >( "cb_force" ) );
219  }
220  runtime_assert( cb_force_ >= -0.000001 );
221  design_partner1_ = host_chain_ == 1 ? true : false;
222  design_partner2_ = host_chain_ == 2 ? true : false;
223  repack_partner1_ = true;
224  repack_partner2_ = true;
225  optimize_foldtree_ = tag->getOption< bool >( "optimize_foldtree", false );
226  min_rb( tag->getOption< bool >( "minimize_rb", 1 ));
227  stub_sets( parse_stub_sets( tag, pose, host_chain_, data ) );
228  runtime_assert( stub_sets_.size() );
229  TR<<"optimize_foldtree set to: "<<optimize_foldtree_<<'\n';
230  TR<<"cb_force is set to "<<cb_force_<<std::endl;
231 }
232 
234 PlacementMinimizationMover::fresh_instance() const {
236 }
237 
238 PlacementMinimizationMover::~PlacementMinimizationMover(){}
239 
240 PlacementMinimizationMover::PlacementMinimizationMover() :
241  simple_moves::DesignRepackMover( PlacementMinimizationMoverCreator::mover_name() ),
242  host_chain_( 2 ),
243  cb_force_( 0.0 )
244 {}
245 
249 }
250 
251 } //movers
252 } //protein_interface_design
253 } //protocols
254