Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ligand_rpkmin.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 apps/public/ligand_docking/ligand_rpkmin.cc
11 ///
12 /// @brief Repack and minimize sidechains. For preparing structures prior to ligand docking.
13 /// @author Rocco Moretti (rmoretti@u.washington.edu), Ian Davis (ian.w.davis@gmail.com)
14 
15 // Package Headers
16 
17 #include <devel/init.hh>
18 #include <protocols/jd2/JobDistributor.hh>
19 #include <protocols/jd2/util.hh>
20 
21 // Project Headers
22 
23 #include <core/types.hh>
24 #include <core/conformation/Residue.hh>
25 #include <core/kinematics/MoveMap.hh>
26 #include <core/optimization/MinimizerOptions.hh>
27 #include <core/pack/rotamer_set/UnboundRotamersOperation.hh>
28 #include <core/pack/task/PackerTask.hh>
29 #include <core/pack/task/TaskFactory.hh>
30 #include <core/pose/Pose.hh>
31 #include <core/scoring/ScoreFunction.hh>
32 #include <core/pack/dunbrack/RotamerConstraint.hh>
33 
34 #include <protocols/ligand_docking/LigandBaseProtocol.hh>
35 #include <protocols/simple_moves/MinMover.hh>
36 #include <protocols/moves/Mover.hh>
37 #include <protocols/simple_moves/PackRotamersMover.hh>
38 #include <protocols/simple_moves/RotamerTrialsMover.hh>
39 
40 // Utility Headers
41 
42 
44 #include <basic/options/keys/in.OptionKeys.gen.hh>
45 #include <basic/options/keys/out.OptionKeys.gen.hh>
46 #include <basic/options/keys/packing.OptionKeys.gen.hh>
47 #include <basic/options/keys/docking.OptionKeys.gen.hh>
48 
49 #include <utility/vector0.hh>
50 #include <utility/vector1.hh>
52 
53 
54 //////////////////////////////////////////////////////////////////////////////
55 class LigandRepackMinimizeProtocol; // fwd declaration
56 typedef utility::pointer::shared_ptr< LigandRepackMinimizeProtocol > LigandRepackMinimizeProtocolOP;
57 typedef utility::pointer::shared_ptr< LigandRepackMinimizeProtocol const > LigandRepackMinimizeProtocolCOP;
58 
60 {
61 public:
62 
63  inline
66  {
67  Mover::type( "LigandRepackMinimizeProtocol" );
68  }
69 
70  virtual void apply( core::pose::Pose & pose );
71 
72 }; // class LigandRepackMinimizeProtocol
73 
74 
75 /// @brief Creates a new hierarchy of Movers for each Pose passed in.
76 /// @details Some Movers (e.g. repack) require knowledge of the Pose to create,
77 /// and are only valid for that Pose and other conformations of it
78 /// (i.e. poses with the same number of residues, jumps, etc).
79 /// In general, we expect each Pose coming in here to be from a different PDB file.
80 /// The cost of creating these objects anew should be minimal compared
81 /// to the processing work they do.
82 void
84 {
85  using namespace protocols::moves;
86  using namespace core::pack::task;
87 
88  //int jump_id = pose.num_jump(); // assume ligand attached by last jump
89  //if ( jump_id == 0 ) {
90  // utility_exit_with_message("Pose has no jumps!");
91  //}
92 
93  core::pack::dunbrack::load_unboundrot(pose); // adds scoring bonuses for the "unbound" rotamers, if any
94 
95  // Scoring function already set up by superclass
96  // BUG: currently need to score pose explicitly to get everything initialized properly
97  (*scorefxn_)( pose );
98 
99  // Repack all sidechains
100  PackerTaskOP pack_task = core::pack::task::TaskFactory::create_packer_task(pose);
101  pack_task->initialize_from_command_line(); // -ex1 -ex2 etc.
102  pack_task->restrict_to_repacking(); // all residues
103  pack_task->or_include_current(true); // may already be in lowest E conf
104  pack_task->append_rotamerset_operation( unboundrot_ );
105  // Disable packing completely for ligands b/c we want them to stay put
106  for ( core::Size i = 1, i_end = pose.total_residue(); i <= i_end; ++i ) {
107  if ( !pose.residue(i).is_polymer() ) {
108  pack_task->nonconst_residue_task( i ).prevent_repacking();
109  }
110  }
111 
112  //core::pack::rtmin(pose, *scorefxn_, pack_task);
113  //return;
114 
115  protocols::simple_moves::PackRotamersMoverOP fullRepack( new protocols::simple_moves::PackRotamersMover(scorefxn_, pack_task) );
116  fullRepack->apply(pose);
117 
118  // Is this necessary? How well does the repack converge?
119  protocols::simple_moves::RotamerTrialsMoverOP rotamerTrials( new protocols::simple_moves::RotamerTrialsMover(scorefxn_, *pack_task) );
120  rotamerTrials->apply(pose);
121 
122  // Set up move map for minimizing.
123  // Only want to minimize protein sc; keep ligand the same as reference point
124  core::kinematics::MoveMapOP movemap( new core::kinematics::MoveMap() );
125  for ( int i = 1, end_i = pose.total_residue(); i <= end_i; ++i ) {
126  if ( pose.residue(i).is_polymer() ) {
127  movemap->set_chi(i, true);
128  }
129  }
130  protocols::simple_moves::MinMoverOP dfpMinTightTol( new protocols::simple_moves::MinMover( movemap, scorefxn_, "dfpmin_armijo_nonmonotone_atol", 0.02, true /*use_nblist*/ ) );
131  dfpMinTightTol->min_options()->nblist_auto_update(true);
132  dfpMinTightTol->apply(pose);
133 
134 }
135 
136 
137 //////////////////////////////////////////////////////////////////////////////
138 int
139 main( int argc, char * argv [] )
140 {
141  try {
143  OPT(in::file::extra_res_fa);
144  OPT(packing::unboundrot);
145  OPT(packing::ex1::ex1);
146  OPT(packing::ex1aro::ex1aro);
147  OPT(packing::ex2::ex2);
148  OPT(packing::extrachi_cutoff);
149  OPT(packing::no_optH);
150  OPT(packing::flip_HNQ);
151  OPT(docking::ligand::soft_rep);
152  OPT(docking::ligand::old_estat);
153 
154  OPT(in::file::s);
155  OPT(out::nstruct);
157 
158  // Parses command line options and inits RNG.
159  // Need to do this before trying to check options.
160  // Doesn't seem to hurt to do it again if already done once (?)
161  devel::init(argc, argv);
163 
164  // Build overall docking protocol Mover
166 
167  protocols::jd2::JobDistributor::get_instance()->go(dockingProtocol);
168  } catch ( utility::excn::EXCN_Base const & e ) {
169  std::cout << "caught exception " << e.msg() << std::endl;
170  return -1;
171  }
172 }
173 
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
void register_options()
utility::pointer::shared_ptr< LigandRepackMinimizeProtocol > LigandRepackMinimizeProtocolOP
vector0: std::vector with assert-checked bounds
void init(int argc, char *argv[])
Command line init() version.
Definition: init.cc:23
utility::pointer::shared_ptr< LigandRepackMinimizeProtocol const > LigandRepackMinimizeProtocolCOP
core::pose::Pose Pose
Definition: supercharge.cc:101
common derived classes for thrown exceptions
tuple database
basic::options::IntegerOptionKey const nstruct("nstruct")
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
vector1: std::vector with 1-based indexing
tuple movemap
Definition: loops.py:29
#define OPT(akey)
platform::Size Size
Definition: random.fwd.hh:30
int main(int argc, char *argv[])
virtual void apply(core::pose::Pose &pose)
Creates a new hierarchy of Movers for each Pose passed in.