Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VLB.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/protein_interface_design/movers/VLB.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu), Jacob Corn (jecorn@u.washington.edu)
13 
14 // Unit headers
17 
18 // Project headers
19 #include <protocols/moves/Mover.hh>
31 
32 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
36 
38 #include <utility/tag/Tag.hh>
41 #include <core/pose/selection.hh>
42 
43 #include <core/pose/Pose.hh>
44 #include <core/types.hh>
45 #include <string>
46 #include <basic/options/option.hh>
47 #include <basic/options/keys/jd2.OptionKeys.gen.hh> // used for internal tracking of ntrials (fragment caching)
48 
49 #include <basic/Tracer.hh>
50 #include <utility/vector0.hh>
51 #include <utility/vector1.hh>
52 
53 
54 
55 namespace protocols {
56 namespace protein_interface_design {
57 namespace movers {
58 
59 using namespace core;
60 using namespace std;
61 using namespace core::scoring;
62 using namespace protocols::moves;
63 using namespace protocols::forge::build;
64 using namespace protocols::forge::components;
65 
66 static basic::Tracer TR( "protocols.protein_interface_design.movers.VLB" );
67 
70 {
71  return VLBCreator::mover_name();
72 }
73 
76  return new VLB;
77 }
78 
81 {
82  return "VLB";
83 }
84 
86  protocols::moves::Mover( VLBCreator::mover_name() )
87 {
88  manager_ = new BuildManager;
90 } // default ctor//design_ = true;
91 
93  protocols::moves::Mover( VLBCreator::mover_name() )
94 {
95  manager_ = new BuildManager( *manager );
96  scorefxn_ = new core::scoring::ScoreFunction( *scorefxn );
97 }
98 
99 void
101 
102  // internally handles ntrials, so that fragments can be cached!
103  VarLengthBuild vlb( *manager_ );
104  vlb.scorefunction( scorefxn_ );
105  core::Size ntrials(1);
106  using namespace basic::options;
107  using namespace basic::options::OptionKeys;
108  if( option[ jd2::ntrials ].user() ) ntrials = option[ jd2::ntrials ]() ;
109  while( ntrials > 0 ) {
110  vlb.apply( pose );
111  if ( vlb.get_last_move_status() == MS_SUCCESS ) break;
112  else ntrials--;
113  }
114 
117  else {
118  TR << "VLB mover status was not properly set! Aborting.";
119  set_last_move_status(FAIL_DO_NOT_RETRY); // we should never get to this point!
120  }
121 
122 }
123 
125 VLB::get_name() const {
126  return VLBCreator::mover_name();
127 }
128 
130  return( protocols::moves::MoverOP( new VLB( *this ) ));
131 }
132 
134  return protocols::moves::MoverOP( new VLB );
135 }
136 
137 VLB::VLB( VLB const & init ) :
138  //utility::pointer::ReferenceCount(),
139  protocols::moves::Mover( init ) {
140  manager_ = new BuildManager( *init.manager_ );
142 }
143 
144 VLB const & VLB::operator=( VLB const & init ) {
145  manager_ = new BuildManager( *init.manager_ );
147  return *this;
148 }
149 
150 
152 
153 void
155  TagPtr const tag,
156  DataMap & data,
158  Movers_map const &,
159  core::pose::Pose const & pose
160 )
161 {
162  using namespace protocols::rosetta_scripts;
163  //RelativeConnectRight( rel_seq_pos, right, connect_pose ); /// version of ConnectRight instruction that depends upon results from another BuildInstruction
164 
165  std::string const scorefxn( tag->getOption<std::string>( "scorefxn", "score4L" ) ); // VarLengthBuild uses remodel_cen by default. score4L is the same, but with Rg=2.0
166  scorefxn_ = new core::scoring::ScoreFunction( *data.get< core::scoring::ScoreFunction * >( "scorefxns", scorefxn ));
167 
168  BuildInstructionOP instruction;
169  utility::vector0< TagPtr > const tags( tag->getTags() );
170  for( utility::vector0< TagPtr >::const_iterator it=tags.begin(); it!=tags.end(); ++it ) {
171  TagPtr const tag = *it;
172  if( tag->getName() == "Bridge" ) {
173  // connect two contiguous but disjoint sections of a Pose into one continuous section
174  string const res1( tag->getOption< std::string >( "left" ) );
175  Size const left = core::pose::parse_resnum( res1, pose );
176  string const res2( tag->getOption< std::string >( "right" ) );
177  Size const right = core::pose::parse_resnum( res2, pose );
178 
179  string const ss( tag->getOption< std::string >( "ss", "" ) );
180  string const aa( tag->getOption< std::string >( "aa", "" ) );
181 
182  Interval const ival( left, right);
183  instruction = new Bridge( ival, ss, aa );
184  }
185  if( tag->getName() == "ConnectRight" ) {
186  //instruction to jump-connect one Pose onto the right side of another
187  string const res1( tag->getOption< std::string >( "left" ) );
188  Size const left = core::pose::parse_resnum( res1, pose );
189  string const res2( tag->getOption< std::string >( "right" ) );
190  Size const right = core::pose::parse_resnum( res2, pose );
191 
192  string const pose_fname( tag->getOption< std::string >( "pdb", "" ) );
193  runtime_assert( pose_fname != "" );
194  pose::Pose connect_pose;
195  core::import_pose::pose_from_pdb( connect_pose, pose_fname );
196  instruction = new ConnectRight( left, right, connect_pose );
197  }
198  if( tag->getName() == "GrowLeft" ) {
199  /// Use this for n-side insertions, but typically not n-terminal
200  /// extensions unless necessary. It does not automatically cover the
201  /// additional residue on the right endpoint that needs to move during
202  /// n-terminal extensions due to invalid phi torsion. For that case,
203  /// use the SegmentRebuild class replacing the n-terminal residue with
204  /// desired length+1.
205 
206  string const res1( tag->getOption< std::string >( "pos" ) );
207  Size const pos = core::pose::parse_resnum( res1, pose );
208 
209  string const ss( tag->getOption< std::string >( "ss", "" ) );
210  string const aa( tag->getOption< std::string >( "aa", "" ) );
211 
212  instruction = new GrowLeft( pos, ss, aa );
213  }
214  if( tag->getName() == "GrowRight" ) {
215  /// instruction to create a c-side extension
216  string const res1( tag->getOption< std::string >( "pos" ) );
217  Size const pos = core::pose::parse_resnum( res1, pose );
218 
219  string const ss( tag->getOption< std::string >( "ss", "" ) );
220  string const aa( tag->getOption< std::string >( "aa", "" ) );
221 
222  instruction = new GrowRight( pos, ss, aa );
223  }
224 
225 
226  if( tag->getName() == "SegmentInsert" ) {
227  /// interval: The interval between which the insert will span.
228  /// To perform a pure insertion without replacing any residues
229  /// within a region, use an interval with a zero as the left endpoint, e.g.
230  /// [0, insert_after_this_residue]. If inserting before the first residue
231  /// of the Pose then interval = [0,0]. If inserting after the last residue
232  /// of the Pose then interval = [0, last_residue].
233  /// ss: The secondary structure specifying the flanking regions,
234  /// with a character '^' specifying where the insert is to be placed.
235  /// insert: The Pose to insert.
236  /// keep_known_bb_torsions_at_junctions: Attempt to keep the omega
237  /// at original_interval().left-1, the phi at original_interval().left, and
238  /// the psi+omega at original_interval().right present from the original Pose
239  /// in the modified Pose. This should be false for pure insertions.
240  /// connection_scheme: Connect insertion on its N-side, C-side,
241  /// or decide randomly between the two (default RANDOM). Random is only random on parsing, not per ntrial.
242 
243  string const res1( tag->getOption< std::string >( "left" ) );
244  Size const left = core::pose::parse_resnum( res1, pose );
245  string const res2( tag->getOption< std::string >( "right" ) );
246  Size const right = core::pose::parse_resnum( res2, pose );
247  Interval const ival( left, right );
248 
249  string const ss( tag->getOption< std::string >( "ss", "L^L" ) );
250  string const aa( tag->getOption< std::string >( "aa", "" ) );
251  bool const keep_bb_torsions( tag->getOption< bool >( "keep_bb_torsions", "0" ));
252  string const pose_fname( tag->getOption< std::string >( "pdb", "" ) );
253 
254  runtime_assert( pose_fname != "" );
255  pose::Pose insert_pose;
256  core::import_pose::pose_from_pdb( insert_pose, pose_fname );
257 
258  string const side( tag->getOption< std::string >( "side", "" ) );
260  if( side == "N" ) connect_side = SegmentInsertConnectionScheme::N;
261  else if( side == "C" ) connect_side = SegmentInsertConnectionScheme::C;
262  else connect_side = SegmentInsertConnectionScheme::RANDOM_SIDE;
263 
264  instruction = new SegmentInsert( ival, ss, insert_pose, keep_bb_torsions, connect_side );
265  }
266 
267 
268  if( tag->getName() == "SegmentRebuild" ) {
269  /// @brief instruction to rebuild a segment
270  string const res1( tag->getOption< std::string >( "left" ) );
271  Size const left = core::pose::parse_resnum( res1, pose );
272  string const res2( tag->getOption< std::string >( "right" ) );
273  Size const right = core::pose::parse_resnum( res2, pose );
274  Interval const ival( left, right);
275 
276  string const ss( tag->getOption< std::string >( "ss", "" ) );
277  string const aa( tag->getOption< std::string >( "aa", "" ) );
278 
279  instruction = new SegmentRebuild( ival, ss, aa );
280  }
281 
282  if( tag->getName() == "SegmentSwap" ) {
283  /// instruction to swap a segment with an external segment
284  /// interval: swap out this range of residues
285  /// move_map: fixed backbone residues in this movemap will be used for new jumps
286  /// swap_in: swap in this pose
287  string const res1( tag->getOption< std::string >( "left" ) );
288  Size const left = core::pose::parse_resnum( res1, pose );
289  string const res2( tag->getOption< std::string >( "right" ) );
290  Size const right = core::pose::parse_resnum( res2, pose );
291 
292  Interval const ival( left, right);
293 
294  string const pose_fname( tag->getOption< std::string >( "pdb", "" ) );
295  runtime_assert( pose_fname != "" );
296  pose::Pose swap_pose;
297  core::import_pose::pose_from_pdb( swap_pose, pose_fname );
298 
299  core::kinematics::MoveMap movemap; // empty = place jump anywhere
300  SegmentSwap( ival, movemap, swap_pose );
301  }
302 
303  manager_->add( instruction );
304  }
305 
306  runtime_assert( manager_->compatibility_check() );
307  TR<<"defined VLB mover with " << manager_->size() << " instructions." << std::endl;
308 }
309 
310 } //movers
311 } //protein_interface_design
312 } //protocols