Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
hbs_design.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 
11 //Headers are generally organized by either what they do or where they come from. This organization is first core library headers, then protocols library, then utility stuff.
12 
13 
14 // Project Headers
15 #include <core/pose/Pose.hh>
16 #include <core/pose/util.hh>
17 #include <core/import_pose/import_pose.hh>
18 #include <core/conformation/Conformation.hh>
19 
20 #include <core/pack/task/TaskFactory.hh>
21 #include <core/pack/task/PackerTask.hh>
22 #include <core/pack/task/operation/TaskOperation.hh>
23 #include <core/pack/task/operation/TaskOperations.hh>
24 
25 #include <core/scoring/ScoreFunction.hh>
26 #include <core/scoring/ScoreFunctionFactory.hh>
27 #include <core/scoring/Energies.hh>
28 #include <core/scoring/constraints/util.hh>
29 #include <core/scoring/ScoringManager.hh>
30 
31 #include <core/chemical/VariantType.hh>
32 
33 #include <core/kinematics/FoldTree.hh>
34 #include <core/kinematics/MoveMap.hh>
35 
37 #include <protocols/jd2/JobDistributor.hh>
38 #include <protocols/jd2/Job.hh>
39 
40 // Mover headers
41 #include <protocols/moves/MoverContainer.hh>
42 #include <protocols/moves/TrialMover.hh>
43 #include <protocols/moves/MonteCarlo.hh>
44 #include <protocols/moves/PyMolMover.hh>
45 #include <protocols/moves/RepeatMover.hh>
46 #include <protocols/simple_moves/MinMover.hh>
47 #include <protocols/simple_moves/PackRotamersMover.hh>
48 #include <protocols/simple_moves/RotamerTrialsMover.hh>
49 #include <protocols/simple_moves/TaskAwareMinMover.hh>
50 #include <protocols/simple_moves/BackboneMover.fwd.hh>
51 #include <protocols/simple_moves/BackboneMover.hh>
52 #include <protocols/simple_moves/hbs/HbsPatcher.hh>
53 #include <protocols/rigid/RigidBodyMover.hh>
54 #include <protocols/rigid/RB_geometry.hh>
55 
56 #include <protocols/ncbb/util.hh>
57 
58 // Filter headers
59 #include <basic/MetricValue.hh>
60 #include <core/pose/metrics/CalculatorFactory.hh>
61 //#include <core/pose/metrics/PoseMetricContainer.fwd.hh>
62 #include <core/pose/metrics/simple_calculators/SasaCalculatorLegacy.hh>
63 
64 #include <protocols/toolbox/pose_metric_calculators/NumberHBondsCalculator.hh>
65 #include <protocols/toolbox/pose_metric_calculators/BuriedUnsatisfiedPolarsCalculator.hh>
66 #include <protocols/toolbox/pose_metric_calculators/PackstatCalculator.hh>
67 
68 // Utility Headers
69 #include <devel/init.hh>
70 #include <basic/options/util.hh>
71 #include <basic/options/option.hh>
72 #include <basic/options/keys/out.OptionKeys.gen.hh>
73 #include <basic/options/keys/run.OptionKeys.gen.hh>
74 #include <basic/Tracer.hh>
75 #include <utility/exit.hh>
77 // C++ headers
78 #include <string>
79 #include <sstream>
80 
81 //The original author used a lot of using declarations here. This is a stylistic choice.
82 // Namespaces
83 using namespace core;
84 using namespace conformation;
85 using namespace chemical;
86 using namespace scoring;
87 using namespace pose;
88 using namespace protocols;
89 using namespace protocols::ncbb;
90 using namespace protocols::moves;
91 using namespace protocols::simple_moves;
92 using namespace protocols::simple_moves::hbs;
93 using namespace protocols::rigid;
94 using namespace protocols::toolbox;
95 using namespace protocols::toolbox::pose_metric_calculators;
96 using namespace core::pack::task;
97 using namespace basic::options;
98 using namespace basic::options::OptionKeys;
99 using namespace core::id;
100 using basic::T;
101 using basic::Error;
102 using basic::Warning;
104 
105 
106 // tracer - used to replace cout
107 static THREAD_LOCAL basic::Tracer TR( "HbsDesign" );
108 
109 // application specific options
110 namespace hbs_design {
111 // pert options
112 
113 IntegerOptionKey const pert_num( "hbs_design::pert_num" );
114 IntegerOptionKey const design_loop_num( "hbs_design::design_loop_num" );
115 
116 IntegerVectorOptionKey const hbs_design_positions( "hbs_design::hbs_design_positions" );
117 
118 }
119 
120 class HbsDesignMover : public Mover {
121 
122 public:
123 
124  //default ctor
125  HbsDesignMover(): Mover("HbsDesignMover"){}
126 
127  //default dtor
128  virtual ~HbsDesignMover(){}
129 
130  //methods
131  virtual void apply( core::pose::Pose & pose );
132  virtual std::string get_name() const { return "HbsDesignMover"; }
133 
134 };
135 
136 typedef utility::pointer::shared_ptr< HbsDesignMover > HbsDesignMoverOP;
137 typedef utility::pointer::shared_ptr< HbsDesignMover const > HbsDesignMoverCOP;
138 
139 
140 int
141 main( int argc, char* argv[] )
142 {
143  try{
144  /*********************************************************************************************************************
145  Common Setup
146  **********************************************************************************************************************/
147 
148  // add application specific options to options system
149 
150  option.add( hbs_design::pert_num, "Number of iterations of perturbation loop per design" ).def(10);
151  option.add( hbs_design::design_loop_num, "Number of iterations of pertubation and design" ).def(10);
152 
153  utility::vector1< core::Size > empty_vector(0);
154  option.add( hbs_design::hbs_design_positions, "Positions of hbs to design" ).def( empty_vector );
155 
156  // init command line options
157  //you MUST HAVE THIS CALL near the top of your main function, or your code will crash when you first access the command line options
158  devel::init(argc, argv);
159 
160  //create mover instance
161  HbsDesignMoverOP OD_mover( new HbsDesignMover() );
162 
163  setup_filter_stats();
164 
165  //call job distributor
166  protocols::jd2::JobDistributor::get_instance()->go( OD_mover );
167  } catch ( utility::excn::EXCN_Base const & e ) {
168  std::cout << "caught exception " << e.msg() << std::endl;
169  return -1;
170  }
171 }//main
172 
173 void
176 )
177 {
178  // create score function
179  scoring::ScoreFunctionOP score_fxn( get_score_function() );
180  //scoring::ScoreFunctionOP score_fxn = get_score_function();
181  scoring::constraints::add_fa_constraints_from_cmdline_to_scorefxn(*score_fxn);
182 
183  scoring::constraints::add_fa_constraints_from_cmdline_to_pose(pose);
184 
185  // get a fold tree suitable for docking (local helper function)
186  setup_pert_foldtree( pose );
187 
188  // create a monte carlo object for the full cycle
189  //moves::MonteCarloOP mc( new moves::MonteCarlo( pose, *score_fxn, option[ hbs_design::mc_temp ].value() ) );
190  moves::MonteCarloOP mc( new moves::MonteCarlo( pose, *score_fxn, 1.0 ) );
191 
192  // jump, rot_mag, trans_mag
193  rigid::RigidBodyPerturbMoverOP pert_dock_rbpm( new rigid::RigidBodyPerturbMover(1, 1.0, 0.5 ) );
194 
195  /*********************************************************
196  HBS Setup
197  **********************************************************/
198 
199  // get hbs start and end positions
200  Size pep_start( pose.conformation().chain_begin( 2 ) ); Size pep_end( pose.total_residue() );
201  TR << "hbs_start: " << pep_start << " hbs_end: " << pep_end << std::endl;
202 
203  // create movemap for hbs
204  kinematics::MoveMapOP pert_pep_mm( new kinematics::MoveMap() );
205  pert_pep_mm->set_bb_true_range(pep_start, pep_end);
206 
207  //kdrew: automatically find hbs positions
208  utility::vector1< core::Size > hbs_seq_positions;
209  for ( Size i = 1; i <= pose.total_residue(); ++i ) {
210  if ( pose.residue(i).has_variant_type(chemical::HBS_PRE) == 1 ) {
211  hbs_seq_positions.push_back( i );
212  //kdrew: set up constraints
213  add_hbs_constraint( pose, i );
214  //kdrew: do not use small/shear mover on hbs positions, use hbs mover instead
215  pert_pep_mm->set_bb( i, false );
216 
217  if ( score_fxn->has_zero_weight( core::scoring::atom_pair_constraint ) ) {
218  score_fxn->set_weight( core::scoring::atom_pair_constraint, 1.0 );
219  }
220 
221  }
222  }
223 
224  /*********************************************************
225  Common Setup
226  **********************************************************/
227 
228  // create a random mover to hold the docking, and peptide pertubation movers
229  //kdrew: only doing rigid body for this app
230  moves::RandomMoverOP pert_random( new moves::RandomMover() );
231  pert_random->add_mover( pert_dock_rbpm, 1 );
232 
233  // create a sequence move to hold random and rotamer trials movers
234  moves::SequenceMoverOP pert_sequence( new moves::SequenceMover() );
235  pert_sequence->add_mover( pert_random );
236  //pert_sequence->add_mover( pert_rt);
237 
238  // create a TrialMover for the pertubation
239  moves::TrialMoverOP pert_trial( new moves::TrialMover( pert_sequence, mc ) );
240 
241  /*********************************************************
242  Design Setup
243  **********************************************************/
244 
245  using core::pack::task::operation::TaskOperationCOP;
246  TaskFactoryOP desn_tf( new TaskFactory() );
247  desn_tf->push_back( TaskOperationCOP( new core::pack::task::operation::InitializeFromCommandline ) );
248 
249  /*********************************************************
250  Minimize Setup
251  **********************************************************/
252 
253  // create move map for minimization
254  kinematics::MoveMapOP desn_mm( new kinematics::MoveMap() );
255  //kdrew: set backbone of target false and backbone of hbs true, decide whether to do this or not
256  desn_mm->set_bb( false );
257  desn_mm->set_bb_true_range( pep_start, pep_end );
258  //desn_mm->set_bb( true );
259  desn_mm->set_chi( true );
260  desn_mm->set_jump( 1, true );
261 
262  // create minimization mover
263  simple_moves::MinMoverOP desn_min( new simple_moves::MinMover( desn_mm, score_fxn, option[ OptionKeys::run::min_type ].value(), 0.01, true ) );
264 
265  //definitely want sidechain minimization here
266  using protocols::simple_moves::TaskAwareMinMoverOP;
267  using protocols::simple_moves::TaskAwareMinMover;
268  TaskAwareMinMoverOP desn_ta_min( new TaskAwareMinMover( desn_min, desn_tf ) );
269 
270  /*********************************************************************************************************************
271  Main Loop
272  **********************************************************************************************************************/
273 
274  TR << "Main loop..." << std::endl;
275 
276  ncbb_design_main_loop( Size( option[ hbs_design::design_loop_num ].value() ),
278  pose,
279  pert_trial,
281  pep_start,
282  pep_end,
283  desn_ta_min,
284  score_fxn,
285  mc
286  );
287 
288 
289 
290  TR << "Ending main loop..." << std::endl;
291 
292  TR << "Checking pose energy..." << std::endl;
293  protocols::jd2::JobOP curr_job( protocols::jd2::JobDistributor::get_instance()->current_job() );
294 
295  curr_job->add_string_real_pair( "ENERGY_FINAL ", (*score_fxn)(pose) );
296 
297  calculate_statistics( curr_job, pose, score_fxn );
298 
299 }
300 
301 
#define THREAD_LOCAL
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
Automatic hidden index key for integer options.
static THREAD_LOCAL basic::Tracer TR("HbsDesign")
Non-owning access smart pointer – dispatch class.
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
Size pep_end(0)
core::pose::Pose Pose
Definition: supercharge.cc:101
utility::pointer::shared_ptr< HbsDesignMover const > HbsDesignMoverCOP
Definition: hbs_design.cc:137
virtual std::string get_name() const
Definition: hbs_design.cc:132
File name class supporting Windows and UN*X/Linux format names.
Definition: FileName.hh:37
Tracer & T(std::string const &channel, TracerPriority priority)
T is special function for assign tracer property on the static object.
Definition: Tracer.cc:567
common derived classes for thrown exceptions
IntegerOptionKey const pert_num("hbs_design::pert_num")
member1 value
Definition: Tag.cc:296
Program exit functions and macros.
Tracer & Error(TracerPriority priority=t_error)
Predefined Error tracer.
Definition: Tracer.hh:395
Tracer IO system.
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
IntegerVectorOptionKey const hbs_design_positions("hbs_design::hbs_design_positions")
Tracer & Warning(TracerPriority priority=t_warning)
Predefined Warning tracer.
Definition: Tracer.hh:398
string min_type
Definition: loops_kic.py:76
virtual ~HbsDesignMover()
Definition: hbs_design.cc:128
int main(int argc, char *argv[])
Definition: hbs_design.cc:141
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
virtual void apply(core::pose::Pose &pose)
Definition: hbs_design.cc:174
IntegerOptionKey const design_loop_num("hbs_design::design_loop_num")
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
Definition: Tracer.hh:134
Automatic hidden index key for integer options.
Program options global and initialization function.
platform::Size Size
Definition: random.fwd.hh:30
utility::pointer::shared_ptr< HbsDesignMover > HbsDesignMoverOP
Definition: hbs_design.cc:136
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378