Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SetSecStructEnergies.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/fldsgn/potentials/SetSecStructEnergy.cc
11 /// @brief mover for setting centroid score of secondary structure through parser
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // unit headers
17 
18 // package headers
19 #include <basic/options/option.hh>
20 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
21 #include <basic/Tracer.hh>
24 //#include <core/conformation/symmetry/util.hh>
25 #include <core/pose/Pose.hh>
39 
42 
43 #include <utility/tag/Tag.hh>
44 // C++ headers
45 #include <utility>
46 
47 // boost
48 // AUTO-REMOVED #include <boost/lexical_cast.hpp>
49 
51 #include <utility/vector0.hh>
52 #include <utility/vector1.hh>
53 
54 
55 
56 namespace protocols {
57 namespace fldsgn {
58 namespace potentials {
59 
60 static basic::Tracer TR( "protocols.fldsgn.SetSecStructEnergies" );
61 
64 {
66 }
67 
70  return new SetSecStructEnergies;
71 }
72 
75 {
76  return "SetSecStructEnergies";
77 }
78 
79 
80 /// @brief default constructor
82  Super( "SetSecStructEnergies" ),
83  loaded_( false ),
84  blueprint_( NULL ),
85  ss_from_blueprint_( true ),
86  sfx_( NULL ),
87  hh_weight_( 1.0 ),
88  hs_weight_( 1.0 ),
89  ss_weight_( 1.0 ),
90  stwist_weight_( 1.0 ),
91  hs_pair_weight_( 0.0 ),
92  ss_pair_weight_( 0.0 ),
93  rsigma_weight_( 0.0 ),
94  hpairpot_( new NatbiasHelixPairPotential ),
95  hspot_( new NatbiasHelicesSheetPotential )
96 {}
97 
98 
99 /// @brief value constructor
100 SetSecStructEnergies::SetSecStructEnergies( ScoreFunctionOP const sfx, String const & filename, bool const ss_from_blueprint ) :
101  Super( "SetSecStructEnergies" ),
102  loaded_( false ),
103  ss_from_blueprint_( ss_from_blueprint ),
104  sfx_( sfx ),
105  hh_weight_( 1.0 ),
106  hs_weight_( 1.0 ),
107  ss_weight_( 1.0 ),
108  stwist_weight_( 1.0 ),
109  hs_pair_weight_( 0.0 ),
110  ss_pair_weight_( 0.0 ),
111  rsigma_weight_( 0.0 ),
112  hpairpot_( new NatbiasHelixPairPotential ),
113  hspot_( new NatbiasHelicesSheetPotential )
114 {
115  set_blueprint( filename );
116 }
117 
118 /// @brief value constructor
119 SetSecStructEnergies::SetSecStructEnergies( ScoreFunctionOP const sfx, BluePrintOP const blueprintOP, bool const ss_from_blueprint ) :
120  Super( "SetSecStructEnergies" ),
121  loaded_( false ),
122  blueprint_( blueprintOP ),
123  ss_from_blueprint_( ss_from_blueprint ),
124  sfx_( sfx ),
125  hh_weight_( 1.0 ),
126  hs_weight_( 1.0 ),
127  ss_weight_( 1.0 ),
128  stwist_weight_( 1.0 ),
129  hs_pair_weight_( 0.0 ),
130  ss_pair_weight_( 0.0 ),
131  rsigma_weight_( 0.0 ),
132  hpairpot_( new NatbiasHelixPairPotential ),
133  hspot_( new NatbiasHelicesSheetPotential )
134 {}
135 
136 /// @Brief copy constructor
138  Super( rval ),
139  loaded_( rval.loaded_ ),
140  blueprint_( rval.blueprint_ ),
141  ss_from_blueprint_( rval.ss_from_blueprint_ ),
142  sfx_( rval.sfx_ ),
143  hh_weight_( rval.hh_weight_ ),
144  hs_weight_( rval.hs_weight_ ),
145  ss_weight_( rval.ss_weight_ ),
146  stwist_weight_( rval.stwist_weight_ ),
147  hs_pair_weight_( rval.hs_pair_weight_ ),
148  ss_pair_weight_( rval.ss_pair_weight_ ),
149  rsigma_weight_( rval.rsigma_weight_ ),
150  hpairpot_( rval.hpairpot_ ),
151  hspot_( rval.hspot_ )
152 {}
153 
154 /// @brief default destructor
156 
157 /// @brief clone this object
160 {
161  return new SetSecStructEnergies( *this );
162 }
163 
164 /// @brief create this type of object
167 {
168  return new SetSecStructEnergies();
169 }
170 
171 /// @brief set the centroid level score function
172 void
174 {
175  sfx_ = sfx.clone();
176 }
177 
178 /// @brief set the centroid level score function
179 void
181 {
182  sfx_ = sfx->clone();
183 }
184 
185 /// @brief use blueprint
186 void
188 {
189  blueprint_ = new BluePrint( filename );
190 }
191 
192 /// @brief use blueprint
193 void
195 {
196  blueprint_ = blp;
197 }
198 
199 /// @brief make symmetric secstruct
202 {
203  runtime_assert( ss.length() == syminfo->num_independent_residues() );
204 
205  String secstruct("");
206  for( Size i=1; i<= syminfo->subunits(); i++ ) {
207  secstruct += ss;
208  }
209  for( Size i=1; i<=syminfo->num_virtuals(); i++ ) {
210  secstruct += "L";
211  }
212 
213  return secstruct;
214 }
215 
216 /// @brief apply defined moves to given Pose
218 {
219  using namespace basic::options;
220  using namespace basic::options::OptionKeys;
221 
227 
230 
233 
242 
247 
248  if( loaded_ ) return;
249 
250  runtime_assert( blueprint_ );
251  runtime_assert( sfx_ );
252 
253  // assign secondary structure
254  if( !ss_from_blueprint_ ){
255  Dssp dssp( pose );
256  dssp.insert_ss_into_pose( pose );
257  }else{
258  blueprint_->insert_ss_into_pose( pose );
259  }
260 
261  Pose scratch( pose );
262  String ss("");
263  if( option[ basic::options::OptionKeys::symmetry::symmetry_definition ].active() ) {
264 
265  if ( !is_symmetric( scratch ) ) {
266  SetupForSymmetryMoverOP symm_setup_mover = new SetupForSymmetryMover;
267  symm_setup_mover->apply( scratch );
268  }
269 
270  SymmetricConformation & symm_conf ( dynamic_cast<SymmetricConformation & > ( scratch.conformation()) );
271  SymmetryInfoOP syminfo( symm_conf.Symmetry_Info() );
272  ss = symmetric_secstruct( syminfo, blueprint_->secstruct() );
273 
274  } else {
275  ss = blueprint_->secstruct();
276  }
277 
278  // set NatbiasSecondaryStructure energy
279  SS_Info2_OP ssinfo = new SS_Info2( ss );
280  StrandPairingSetOP spairset = new StrandPairingSet( blueprint_->strand_pairings(), ssinfo );
281  HelixPairingSetOP hpairset = new HelixPairingSet ( blueprint_->helix_pairings() );
282  HSSTripletSetOP hss3set = new HSSTripletSet ( blueprint_->hss_triplets() );
283 
284  NatbiasSecondaryStructureEnergy sspot;
285  NatbiasStrandPairPotentialOP spairpot = new NatbiasStrandPairPotential( spairset );
286  hpairpot_->set_hpairset( hpairset );
287  hpairpot_->show_params();
288 
289  hspot_->hss_triplet_set( hss3set );
290  hspot_->show_params();
291 
292  sspot.native_secstruct( ss );
293  if( ss_weight_ != 0.0 ) sspot.set_natbias_spairpot( spairpot );
294  if( hs_weight_ != 0.0 ) sspot.set_natbias_helices_sheet_pot( hspot_ );
295  if( hh_weight_ != 0.0 ) sspot.set_natbias_hpairpot( hpairpot_ );
296 
297  // turn Original SecondaryStructureEnergy off
298  std::map< ScoreType, Real > new_weights;
299  new_weights.insert( std::map< ScoreType, Real >::value_type( core::scoring::natbias_hs, hs_weight_ ) );
300  new_weights.insert( std::map< ScoreType, Real >::value_type( core::scoring::natbias_ss, ss_weight_ ) );
301  new_weights.insert( std::map< ScoreType, Real >::value_type( core::scoring::natbias_hh, hh_weight_ ) );
302  new_weights.insert( std::map< ScoreType, Real >::value_type( core::scoring::natbias_stwist, stwist_weight_ ) );
303  sfx_->add_extra_method( new_weights, sspot );
304 
306  if( hs_pair_weight_ <= 0.0 ) {
307  TR << "original hs_pair term was turned off." << std::endl;
308  }
309 
311  if( ss_pair_weight_ <= 0.0 ) {
312  TR << "original ss_pair term was turned off." << std::endl;
313  }
314 
315  sfx_->set_weight( core::scoring::rsigma, rsigma_weight_ );
316  if( rsigma_weight_ <= 0.0 ) {
317  TR << "original rsigma term was turned off." << std::endl;
318  }
319 
320  // this mover have to be called only once
321  loaded_ = true;
322 
323 }
324 
325 /// @brief
329 }
330 
331 
332 /// @brief parse xml
333 void
335  TagPtr const tag,
336  DataMap & data,
337  Filters_map const &,
338  Movers_map const &,
339  Pose const & )
340 {
341  std::string const blueprint( tag->getOption<std::string>( "blueprint", "" ) );
342  if( blueprint == "" ){
343  TR << "No input of blueprint file ! " << std::endl;
344  runtime_assert( false );
345  }
346  set_blueprint( blueprint );
347 
348  bool const ss_from_blueprint( tag->getOption<bool>( "ss_from_blueprint", true ) );
350 
351  // set scorefxn
352  String const sfxn ( tag->getOption<String>( "scorefxn", "" ) );
353  if( sfxn == "" ) {
354  TR << "[ERROR] No input of scorefxn !" << std::endl;
355  runtime_assert( false );
356  }
357 
358  sfx_ = data.get< ScoreFunction * >( "scorefxns", sfxn );
359  TR << "score function, " << sfxn << ", is used. " << std::endl;
360 
361  ///
362  if( tag->hasOption( "natbias_ss" ) ) ss_weight_ = tag->getOption< Real >( "natbias_ss" );
363  if( tag->hasOption( "natbias_hh" ) ) hh_weight_ = tag->getOption< Real >( "natbias_hh" );
364  if( tag->hasOption( "natbias_hs" ) ) hs_weight_ = tag->getOption< Real >( "natbias_hs" );
365  if( tag->hasOption( "natbias_stwist" ) ) stwist_weight_ = tag->getOption< Real >( "natbias_stwist" );
366 
367  /// original secondary structure potential except for sheet potential
368  if( tag->hasOption( "hs_pair" ) ) hs_pair_weight_ = tag->getOption< Real >( "hs_pair" );
369  if( tag->hasOption( "ss_pair" ) ) ss_pair_weight_ = tag->getOption< Real >( "ss_pair" );
370  if( tag->hasOption( "rsigma" ) ) rsigma_weight_ = tag->getOption< Real >( "rsigma" );
371 
372  // params for NatbiasHelixPairPotential
373  if( tag->hasOption( "hh_dist_wts" ) ) {
374  hpairpot_->set_dist_wts( tag->getOption< Real >( "hh_dist_wts" ) );
375  }
376  if( tag->hasOption( "hh_dist" ) ) {
377  hpairpot_->set_dist( tag->getOption< Real >( "hh_dist" ) );
378  }
379  if( tag->hasOption( "hh_dist_s2" ) ) {
380  hpairpot_->set_dist_sigma2( tag->getOption< Real >( "hh_dist_s2" ) );
381  }
382 
383  if( tag->hasOption( "hh_cross_angle_wts" ) ) {
384  hpairpot_->set_angle_wts( tag->getOption< Real >( "hh_cross_angle_wts" ) );
385  }
386  if( tag->hasOption( "hh_cross_angle" ) ) {
387  hpairpot_->set_angle( tag->getOption< Real >( "hh_cross_angle" ) );
388  }
389  if( tag->hasOption( "hh_cross_angle_s2" ) ) {
390  hpairpot_->set_angle_sigma2( tag->getOption< Real >( "hh_cross_angle_s2" ) );
391  }
392 
393  // params for NatbiasHelicesSheetPotential
394  if( tag->hasOption( "hs_atr_dist_wts" ) ) {
395  hspot_->set_hs_atr_dist_wts( tag->getOption< Real >( "hs_atr_dist_wts" ) );
396  }
397  if( tag->hasOption( "hs_atr_dist" ) ) {
398  hspot_->set_hs_atr_dist( tag->getOption< Real >( "hs_atr_dist" ) );
399  }
400  if( tag->hasOption( "hs_atr_dist_s2" ) ) {
401  hspot_->set_hs_atr_dist_sigma2( tag->getOption< Real >( "hs_atr_dist_s2" ) );
402  }
403 
404  if( tag->hasOption( "hs_angle_wts" ) ) {
405  hspot_->set_hs_angle_wts( tag->getOption< Real >( "hs_angle_wts" ) );
406  }
407  if( tag->hasOption( "hs_angle" ) ) {
408  hspot_->set_hs_angle( tag->getOption< Real >( "hs_angle" ) );
409  }
410  if( tag->hasOption( "hs_angle_s2") ) {
411  hspot_->set_hs_angle_sigma2( tag->getOption< Real >( "hs_angle_s2" ) );
412  }
413 
414  if( tag->hasOption( "hsheet_repl_dist" ) ) {
415  hspot_->set_hsheet_repl_dist( tag->getOption< Real >( "hsheet_repl_dist" ) );
416  }
417 
418  if( tag->hasOption( "hh_align_angle_wts" ) ) {
419  hspot_->set_hh_angle_wts( tag->getOption< Real >( "hh_align_angle_wts" ) );
420  }
421  if( tag->hasOption( "hh_align_angle" ) ) {
422  hspot_->set_hh_angle( tag->getOption< Real >( "hh_align_angle" ) );
423  }
424  if( tag->hasOption( "hh_align_angle_s2" ) ) {
425  hspot_->set_hh_angle_sigma2( tag->getOption< Real >( "hh_align_angle_s2" ) );
426  }
427 
428 }
429 
430 } // Namespace potentials
431 } // namespace fldsgn
432 } // namespace protocols