Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InvrotTreeRCG.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/InvrotTreeRCG.cc
11 ///
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, may 2012
14 /// @modified Tom Linsky, tlinsky@uw.edu, nov 2012
15 
16 // unit headers
19 
20 // project headers
21 #include <core/pose/Pose.hh>
29 
30 // utility headers
31 #include <basic/Tracer.hh>
32 #include <utility/tag/Tag.hh>
33 #include <utility/excn/Exceptions.hh>
34 #include <utility/vector1.hh>
35 
36 
37 static basic::Tracer tr( "protocols.forge.constraints.InvrotTreeRCG" );
38 
39 namespace protocols{
40 namespace forge{
41 namespace constraints{
42 
45 {
46  return new InvrotTreeRCG();
47 }
48 
51 {
53 }
54 
57 {
58  return "InvrotTreeCstGenerator";
59 }
60 
62  : RemodelConstraintGenerator(),
63  add_ligand_to_pose_( false ),
64  invrot_tree_( NULL ),
65  enzcst_io_( NULL ),
66  geomcst_seqpos_( NULL ),
67  setup_align_pose_( NULL )
68 {}
69 
71  : RemodelConstraintGenerator( rval ),
72  add_ligand_to_pose_( rval.add_ligand_to_pose_ ),
73  invrot_tree_( rval.invrot_tree_ ),
74  enzcst_io_( rval.enzcst_io_ ),
75  geomcst_seqpos_( rval.geomcst_seqpos_ ),
76  setup_align_pose_( rval.setup_align_pose_ )
77 {}
78 
82  )
83  : invrot_tree_(invrot_tree),
84  geomcst_seqpos_(geomcst_seqpos)
85 {}
86 
88 
89 void
92  protocols::filters::Filters_map const & filters,
93  protocols::moves::Movers_map const & movers,
94  core::pose::Pose const & pose )
95 {
96  RemodelConstraintGenerator::parse_my_tag( tag, data, filters, movers, pose );
97  //in case we'ref folding up around a ligand
98  std::string cstfilename = tag->getOption<std::string>( "cstfile", "" );
99  if ( cstfilename == "" ) {
100  throw utility::excn::EXCN_RosettaScriptsOption( "XML tag for invrot tree does not contain a cstfile option... this will probably fail when the InvrotTreeCstGenerator mover runs." );
101  }
102  set_cstfile( cstfilename );
103 
104  // should we add in the ligand, or is it already there
105  set_add_ligand_to_pose( tag->getOption<bool>( "add_ligand_to_pose", add_ligand_to_pose_ ) );
106 }
107 
110 {
112 }
113 
116 {
117  return new InvrotTreeRCG();
118 }
119 
122 {
123  return new InvrotTreeRCG( *this );
124 }
125 
126 void
128 {
129  //tr << "IN apply, id=" << id() << std::endl;
130  init( pose );
131  setup_align_pose_->apply( pose );
132 
133  runtime_assert( invrot_tree_ );
134  runtime_assert( geomcst_seqpos_ );
135  runtime_assert( setup_align_pose_ );
136 
137  //tr << "now id=" << id() << std::endl;
138  // generate and add constraints
139  this->add_remodel_constraints_to_pose( pose );
140 }
141 
142 void
144  core::pose::Pose const & pose )
145 {
146  tr << "in invrottreercg" << std::endl;
147 
148  //for now
149  runtime_assert( invrot_tree_->num_target_states() == 1 );
150  Size target_state = 1;
151 
152  tr << "generating inverse_rotamer_constraints" << std::endl;
153  invrot_tree_->generate_inverse_rotamer_constraints( pose, geomcst_seqpos_ );
154  tr << "done generating inverse_rotamer_constraints" << std::endl;
155  core::scoring::constraints::ConstraintCOP cst_to_add( invrot_tree_->get_constraint_for_target_state( target_state ) );
156 
157  if( !cst_to_add ) utility_exit_with_message("InvrotTree failed to generate anything but NULL pointer csts. Something is wrong somewhere. Check your starting structure for whether it already has every interaction in the cstfile." );
158  this->add_constraint( cst_to_add );
159 }
160 
161 /// @brief tells the mover whether it should add the ligand to the pose
162 void
164 {
165  add_ligand_to_pose_ = add_lig;
166 }
167 
168 /// @brief sets up the invrot_tree_ and enzcst_io_ from an enzdes constraint filename.
169 void
171 {
173  enzcst_io->read_enzyme_cstfile( cstfilename );
175  invrot_tree_->generate_targets_and_inverse_rotamers();
176  enzcst_io_ = enzcst_io;
177 } //set_cstfile()
178 
179 /// @brief initializes the rcg object
180 void
182 {
183  // this function is invoked from BluePrintBDR after the VLB object is attached, but before we enter centroid mode
184  // it is also invoked when the mover is applied, if it is called from somewhere else
186  //stupid: apparently we have to make a copy of the pose on the heap for
187  //the initialization of allowed_seqpos to work
188  core::pose::PoseOP posecopy( new core::pose::Pose( pose ) );
189  geomcst_seqpos_->initialize_from_command_line( posecopy );
190 
191  // setup the align_pose movers
192  // this one is called once before adding constraints
194  setup_align_pose_->set_add_target_to_pose( add_ligand_to_pose_ );
195  setup_align_pose_->set_geomcst_for_superposition_from_enz_io( enzcst_io_ );
196 
197  // if a VLB is going on, this one can be called as a user-provided mover
199  run_align_pose_->set_geomcst_for_superposition_from_enz_io( enzcst_io_ );
200  if ( vlb() ) {
201  vlb()->loop_mover_fold_tree_constant( true ); //we're taking care of the fold tree through the above align movers
202  vlb()->add_setup_mover( setup_align_pose_ );
203  vlb()->add_user_provided_mover( run_align_pose_ );
204  }
205 }
206 
207 } //namespace remodel
208 } //namespace forge
209 } //namespace protocols