Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidueVicinityRCG.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/forge/remodel/ResidueVicinityRCG.cc
11 ///
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, april 2009
14 
15 // unit headers
17 
18 
19 //package headers
21 
22 //project headers
23 #include <core/id/AtomID.hh>
24 #include <core/pose/Pose.hh>
30 #include <basic/Tracer.hh>
32 
33 //utility headers
34 #include <utility/tag/Tag.hh>
35 #include <utility/excn/Exceptions.hh>
36 #include <utility/vector1.hh>
37 
38 static basic::Tracer tr( "protocols.forge.remodel.ResidueVicinityRCG" );
39 
40 namespace protocols{
41 namespace forge{
42 namespace remodel{
43 
45  core::Size old_seqpos,
46  utility::vector1< core::Size > const & residue_atoms,
47  utility::vector1< core::Size > const & loopres_atoms,
48  core::Size desired_remodelres_in_vicinity
49 ) :
50  old_seqpos_( old_seqpos ),
51  residue_atoms_( residue_atoms ),
52  loopres_atoms_(loopres_atoms),
53  dis_(NULL),
54  loop_ang_(NULL),
55  targ_ang_(NULL),
56  loop_dih_(NULL),
57  targ_dih_(NULL),
58  lt_dih_(NULL),
59  desired_remodelres_in_vicinity_(desired_remodelres_in_vicinity)
60 {}
61 
63 
66  return dis_; }
67 
70  return loop_ang_; }
71 
74  return targ_ang_; }
75 
78  return loop_dih_; }
79 
82  return targ_dih_; }
83 
86  return lt_dih_; }
87 
88 void
90  dis_ = dis; }
91 
92  void
94  loop_ang_ = loop_ang; }
95 
96  void
98  targ_ang_ = targ_ang; }
99 
100 void
102  loop_dih_ = loop_dih; }
103 
104 void
106  targ_dih_ = targ_dih; }
107 
108 void
110  lt_dih_ = lt_dih; }
111 
112 
113 //ResidueVicinityConstraintsCreator Functions
116 {
117  return new ResidueVicinityRCG();
118 }
119 
122 {
124 }
125 
128 {
129  return "ResidueVicinityCstCreator";
130 }
131 
134  lstart_( 0 ),
135  lstop_( 0 )
136 {}
137 
139  : RemodelConstraintGenerator( rval ),
140  lstart_( rval.lstart_ ),
141  lstop_( rval.lstop_ )
142 {}
143 
145  core::Size lstart,
146  core::Size lstop,
149  lstart_(lstart), lstop_(lstop),
150  rv_infos_(rv_infos)
151 {}
152 
154 
155 void
158  protocols::filters::Filters_map const & filters,
159  protocols::moves::Movers_map const & movers,
160  core::pose::Pose const & pose )
161 {
162  RemodelConstraintGenerator::parse_my_tag( tag, data, filters, movers, pose );
163  lstart( tag->getOption< core::Size >( "lstart", lstart_ ) );
164  if ( lstart_ == 0 ) {
165  throw utility::excn::EXCN_RosettaScriptsOption("lstart must be specified in ResidueVicinityCstGenerator mover");
166  }
167  lstop( tag->getOption< core::Size >( "lstart", lstop_ ) );
168  if ( lstop_ == 0 ) {
169  throw utility::excn::EXCN_RosettaScriptsOption("lstop must be specified in ResidueVicinityCstGenerator mover");
170  }
171 }
172 
175 {
177 }
178 
179 
182 {
183  return new ResidueVicinityRCG();
184 }
185 
188 {
189  return new ResidueVicinityRCG( *this );
190 }
191 
192 /// @brief for every ResidueVicinityInfo (RVI) that this generator has, an AmbiguousConstraint between the
193 /// @brief neighbor atoms of all residues in the remodel region and the RVI are generated.
194 void
196  core::pose::Pose const & pose )
197 {
198 
199  this->clear_constraints();
200 
201  //pose.dump_pdb("remodel_start.pdb"); //debug
202 
203  //std::set< Interval > regions = vlb()->manager().intervals_containing_undefined_positions();
204 
205  core::Size remstart( lstart_ );
206  core::Size remend( lstop_ );
207 
208  if( this->seqmap() ){
209  remstart = (*(this->seqmap() ))[ remstart ];
210  remend = (*(this->seqmap() ))[ remend ];
211  }
212 
213 
214  tr << "setting up constraints for res " << remstart << " to res " << remend << std::endl;
215 
217  rv_it != rv_end; ++rv_it ){
218 
219 
220  //now generate constraints between all nbr atoms of the remodel region positions and all specified atoms
221  //in the rvi. Note: if more than one atom is specified in the rvi, an ambiguous constraint will be
222  //created between all specified atoms and the residue nb atom
224 
225  for( core::Size i = remstart; i <= remend; ++i){
226 
228 
229  generate_remodel_constraints_for_respair(pose, i, *(*rv_it), respair_csts );
230 
231  if( respair_csts.size() == 1 ){
232  rv_csts.push_back( respair_csts[1] );
233  //debug
234  //tr << "respair_cst pushing back single constraint for loopres " << i << " and rvinfo with old seqpos " << (*rv_it)->old_seqpos() << std::endl;
235  }
236 
237  else{
238  rv_csts.push_back( new core::scoring::constraints::AmbiguousConstraint( respair_csts ) );
239  //tr << "respair_cst pushing back ambig constraint for loopres " << i << " and rvinfo with old seqpos " << (*rv_it)->old_seqpos() << " containing " << respair_csts.size() << " members" << std::endl;
240  }
241 
242  } //loop over all residues of the remodel region
243 
244 
245  //and finally add the constraints to the RGC
246  if( (*rv_it)->desired_remodelres_in_vicinity() == 1 ){
248  //debug
249  //tr << "creating ambig constraint of size " << rv_csts.size() << std::endl;
250  }
251 
252  else{
253  this->add_constraint( new protocols::constraints_additional::AmbiguousMultiConstraint( (*rv_it)->desired_remodelres_in_vicinity(), rv_csts ) );
254 
255  //debug
256  //tr << "creating ambig multi constraint of size " << rv_csts.size() << " and n " << (*rv_it)->desired_remodelres_in_vicinity() << std::endl;
257  }
258 
259  } //loop over residue vicinity infos
260 
261 } //generate constraints
262 
263 
264 void
266  core::pose::Pose const & pose,
267  core::Size const loopres,
268  ResidueVicinityInfo const & rv_info,
270 ){
271 
272  using namespace core::scoring::constraints;
273  csts.clear();
274 
275  //core::Size target_pos = ( *(vlb()->manager().sequence_mapping()) )[ rv_info->old_seqpos() ];
276 
277  core::Size target_pos( rv_info.old_seqpos() );
278 
279  if( this->seqmap() ){
280  target_pos = (*(this->seqmap() ))[ target_pos ];
281  }
282 
283  //generate the penalty function for all constraints of this rvi
284 
285  //FuncOP cst_func = new BoundFunc(
286  //rv_info.distance() - rv_info.tolerance(), rv_info.distance() + rv_info.tolerance(), 0.1, "rem_cstfunc" );
287 
288  for( core::Size i =1; i <= rv_info.residue_atoms().size(); ++i ){
289 
290  for( core::Size j =1; j <= rv_info.loopres_atoms().size(); ++j ){
291 
292  //csts.push_back( new AtomPairConstraint( core::id::AtomID( rv_info.loopres_atoms()[j], loopres ),core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), cst_func ) );
293 
295 
296  if( rv_info.dis() ) csts_this_pair.push_back( new AtomPairConstraint( core::id::AtomID( rv_info.loopres_atoms()[j], loopres ),core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), rv_info.dis() ) );
297  //tr << "creating dist constraints between looppos " << loopres << " atom " << pose.residue_type( loopres ).atom_name( rv_info->loopres_atoms()[j] ) << " and targ pos " << target_pos << " atom " << pose.residue_type( target_pos ).atom_name( rv_info->residue_atoms()[i] ) << std::endl;
298 
299  if( rv_info.loop_ang() ){
300  csts_this_pair.push_back( new AngleConstraint( core::id::AtomID( rv_info.loopres_base_atoms()[j], loopres ), core::id::AtomID( rv_info.loopres_atoms()[j], loopres ), core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), rv_info.loop_ang() ) );
301 
302  //tr << "creating loop ang constraints between looppos " << loopres << " base atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_base_atoms()[j] ) << ", atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_atoms()[j] ) << " and targ pos " << target_pos << " atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_atoms()[i] ) << std::endl;
303  }
304 
305  if( rv_info.targ_ang() ){
306  csts_this_pair.push_back( new AngleConstraint( core::id::AtomID( rv_info.loopres_atoms()[j], loopres ), core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), core::id::AtomID( rv_info.residue_base_atoms()[i], target_pos ), rv_info.targ_ang() ) );
307 
308  //tr << "creating targ ang constraints between looppos " << loopres << " atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_atoms()[j] ) << ",targ atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_atoms()[i] ) << " and targ pos " << target_pos << "base atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_base_atoms()[i] ) << std::endl;
309  }
310 
311  if( rv_info.loop_dih() ){
312  csts_this_pair.push_back( new DihedralConstraint( core::id::AtomID( rv_info.loopres_base2_atoms()[j], loopres ), core::id::AtomID( rv_info.loopres_base_atoms()[j], loopres ), core::id::AtomID( rv_info.loopres_atoms()[j], loopres ), core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), rv_info.loop_dih() ) );
313 
314  //tr << "creating loop dih constraints between looppos " << loopres << " base2 atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_base2_atoms()[j] )<< ", base atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_base_atoms()[j] ) << ", atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_atoms()[j] ) << " and targ pos " << target_pos << " atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_atoms()[i] ) << std::endl;
315  }
316 
317  if( rv_info.targ_dih() ){
318  csts_this_pair.push_back( new DihedralConstraint( core::id::AtomID( rv_info.loopres_atoms()[j], loopres ), core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), core::id::AtomID( rv_info.residue_base_atoms()[i], target_pos ), core::id::AtomID( rv_info.residue_base2_atoms()[i], target_pos ), rv_info.targ_dih() ) );
319  //tr << "creating targ dih constraints between looppos " << loopres << " atom " << pose.residue_type( loopres ).atom_name( rv_info.loopres_atoms()[j] ) << ",targ atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_atoms()[i] ) << " and targ pos " << target_pos << " base atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_base_atoms()[i] ) << ", base 2 atom " << pose.residue_type( target_pos ).atom_name( rv_info.residue_base2_atoms()[i] )<< std::endl;
320  }
321 
322  if( rv_info.lt_dih() ){
323  csts_this_pair.push_back( new DihedralConstraint( core::id::AtomID( rv_info.loopres_base_atoms()[j], loopres ), core::id::AtomID( rv_info.loopres_atoms()[j], loopres ), core::id::AtomID( rv_info.residue_atoms()[i], target_pos ), core::id::AtomID( rv_info.residue_base_atoms()[i], target_pos ), rv_info.lt_dih() ) );
324  }
325 
326  if( csts_this_pair.size() == 1 ) csts.push_back( csts_this_pair[1] );
327  else if( csts_this_pair.size() > 1 ) csts.push_back( new MultiConstraint( csts_this_pair ) );
328 
329  //debug
330  //lil stupid: we only need the pose in this function for the debug info
331  //but i don't feel like changing headers for debug at the moment,
332  //so let's do some call to a pose function to prevent the compiler warning
333  pose.total_residue();
334 
335  } //loop over loopres residue atoms
336 
337  } //loop over targ residue atoms
338 
339 }
340 
341 void
343 {
344  lstart_ = lstart;
345 }
346 
347 void
349 {
350  lstop_ = lstop;
351 }
352 
353 void
355 {
356  rv_infos_ = rv_infos;
357 }
358 
359 
360 } //namespace remodel
361 } //namespace forge
362 } //namespace protocols