Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SheetConstraintsRCG.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/constraints/SheetConstraintsRCG.cc
11 ///
12 /// @brief
13 /// @author Nobuyasu Koga( nobuyasu@uw.edu ) , October 2009
14 /// @modified Tom Linsky (tlinsky@uw.edu), Nov 2012
15 
16 // Unit header
19 
20 // Package headers
23 
24 // Project headers
27 #include <core/id/types.hh>
28 #include <core/pose/Pose.hh>
36 
37 // Utility headers
38 #include <basic/options/option.hh>
39 #include <basic/options/keys/flxbb.OptionKeys.gen.hh>
40 #include <basic/Tracer.hh>
41 #include <utility/tag/Tag.hh>
42 #include <utility/vector1.hh>
43 
44 // C++ headers
45 #include <cmath>
46 
47 static basic::Tracer TR( "protocols.fldsgn.SheetConstraintsRCG" );
48 
49 namespace protocols{
50 namespace fldsgn{
51 
54 {
56 }
57 
60  return new SheetConstraintsRCG();
61 }
62 
65 {
66  return "SheetCstGenerator";
67 }
68 
69 /// @brief
71  RemodelConstraintGenerator(),
72  weight_( 1.0 ),
73  dist_( 5.5 ),
74  angle_tolerance_( 0.35 ),
75  cacb_dihedral_tolerance_( 0.9 ),
76  bb_dihedral_tolerance_( 0.52 ),
77  constrain_dist_only_( false ),
78  blueprint_( NULL )
79 {}
80 
81 /// @ copy constructor
83  RemodelConstraintGenerator( rval ),
84  weight_( rval.weight_ ),
85  dist_( rval.dist_ ),
86  angle_tolerance_( rval.angle_tolerance_ ),
87  cacb_dihedral_tolerance_( rval.cacb_dihedral_tolerance_ ),
88  bb_dihedral_tolerance_( rval.bb_dihedral_tolerance_ ),
89  constrain_dist_only_( rval.constrain_dist_only_ ),
90  blueprint_( rval.blueprint_ )
91 {}
92 
93 /// @brief
95  RemodelConstraintGenerator(),
96  weight_( 1.0 ),
97  dist_( 5.5 ),
98  angle_tolerance_( 0.35 ),
99  cacb_dihedral_tolerance_( 0.9 ),
100  bb_dihedral_tolerance_( 0.52 ),
101  constrain_dist_only_( false ),
102  blueprint_( blue )
103 {}
104 
105 /// @brief value constructor
107  RemodelConstraintGenerator(),
108  weight_( coef ),
109  dist_( 5.5 ),
110  angle_tolerance_( 0.35 ),
111  cacb_dihedral_tolerance_( 0.9 ),
112  bb_dihedral_tolerance_( 0.52 ),
113  constrain_dist_only_( false ),
114  blueprint_( blue )
115 {}
116 
117 /// @brief value constructor
118 SheetConstraintsRCG::SheetConstraintsRCG( BluePrintOP const & blue, Real const coef, Real const dist ):
119  RemodelConstraintGenerator(),
120  weight_( coef ),
121  dist_( dist ),
122  angle_tolerance_( 0.35 ),
123  cacb_dihedral_tolerance_( 0.9 ),
124  bb_dihedral_tolerance_( 0.52 ),
125  constrain_dist_only_( false ),
126  blueprint_( blue )
127 {}
128 
129 /// @brief
131 
132 void
135  protocols::filters::Filters_map const & filters,
136  protocols::moves::Movers_map const & movers,
137  core::pose::Pose const & pose )
138 {
139  RemodelConstraintGenerator::parse_my_tag( tag, data, filters, movers, pose );
140  // for all of these, the default is to not change what is already present in the class
141  set_blueprint( tag->getOption<std::string>( "blueprint", "" ) );
142  set_distance( tag->getOption< core::Real >( "dist", dist_ ) );
143  set_angle_tolerance( tag->getOption< core::Real >( "angle_tolerance", angle_tolerance_ ) );
144  set_cacb_dihedral_tolerance( tag->getOption< core::Real >( "cacb_dihedral_tolerance", cacb_dihedral_tolerance_ ) );
145  set_bb_dihedral_tolerance( tag->getOption< core::Real >( "bb_dihedral_tolerance", bb_dihedral_tolerance_ ) );
146  set_weight( tag->getOption< core::Real >( "weight", weight_ ) );
147  set_constrain_dist_only( tag->getOption< bool >( "constrain_dist_only", constrain_dist_only_ ) );
148 }
149 
152 {
154 }
155 
158 {
159  return new SheetConstraintsRCG();
160 }
161 
164 {
165  return new SheetConstraintsRCG( *this );
166 }
167 
168 
169 /// @brief sets teh blueprint file used for determining proper sheet pairing
170 /// This function will create the blueprint object for you from the file and use it
171 void
173 {
174  if ( blueprint_file == "" ) {
175  utility_exit_with_message( "SheetCstGenerator requires a blueprint file" );
176  }
177  set_blueprint( new protocols::jd2::parser::BluePrint( blueprint_file ) );
178  if ( ! blueprint_ ) {
179  utility_exit_with_message( "SheetCstGenerator tried to read a blueprint file, but failed to create the proper object." );
180  }
181 }
182 
183 /// @brief
184 void
186 {
187  blueprint_ = blue;
188 }
189 
190 /// @brief set weight
191 void
193 {
194  weight_ = coef;
195 }
196 
197 /// @brief set distance of constraint
198 void
200 {
201  dist_ = dist;
202 }
203 
204 
205 /// @brief set the flat-bottom tolerance for the backbone angle between strands for each pair
206 /// This is N1-C1-C2 and N2-C2-C1 for parallel sheets, and N1-C1-N2/N2-C2-N1 for antiparallel.
207 void
209 {
210  angle_tolerance_ = angle_tolerance;
211 }
212 
213 /// @brief set the flat-bottom tolerance for the Cb1-Ca1-Ca2-Cb2 dihedral angle (0 = optimal)
214 void
216 {
217  cacb_dihedral_tolerance_ = dihedral_tolerance;
218 }
219 
220 /// @brief set the flat-bottom tolerance for the backbone dihedrals (0=optimal)
221 /// Dihedral 1 = O1-N1-C1-C2, Dihedral 2 = O2-N2-C2-C1
222 void
224 {
225  bb_dihedral_tolerance_ = dihedral_tolerance;
226 }
227 
228 /// @brief sets whether we should constrain distance only, and not generate dihedral and angle constraints
229 void
230 SheetConstraintsRCG::set_constrain_dist_only( bool const constrain_dist_only )
231 {
232  constrain_dist_only_ = constrain_dist_only;
233 }
234 
235 /// @brief
236 void
238 {
251 
252  // returned data
253  ConstraintOPs csts;
254 
255  // set constraint func
256  core::Real lb( 0.0 );
257  core::Real ub( dist_ );
258  core::Real sd( 1.0 );
259  std::string tag( "constraints_in_beta_sheet" );
260  ScalarWeightedFuncOP cstfunc = new ScalarWeightedFunc( weight_, new BoundFunc( lb, ub, sd, tag ) );
261  // TL Oct '12 add weights to angle/dihedral constraints
262  ScalarWeightedFuncOP cacb_dihedral_func = new ScalarWeightedFunc( weight_, new OffsetPeriodicBoundFunc(-cacb_dihedral_tolerance_,cacb_dihedral_tolerance_, std::sqrt(1.0/42.0), "dihed_cacb", 6.28, 0.0 ) );
263  ScalarWeightedFuncOP bb_dihedral_func = new ScalarWeightedFunc( weight_, new OffsetPeriodicBoundFunc(-bb_dihedral_tolerance_,bb_dihedral_tolerance_, std::sqrt(1.0/42.0), "dihed_bb", 3.14, 0.0 ) );
264  ScalarWeightedFuncOP bb_angle_func = new ScalarWeightedFunc( weight_, new BoundFunc(1.57-angle_tolerance_,1.57+angle_tolerance_, sqrt(1.0/42.0), "angle_bb") );
265 
266  // set constraints to csts
267  core::Size nres( pose.total_residue() );
268  //flo sep '12 in case we have ligands in the pose, don't count them
269  for( core::Size i = nres; i != 0; i-- ){
270  if( pose.residue_type(i).is_ligand() ) {
271  nres--;
272  TR << pose.residue( i ).name3() << i << " = ligand" << std::endl;
273  } else {
274  TR << pose.residue( i ).name3() << i << std::endl;
275  }
276  }
277  runtime_assert( blueprint_ );
278  TR << "Blueprint num res=" << blueprint_->total_residue() << std::endl;
279  TR << "Pose nres protein=" << nres << std::endl;
280  runtime_assert( nres == blueprint_->total_residue() );
281 
282  TR << "Blueprint file is used for determining constrained residue pairs. " << std::endl;
283  TR << "Constrains between CA-CA atoms in sheet are applied for the following residues. " << std::endl;
284  TR << "dist=" << dist_ << ", weight_=" << weight_ << ", cacb_dihedral=" << cacb_dihedral_tolerance_ << ", bb_dihedral=" << bb_dihedral_tolerance_ << ", angle=" << angle_tolerance_ << std::endl;
285 
286  SS_Info2_OP ssinfo = new SS_Info2( pose, blueprint_->secstruct() );
287  StrandPairingSet spairset( blueprint_->strand_pairings(), ssinfo );
288  StrandPairings spairs = spairset.strand_pairings();
289  for ( utility::vector1< StrandPairingOP >::const_iterator it=spairs.begin(); it!=spairs.end(); ++it ) {
290 
291  StrandPairing spair=**it;
292  for( core::Size iaa=spair.begin1(); iaa<=spair.end1(); iaa++ ) {
293  core::Size jaa( spair.residue_pair( iaa ) );
294  TR << iaa << ' ' << jaa << std::endl;
295  core::id::AtomID atom1( pose.residue_type( iaa ).atom_index( "CA" ), iaa );
296  core::id::AtomID atom2( pose.residue_type( jaa ).atom_index( "CA" ), jaa );
297  csts.push_back( new AtomPairConstraint( atom1, atom2, cstfunc ) );
298  //flo sep '12: constrain dihedral, might be more accurate
299  if( ( !constrain_dist_only_ ) ||
300  ( basic::options::option[ basic::options::OptionKeys::flxbb::constraints_sheet_include_cacb_pseudotorsion ].value() ) ){
301  core::id::AtomID resi_n( pose.residue_type( iaa ).atom_index( "N" ), iaa );
302  core::id::AtomID resi_c( pose.residue_type( iaa ).atom_index( "C" ), iaa );
303  core::id::AtomID resi_o( pose.residue_type( iaa ).atom_index( "O" ), iaa );
304  core::id::AtomID resj_n( pose.residue_type( jaa ).atom_index( "N" ), jaa );
305  core::id::AtomID resj_c( pose.residue_type( jaa ).atom_index( "C" ), jaa );
306  core::id::AtomID resj_o( pose.residue_type( jaa ).atom_index( "O" ), jaa );
307  csts.push_back( new core::scoring::constraints::DihedralConstraint( resi_o, resi_n, resi_c, resj_c, bb_dihedral_func ) );
308  csts.push_back( new core::scoring::constraints::DihedralConstraint( resj_o, resj_n, resj_c, resi_c, bb_dihedral_func ) );
309  if( spair.orient() == 'P' ){
310  csts.push_back( new core::scoring::constraints::AngleConstraint( resi_n, resi_c, resj_c, bb_angle_func ) );
311  csts.push_back( new core::scoring::constraints::AngleConstraint( resj_n, resj_c, resi_c, bb_angle_func ) );
312  }
313  else if( spair.orient() == 'A' ){
314  csts.push_back( new core::scoring::constraints::AngleConstraint( resi_n, resi_c, resj_n, bb_angle_func ) );
315  csts.push_back( new core::scoring::constraints::AngleConstraint( resj_n, resj_c, resi_n, bb_angle_func ) );
316  }
317  if( (pose.residue_type( iaa ).name3() == "GLY") || (pose.residue_type( jaa ).name3() == "GLY" ) ) continue; // don't bother restraining cacb dihedral with gly
318  core::id::AtomID resi_cb( pose.residue_type( iaa ).atom_index( "CB" ), iaa );
319  core::id::AtomID resj_cb( pose.residue_type( jaa ).atom_index( "CB" ), jaa );
320  csts.push_back( new core::scoring::constraints::DihedralConstraint( resi_cb, atom1, atom2, resj_cb, cacb_dihedral_func ) );
321  TR << "Added dihedral constraint between residues " << iaa << " and " << jaa << std::endl;
322  }
323  // flo sep '12 over
324  } // for( Size i=1 )
325 
326  } // StrandPairingOP
327  this->add_constraints( csts );
328 } //generate constraints
329 
330 
331 } //namespace fldsgn
332 } //namespace protocols