Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DesignMinimizeHbonds.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/protein_interface_design/movers/DesignMinimizeHbonds.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
14 // Unit headers
17 
18 
26 #include <basic/Tracer.hh>
27 #include <core/pose/Pose.hh>
28 #include <utility/tag/Tag.hh>
29 
30 #include <ObjexxFCL/FArray1D.hh>
31 #include <ObjexxFCL/FArray1D.fwd.hh>
32 
33 #include <utility/vector0.hh>
34 #include <utility/vector1.hh>
35 
36 //Auto Headers
38 
39 
40 
41 namespace protocols {
42 namespace protein_interface_design {
43 namespace movers {
44 
45 using namespace core;
46 using namespace std;
47 using namespace core::scoring;
48 using namespace protocols::moves;
49 
50 static basic::Tracer TR( "protocols.protein_interface_design.movers.DesignMinimizeHbonds" );
51 
54 {
56 }
57 
60  return new DesignMinimizeHbonds;
61 }
62 
65 {
66  return "DesignMinimizeHbonds";
67 }
68 
70  simple_moves::DesignRepackMover( DesignMinimizeHbondsCreator::mover_name() )
71 {
73  optimize_foldtree_ = true;
75 }
76 
78  ScoreFunctionCOP scorefxn_repack, ScoreFunctionCOP scorefxn_minimize,
79  utility::vector1< core::Size > const target_residues,
80  bool const donors,
81  bool const acceptors,
82  bool const bb_hbond,
83  bool const sc_hbond,
84  core::Real const hbond_energy_threshold,
85  core::Real interface_distance_cutoff/*=8.0*/,
86  bool const repack_partner1/*=true*/,
87  bool const repack_partner2/*=false*/,
88  bool const repack_non_ala/* = true*/
89 ) :
90  simple_moves::DesignRepackMover( DesignMinimizeHbondsCreator::mover_name() )
91 {
92  scorefxn_repack_ = scorefxn_repack->clone();
93  scorefxn_minimize_ = scorefxn_minimize->clone();
94  target_residues_ = target_residues;
95  repack_partner1_ = repack_partner1;
96  repack_partner2_ = repack_partner2;
97  donors_ = donors; acceptors_ = acceptors;
98  bb_hbond_ = bb_hbond;
99  sc_hbond_ = sc_hbond;
100  hbond_energy_threshold_ = hbond_energy_threshold;
101  interface_distance_cutoff_ = interface_distance_cutoff;
102  repack_non_ala_ = repack_non_ala;
103  // only requires donors_ || acceptors_ if doing sc hbonding
104  runtime_assert( ( donors_ || acceptors_ ) || ( bb_hbond_ && !sc_hbond_ ) );
105  runtime_assert( bb_hbond || sc_hbond );
106  runtime_assert( hbond_energy_threshold_ <= 0 );
107  runtime_assert (interface_distance_cutoff_ >= 0 );
108 }
109 
111  ScoreFunctionOP scorefxn_repack,
112  ScoreFunctionOP scorefxn_minimize,
113  core::Size const target_residue,
114  bool const donors,
115  bool const acceptors,
116  bool const bb_hbond,
117  bool const sc_hbond,
118  core::Real const hbond_energy_threshold,
119  core::Real interface_distance_cutoff /*=8.0*/,
120  bool const repack_partner1/*=true*/,
121  bool const repack_partner2/*=false*/,
122  bool const repack_non_ala/*=true*/
123 ) :
124  simple_moves::DesignRepackMover( DesignMinimizeHbondsCreator::mover_name() )
125 {
128  target_residues_.push_back( target_residue );
129  bb_hbond_ = bb_hbond;
130  sc_hbond_ = sc_hbond;
131  hbond_energy_threshold_ = hbond_energy_threshold;
132  repack_partner1_ = repack_partner1;
133  repack_partner2_ = repack_partner2;
134  interface_distance_cutoff_ = interface_distance_cutoff;
135  donors_ = donors; acceptors_ = acceptors;
136  repack_non_ala_ = repack_non_ala;
137 }
138 
140 
143  return( protocols::moves::MoverOP( new DesignMinimizeHbonds( *this ) ) );
144 }
145 
146 
147 /// @details Residues within a 10.0 Ang sphere around the set of target residues are designed with acceptors or donors
148 /// (or both) and the design is minimized. All residues that were changed but are not hbonded to the target residues
149 /// are reverted. If only backbone hbonding is desired all residues except PRO, CYS, and GLY are used in design.
150 void
152 {
153  allowed_aas_.assign( chemical::num_canonical_aas, false );
154 
155  if ( bb_hbond_ && !sc_hbond_ ){
156  allowed_aas_[ chemical::aa_ala ] = true;
157  allowed_aas_[ chemical::aa_arg ] = true;
158  allowed_aas_[ chemical::aa_asn ] = true;
159  allowed_aas_[ chemical::aa_asp ] = true;
160  allowed_aas_[ chemical::aa_gln ] = true;
161  allowed_aas_[ chemical::aa_glu ] = true;
162  allowed_aas_[ chemical::aa_his ] = true;
163  allowed_aas_[ chemical::aa_ile ] = true;
164  allowed_aas_[ chemical::aa_leu ] = true;
165  allowed_aas_[ chemical::aa_lys ] = true;
166  allowed_aas_[ chemical::aa_met ] = true;
167  allowed_aas_[ chemical::aa_phe ] = true;
168  allowed_aas_[ chemical::aa_ser ] = true;
169  allowed_aas_[ chemical::aa_thr ] = true;
170  allowed_aas_[ chemical::aa_trp ] = true;
171  allowed_aas_[ chemical::aa_tyr ] = true;
172  allowed_aas_[ chemical::aa_val ] = true;
173  }
174  else{
175  if( donors_ ) {
176  allowed_aas_[ chemical::aa_lys ] = true;
177  allowed_aas_[ chemical::aa_asn ] = true;
178  allowed_aas_[ chemical::aa_gln ] = true;
179  allowed_aas_[ chemical::aa_ser ] = true;
180  allowed_aas_[ chemical::aa_thr ] = true;
181  allowed_aas_[ chemical::aa_trp ] = true;
182  allowed_aas_[ chemical::aa_tyr ] = true;
183  allowed_aas_[ chemical::aa_his ] = true;
184  }
185  if( acceptors_ ) {
186  allowed_aas_[ chemical::aa_asp ] = true;
187  allowed_aas_[ chemical::aa_glu ] = true;
188  allowed_aas_[ chemical::aa_asn ] = true;
189  allowed_aas_[ chemical::aa_gln ] = true;
190  allowed_aas_[ chemical::aa_ser ] = true;
191  allowed_aas_[ chemical::aa_thr ] = true;
192  }
193  }
194  core::Size const rb_jump( 1 );
195 
196  runtime_assert( repack_partner1_ || repack_partner2_ );
197 
198  core::pose::Pose const saved_pose( pose );
199 
200  using ObjexxFCL::FArray1D_bool;
201  FArray1D_bool partner1( pose.total_residue() );
202  pose.fold_tree().partition_by_jump( rb_jump, partner1 ); // partner1 is true for all residues in partner1; false o/w
203 
204  protocols::scoring::Interface interface_obj(rb_jump);
205  interface_obj.distance( interface_distance_cutoff_ ); // to encourage longish residues
206  pose.update_residue_neighbors(); // o/w fails assertion `graph_state_ == GOOD`
207  interface_obj.calculate( pose );
208 
209  setup_packer_and_movemap( pose );
210  // potential hbond partners will later on be reverted if they do not form hbonds
211  std::set< core::Size > potential_hbond_partners;
212  for( core::Size i = 1; i <= pose.total_residue(); ++i ){
213  if( !pose.residue(i).is_protein() ) continue;
214  core::Size const restype( pose.residue(i).aa() );
215  if( (interface_obj.is_interface( i ) && // in interface
216  (partner1( i ) && repack_partner1_ )) || ((!partner1(i) && repack_partner2_) && //designable
217  ( !( !repack_non_ala_ && (restype != chemical::aa_ala) ) || (restype == chemical::aa_pro) || (restype == chemical::aa_gly) || pose.residue(i).type().name() == "CYD" ))) { // design-allowed residues
218  core::conformation::Residue const resi( pose.residue( i ) );
220  target_it!=target_residues_.end(); ++target_it ) {
221  core::conformation::Residue const res_target( pose.residue( *target_it ) );
222 
223  Real const distance( resi.xyz( resi.nbr_atom() ).distance( res_target.xyz( res_target.nbr_atom() ) ) );
224  Real const distance_cutoff( interface_distance_cutoff_ );
225  if ( distance <= distance_cutoff && automatic_repacking_definition_ )
226  potential_hbond_partners.insert( i );
227  }
228  }
229  }
230 
234 
235  { // replace any positions that were mutated but did not hbond with their previous identities
236  std::set< core::Size > hbonded_residues;
238  target_it!=target_residues_.end(); ++target_it ) {
239  std::list< core::Size > new_list( hbonded( pose, *target_it, potential_hbond_partners, bb_hbond_, sc_hbond_,
241  hbonded_residues.insert( new_list.begin(), new_list.end() );
242  }
243 
244  pack::task::PackerTaskOP to_Ala_task( pack::task::TaskFactory::create_packer_task( pose ));
245  for( Size i=1; i<=pose.total_residue(); ++i ) {
246  if( potential_hbond_partners.find( i ) == potential_hbond_partners.end() ) {
247  to_Ala_task->nonconst_residue_task(i).prevent_repacking();
248  continue;
249  }
250  if( hbonded_residues.find( i ) == hbonded_residues.end() ) { // revert
251  TR<<"reverting "<< i <<'\n';
253  revert_type[ saved_pose.residue( i ).aa() ] = true;
254  to_Ala_task->nonconst_residue_task( i ).restrict_absent_canonical_aas( revert_type );
255  }
256  else
257  to_Ala_task->nonconst_residue_task(i).prevent_repacking();
258  }
259  pack::pack_rotamers( pose, *scorefxn_repack_, to_Ala_task );
260  } // end of replace non-hbonded residues scope
261  (*scorefxn_minimize_)( pose );
262  /// Now handled automatically. scorefxn_minimize_->accumulate_residue_total_energies( pose );
264  TR.flush();
265 }
266 
270 }
271 
272 void
273 DesignMinimizeHbonds::parse_my_tag( TagPtr const tag, DataMap & data, protocols::filters::Filters_map const & filters, Movers_map const & movers, core::pose::Pose const & pose )
274 {
275  core::Real const hbond_weight( tag->getOption<core::Real>( "hbond_weight", 3.0 ) );
276  TR<<"DesignMinimizeHbonds with the following parameters: "<<std::endl;
277  donors_ = tag->getOption<bool>( "donors" );
278  acceptors_ = tag->getOption<bool>( "acceptors" );
279  bb_hbond_ = tag->getOption<bool>( "bb_hbond", 0 );
280  sc_hbond_ = tag->getOption<bool>( "sc_hbond", 1 ) ;
281  hbond_energy_threshold_ = tag->getOption<core::Real>( "hbond_energy", -0.5 );
282  interface_distance_cutoff_ = tag->getOption<core::Real>( "interface_cutoff_distance", 8.0 );
283 
284  simple_moves::DesignRepackMover::parse_my_tag( tag, data, filters, movers, pose );
285  using namespace core::scoring;
286 
287  // change the weights on the hbonding terms
288  scorefxn_repack_->set_weight( hbond_lr_bb, hbond_weight );
289  scorefxn_repack_->set_weight( hbond_sr_bb, hbond_weight );
290  scorefxn_repack_->set_weight( hbond_bb_sc, hbond_weight );
291  scorefxn_repack_->set_weight( hbond_sc, hbond_weight );
292 
293  scorefxn_minimize_->set_weight( hbond_lr_bb, hbond_weight );
294  scorefxn_minimize_->set_weight( hbond_sr_bb, hbond_weight );
295  scorefxn_minimize_->set_weight( hbond_bb_sc, hbond_weight );
296  scorefxn_minimize_->set_weight( hbond_sc, hbond_weight );
297 
298  runtime_assert( ( donors_ || acceptors_ ) || ( bb_hbond_ && !sc_hbond_ ) );
299  runtime_assert( bb_hbond_ || sc_hbond_ );
300  runtime_assert( hbond_energy_threshold_ <= 0 );
301  runtime_assert(interface_distance_cutoff_ >= 0 );
302  runtime_assert( target_residues_.size() );
303 
304  if( target_residues_.size() == 0 )
305  TR<<"WARNING WARNING: no target residue defined for hbond design minimize"<<std::endl;
306 }
307 
308 } //movers
309 } //protein_interface_design
310 } //protocols