Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
peptoid_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 // based on code from mini/src/apps/public/scenarios/doug_dock_design_min_mod2_cal_cal.cc
12 // and https://svn.rosettacommons.org/source/branches/releases/rosetta-3.1/manual/advanced/example_protocol.cc
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 #include <core/chemical/ResidueTypeSet.hh>
33 #include <core/chemical/ResidueTypeFinder.hh>
34 #include <core/chemical/ChemicalManager.hh>
35 
36 #include <core/kinematics/FoldTree.hh>
37 #include <core/kinematics/MoveMap.hh>
38 
40 #include <protocols/jd2/JobDistributor.hh>
41 #include <protocols/jd2/Job.hh>
42 
43 // Mover headers
44 #include <protocols/moves/MoverContainer.hh>
45 #include <protocols/moves/TrialMover.hh>
46 #include <protocols/moves/MonteCarlo.hh>
47 #include <protocols/moves/PyMolMover.hh>
48 #include <protocols/moves/RepeatMover.hh>
49 #include <protocols/simple_moves/MinMover.hh>
50 #include <protocols/simple_moves/PackRotamersMover.hh>
51 #include <protocols/simple_moves/RotamerTrialsMover.hh>
52 #include <protocols/simple_moves/TaskAwareMinMover.hh>
53 #include <protocols/simple_moves/BackboneMover.fwd.hh>
54 #include <protocols/simple_moves/BackboneMover.hh>
55 #include <protocols/simple_moves/RandomTorsionMover.hh>
56 #include <protocols/simple_moves/RandomOmegaFlipMover.hh>
57 #include <protocols/simple_moves/CyclizationMover.hh>
58 #include <protocols/rigid/RigidBodyMover.hh>
59 #include <protocols/rigid/RB_geometry.hh>
60 
61 #include <protocols/ncbb/util.hh>
62 
63 // Filter headers
64 #include <basic/MetricValue.hh>
65 #include <core/pose/metrics/CalculatorFactory.hh>
66 //#include <core/pose/metrics/PoseMetricContainer.fwd.hh>
67 #include <core/pose/metrics/simple_calculators/SasaCalculatorLegacy.hh>
68 
69 #include <protocols/toolbox/pose_metric_calculators/NumberHBondsCalculator.hh>
70 #include <protocols/toolbox/pose_metric_calculators/BuriedUnsatisfiedPolarsCalculator.hh>
71 #include <protocols/toolbox/pose_metric_calculators/PackstatCalculator.hh>
72 
73 // Utility Headers
74 #include <devel/init.hh>
75 #include <basic/options/util.hh>
76 #include <basic/options/option.hh>
77 #include <basic/options/keys/out.OptionKeys.gen.hh>
78 #include <basic/options/keys/run.OptionKeys.gen.hh>
79 #include <basic/Tracer.hh>
80 #include <utility/exit.hh>
81 
82 // C++ headers
83 #include <string>
84 #include <sstream>
85 
86 // DEBUG DEBUG
87 #include <protocols/moves/PyMolMover.hh>
88 
89 
90 // Namespaces
91 using namespace core;
92 using namespace conformation;
93 using namespace chemical;
94 using namespace scoring;
95 using namespace pose;
96 using namespace protocols;
97 using namespace protocols::moves;
98 using namespace protocols::ncbb;
99 using namespace protocols::simple_moves;
100 using namespace protocols::rigid;
101 using namespace protocols::toolbox;
102 using namespace protocols::toolbox::pose_metric_calculators;
103 using namespace core::pack::task;
104 using namespace basic::options;
105 using namespace basic::options::OptionKeys;
106 using namespace core::id;
107 using basic::T;
108 using basic::Error;
109 using basic::Warning;
111 
112 
113 // tracer
114 static THREAD_LOCAL basic::Tracer TR( "PeptoidDesign" );
115 
116 // application specific options
117 namespace peptoid_design {
118 IntegerOptionKey const pert_num( "peptoid_design::pert_num" );
119 IntegerOptionKey const design_loop_num( "peptoid_design::design_loop_num" );
120 BooleanOptionKey const cyclic( "peptoid_design::cyclic" );
121 IntegerVectorOptionKey const peptoid_design_positions( "peptoid_design::peptoid_design_positions" );
122 }
123 
124 class PeptoidDesignMover : public Mover {
125 
126 public:
127 
128  //default ctor
129  PeptoidDesignMover(): Mover("PeptoidDesignMover"){}
130 
131  //default dtor
133 
134  //methods
135  virtual void apply( core::pose::Pose & pose );
136  virtual std::string get_name() const { return "PeptoidDesignMover"; }
137 
138 };
139 
140 typedef utility::pointer::shared_ptr< PeptoidDesignMover > PeptoidDesignMoverOP;
141 typedef utility::pointer::shared_ptr< PeptoidDesignMover const > PeptoidDesignMoverCOP;
142 
143 
144 int
145 main( int argc, char* argv[] )
146 {
147  try {
148  /*********************************************************************************************************************
149  Common Setup
150  **********************************************************************************************************************/
151 
152  // add application specific options to options system
153  option.add( peptoid_design::pert_num, "Number of iterations of perturbation loop per design" ).def(10);
154  option.add( peptoid_design::design_loop_num, "Number of iterations of pertubation and design" ).def(10);
155  option.add( peptoid_design::cyclic, "Is the second chain a cycle" ).def(false);
156 
157  utility::vector1< core::Size > empty_vector(0);
158  option.add( peptoid_design::peptoid_design_positions, "Positions of peptoid to design" ).def( empty_vector );
159 
160  // init command line options
161  devel::init(argc, argv);
162 
163  //create mover instance
164  PeptoidDesignMoverOP OD_mover( new PeptoidDesignMover() );
165 
166  setup_filter_stats();
167 
168  //call job distributor
169  protocols::jd2::JobDistributor::get_instance()->go( OD_mover );
170 
171  } catch ( utility::excn::EXCN_Base const & e ) {
172  std::cout << "caught exception " << e.msg() << std::endl;
173  return -1;
174  }
175 
176 }//main
177 
178 void
181 )
182 {
183  // create score function
184  scoring::ScoreFunctionOP score_fxn( ScoreFunctionFactory::create_score_function( scoring::MM_STD_WTS ) );
185  score_fxn->set_weight( atom_pair_constraint, 10 );
186  score_fxn->set_weight( angle_constraint, 10 );
187  score_fxn->set_weight( dihedral_constraint, 10 );
188 
189  // get a fold tree suitable for docking (local helper function)
190  setup_pert_foldtree( pose );
191 
192  // setup the cyclization mover if the pose is cyclic
193  if ( option[ peptoid_design::cyclic ].value() == true ) {
194  simple_moves::CyclizationMoverOP init_cyclization( new CyclizationMover( 2, true, false, 0 ) );
195  init_cyclization->apply( pose );
196  }
197 
198  // create a monte carlo object for the full cycle
199  moves::MonteCarloOP mc( new moves::MonteCarlo( pose, *score_fxn, 1.0 ) );
200 
201  // DEBUG
202  //moves::PyMolMoverOP pmm( new protocols::moves::PyMolMover() );
203  //pmm->keep_history( true );
204 
205  /*********************************************************
206  Peptoid Pertubation Phase Setup
207  **********************************************************/
208 
209  // jump, rot_mag, trans_mag
210  rigid::RigidBodyPerturbMoverOP pert_dock_rbpm( new rigid::RigidBodyPerturbMover( 1, 0.1, 0.1 ) );
211 
212  // get peptoid start and end positions
213  Size pep_start( pose.conformation().chain_begin( 2 ) ); Size pep_end( pose.total_residue() );
214  TR << "peptoid_start: " << pep_start << " peptoid_end: " << pep_end << std::endl;
215 
216  // create movemap for peptoid
217  kinematics::MoveMapOP pert_pep_mm( new kinematics::MoveMap() );
218  pert_pep_mm->set_bb_true_range(pep_start, pep_end);
219  pert_pep_mm->set_jump( 1, true );
220 
221  // setup the cyclization mover
222  simple_moves::CyclizationMoverOP pert_cyclization( new CyclizationMover( 2, false, true, 1, score_fxn, pert_pep_mm ) );
223 
224  // create random torsion mover
225  simple_moves::RandomTorsionMoverOP pert_pep_rand_tor( new simple_moves::RandomTorsionMover( pert_pep_mm, 0.5, 10 ) );
226 
227  // create an omega flip mover
228  simple_moves::RandomOmegaFlipMoverOP pert_pep_omg_flip( new simple_moves::RandomOmegaFlipMover( pert_pep_mm ) );
229 
230  // create a random mover to hold the docking, and peptide pertubation movers
231  moves::RandomMoverOP pert_random( new moves::RandomMover() );
232  pert_random->add_mover( pert_dock_rbpm, 1 );
233  pert_random->add_mover( pert_pep_rand_tor, 1 );
234  //pert_random->add_mover( pert_pep_omg_flip, 0.01 );
235 
236  // create a repeat mover
237  moves::RepeatMoverOP pert_repeat( new moves::RepeatMover( pert_random, 100 ) );
238 
239  // create a sequence move to hold random and rotamer trials movers
240  moves::SequenceMoverOP pert_sequence( new moves::SequenceMover() );
241  pert_sequence->add_mover( pert_repeat );
242  //pert_sequence->add_mover( pmm );
243  if ( option[ peptoid_design::cyclic ].value() == true ) {
244  pert_sequence->add_mover( pert_cyclization );
245  }
246  //pert_sequence->add_mover( pmm );
247 
248  // create a TrialMover for the pertubation
249  moves::TrialMoverOP pert_trial( new moves::TrialMover( pert_sequence, mc ) );
250 
251  /*********************************************************
252  Design Setup
253  **********************************************************/
254 
255  using core::pack::task::operation::TaskOperationCOP;
256  TaskFactoryOP desn_tf( new TaskFactory() );
257  desn_tf->push_back( TaskOperationCOP( new core::pack::task::operation::InitializeFromCommandline ) );
258 
259  // maybe a restrict to interface operation
260 
261  /*********************************************************
262  Minimize Setup
263  **********************************************************/
264 
265  // create move map for minimization
266  kinematics::MoveMapOP desn_mm( new kinematics::MoveMap() );
267  desn_mm->set_bb( false );
268  desn_mm->set_bb_true_range( pep_start, pep_end );
269  desn_mm->set_chi( true );
270  desn_mm->set_jump( 1, true );
271 
272  // create minimization mover
273  simple_moves::MinMoverOP desn_min( new simple_moves::MinMover( desn_mm, score_fxn, option[ OptionKeys::run::min_type ].value(), 0.01, true ) );
274 
275  //definitely want sidechain minimization here
276  using protocols::simple_moves::TaskAwareMinMoverOP;
277  using protocols::simple_moves::TaskAwareMinMover;
278  TaskAwareMinMoverOP desn_ta_min( new TaskAwareMinMover( desn_min, desn_tf ) );
279 
280  // create a list of peptoid sidechains (this is inefficient)
281  // chemical::ResidueTypeCOPs const & rt_caps( ChemicalManager::get_instance()->residue_type_set( FA_STANDARD )->residue_types_DO_NOT_USE() );
282  chemical::ResidueTypeCOPs rt_caps( chemical::ResidueTypeFinder( *ChemicalManager::get_instance()->residue_type_set( FA_STANDARD ) ).base_property( PEPTOID ).get_possible_base_residue_types() );
283  std::set< std::string > peptoid_name_set;
284  for ( Size i(1); i <= rt_caps.size(); ++i ) {
285  if ( rt_caps[i]->is_peptoid() ) {
286  peptoid_name_set.insert( rt_caps[i]->name3() );
287  }
288  }
289 
290  peptoid_name_set.erase( peptoid_name_set.find( "004" ) );
291  peptoid_name_set.erase( peptoid_name_set.find( "006" ) );
292  peptoid_name_set.erase( peptoid_name_set.find( "010" ) );
293  peptoid_name_set.erase( peptoid_name_set.find( "013" ) );
294  peptoid_name_set.erase( peptoid_name_set.find( "111" ) );
295  peptoid_name_set.erase( peptoid_name_set.find( "206" ) );
296  peptoid_name_set.erase( peptoid_name_set.find( "307" ) );
297  peptoid_name_set.erase( peptoid_name_set.find( "313" ) );
298  peptoid_name_set.erase( peptoid_name_set.find( "402" ) );
299  peptoid_name_set.erase( peptoid_name_set.find( "405" ) );
300 
301  peptoid_name_set.erase( peptoid_name_set.find( "623" ) ); // wrong order of chi angle atoms, not sure why we have been able to pack with this before?
302  peptoid_name_set.erase( peptoid_name_set.find( "624" ) ); // wrong order of chi angle atoms, not sure why we have been able to pack with this before?
303 
304  peptoid_name_set.erase( peptoid_name_set.find( "701" ) ); // not sure what is up but don't want to design this anyway
305  peptoid_name_set.erase( peptoid_name_set.find( "702" ) ); // not sure what is up but don't want to design this anyway
306  peptoid_name_set.erase( peptoid_name_set.find( "703" ) ); // not sure what is up but don't want to design this anyway
307  peptoid_name_set.erase( peptoid_name_set.find( "704" ) ); // not sure what is up but don't want to design this anyway
308 
309  TR << "Allowed sidechains: ";
310  for ( std::set< std::string >::const_iterator j(peptoid_name_set.begin()); j != peptoid_name_set.end(); ++j ) {
311  TR << *j << " ";
312  }
313  TR << std::endl;
314 
315 
316  /*********************************************************************************************************************
317  Main Loop
318  **********************************************************************************************************************/
319 
320  TR << "Main loop..." << std::endl;
321 
322  ncbb_design_main_loop( Size( option[ peptoid_design::design_loop_num ].value() ),
324  pose,
325  pert_trial,
327  pep_start,
328  pep_end,
329  desn_ta_min,
330  score_fxn,
331  mc
332  );
333 
334  mc->recover_low( pose );
335 
336  protocols::jd2::JobOP curr_job( protocols::jd2::JobDistributor::get_instance()->current_job() );
337 
338  curr_job->add_string_real_pair( "ENERGY_FINAL ", (*score_fxn)(pose) );
339 
340  TR << "Ending main loop..." << std::endl;
341  TR << "Checking pose energy..." << std::endl;
342  calculate_statistics( curr_job, pose, score_fxn );
343 }
344 
345 
virtual ~PeptoidDesignMover()
#define THREAD_LOCAL
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
Automatic hidden index key for integer options.
int main(int argc, char *argv[])
utility::keys::KeyLookup< KeyType >::const_iterator const_iterator
Key collection iterators.
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
IntegerOptionKey const design_loop_num("peptoid_design::design_loop_num")
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
static THREAD_LOCAL basic::Tracer TR("PeptoidDesign")
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.
Automatic hidden index key for boolean options.
utility::pointer::shared_ptr< PeptoidDesignMover > PeptoidDesignMoverOP
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
Tracer & Warning(TracerPriority priority=t_warning)
Predefined Warning tracer.
Definition: Tracer.hh:398
string min_type
Definition: loops_kic.py:76
IntegerOptionKey const pert_num("peptoid_design::pert_num")
BooleanOptionKey const cyclic("peptoid_design::cyclic")
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
utility::pointer::shared_ptr< PeptoidDesignMover const > PeptoidDesignMoverCOP
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.
virtual std::string get_name() const
virtual void apply(core::pose::Pose &pose)
Program options global and initialization function.
platform::Size Size
Definition: random.fwd.hh:30
IntegerVectorOptionKey const peptoid_design_positions("peptoid_design::peptoid_design_positions")
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378