Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Motif.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/motifs/Motif.cc
11 /// @brief Implementation of interaction motifs
12 /// @author havranek, sthyme (sthyme@gmail.com)
13 
14 // Unit Headers
16 
17 // Package Headers
18 
19 // Project Headers
20 #include <protocols/dna/util.hh>
26 #include <core/graph/Graph.hh>
27 #include <core/kinematics/Jump.hh>
33 #include <core/pose/PDBInfo.hh>
34 #include <core/pose/Pose.hh>
37 #include <basic/Tracer.hh>
38 #include <core/chemical/AtomType.hh> //Need this to prevent the compiling error: invalid use of incomplete type 'const struct core::chemical::AtomType
40 
41 // Utility Headers
42 #include <utility/string_util.hh>
43 #include <utility/tools/make_vector1.hh>
44 #include <utility/tools/make_map.hh>
45 
46 #include <numeric/xyz.functions.hh>
47 
48 // C++ Headers
49 #include <sstream>
50 
51 #include <utility/vector1.hh>
52 
53 
54 namespace protocols {
55 namespace motifs {
56 
57 static basic::Tracer mt( "protocols.motifs.Motif", basic::t_info );
58 
60  std::string const resname1,
61  std::string const res1_atom1,
62  std::string const res1_atom2,
63  std::string const res1_atom3,
64  std::string const resname2,
65  std::string const res2_atom1,
66  std::string const res2_atom2,
67  std::string const res2_atom3,
68  core::kinematics::Jump const & orientation
69 ) : restype_name1_( protocols::dna::dna_full_name3( resname1 ) ),
70  res1_atom1_name_( res1_atom1 ),
71  res1_atom2_name_( res1_atom2 ),
72  res1_atom3_name_( res1_atom3 ),
73  restype_name2_( protocols::dna::dna_full_name3( resname2 ) ),
74  res2_atom1_name_( res2_atom1 ),
75  res2_atom2_name_( res2_atom2 ),
76  res2_atom3_name_( res2_atom3 ),
77  forward_jump_( orientation ),
78  backward_jump_( ( orientation.reversed() ) ),
79  has_remark_( false ),
80  has_path_( false )
81 {
83  core::chemical::ResidueType const & rsd_type( rsd_set.name_map( restype_name1_ ) );
84  core::chemical::ResidueType const & rsd_type2( rsd_set.name_map( restype_name2_ ) );
85  res1_atom1_index_ = rsd_type.atom_index( res1_atom1_name_ );
86  res1_atom2_index_ = rsd_type.atom_index( res1_atom2_name_ );
87  res1_atom3_index_ = rsd_type.atom_index( res1_atom3_name_ );
88  res2_atom1_index_ = rsd_type2.atom_index( res2_atom1_name_ );
89  res2_atom2_index_ = rsd_type2.atom_index( res2_atom2_name_ );
90  res2_atom3_index_ = rsd_type2.atom_index( res2_atom3_name_ );
91 }
92 
94  core::pose::Pose const & pose,
95  Size const residue_position_1,
96  char const chain1,
97  std::string const res1_atom1_name,
98  std::string const res1_atom2_name,
99  std::string const res1_atom3_name,
100  Size const residue_position_2,
101  char const chain2,
102  std::string const res2_atom1_name,
103  std::string const res2_atom2_name,
104  std::string const res2_atom3_name
105 ) : restype_name1_( protocols::dna::dna_full_name3( pose.residue( pose.pdb_info()->pdb2pose( chain1, residue_position_1 ) ).name3() ) ),
106  res1_atom1_name_( res1_atom1_name ),
107  res1_atom2_name_( res1_atom2_name ),
108  res1_atom3_name_( res1_atom3_name ),
109  restype_name2_( protocols::dna::dna_full_name3( pose.residue( pose.pdb_info()->pdb2pose( chain2, residue_position_2 ) ).name3() ) ),
110  res2_atom1_name_( res2_atom1_name ),
111  res2_atom2_name_( res2_atom2_name ),
112  res2_atom3_name_( res2_atom3_name ),
113  forward_jump_( core::kinematics::Jump(
114  core::kinematics::Stub( pose.residue( pose.pdb_info()->pdb2pose( chain1, residue_position_1 ) ).atom( res1_atom2_name ).xyz(),
115  pose.residue( pose.pdb_info()->pdb2pose( chain1, residue_position_1 ) ).atom( res1_atom1_name ).xyz(),
116  pose.residue( pose.pdb_info()->pdb2pose( chain1, residue_position_1 ) ).atom( res1_atom2_name ).xyz(),
117  pose.residue( pose.pdb_info()->pdb2pose( chain1, residue_position_1 ) ).atom( res1_atom3_name ).xyz() ),
118  core::kinematics::Stub( pose.residue( pose.pdb_info()->pdb2pose( chain2, residue_position_2 ) ).atom( res2_atom2_name ).xyz(),
119  pose.residue( pose.pdb_info()->pdb2pose( chain2, residue_position_2 ) ).atom( res2_atom1_name ).xyz(),
120  pose.residue( pose.pdb_info()->pdb2pose( chain2, residue_position_2 ) ).atom( res2_atom2_name ).xyz(),
121  pose.residue( pose.pdb_info()->pdb2pose( chain2, residue_position_2 ) ).atom( res2_atom3_name ).xyz() ) ) ),
122  backward_jump_( forward_jump_.reversed() )
123 {
125  core::chemical::ResidueType const & rsd_type( rsd_set.name_map( restype_name1_ ) );
126  core::chemical::ResidueType const & rsd_type2( rsd_set.name_map( restype_name2_ ) );
127  res1_atom1_index_ = rsd_type.atom_index( res1_atom1_name_ );
128  res1_atom2_index_ = rsd_type.atom_index( res1_atom2_name_ );
129  res1_atom3_index_ = rsd_type.atom_index( res1_atom3_name_ );
130  res2_atom1_index_ = rsd_type2.atom_index( res2_atom1_name_ );
131  res2_atom2_index_ = rsd_type2.atom_index( res2_atom2_name_ );
132  res2_atom3_index_ = rsd_type2.atom_index( res2_atom3_name_ );
133 }
134 
136  core::pose::Pose const & pose,
137  Size const residue_position_1,
138  std::string const res1_atom1_name,
139  std::string const res1_atom2_name,
140  std::string const res1_atom3_name,
141  Size const residue_position_2,
142  std::string const res2_atom1_name,
143  std::string const res2_atom2_name,
144  std::string const res2_atom3_name
145 ) : restype_name1_( protocols::dna::dna_full_name3( pose.residue( residue_position_1 ).name3() ) ),
146  res1_atom1_name_( res1_atom1_name ),
147  res1_atom2_name_( res1_atom2_name ),
148  res1_atom3_name_( res1_atom3_name ),
149  restype_name2_( protocols::dna::dna_full_name3( pose.residue( residue_position_2 ).name3() ) ),
150  res2_atom1_name_( res2_atom1_name ),
151  res2_atom2_name_( res2_atom2_name ),
152  res2_atom3_name_( res2_atom3_name ),
153  forward_jump_( core::kinematics::Jump(
154  core::kinematics::Stub( pose.residue( residue_position_1 ).atom( res1_atom2_name ).xyz(),
155  pose.residue( residue_position_1 ).atom( res1_atom1_name ).xyz(),
156  pose.residue( residue_position_1 ).atom( res1_atom2_name ).xyz(),
157  pose.residue( residue_position_1 ).atom( res1_atom3_name ).xyz() ),
158  core::kinematics::Stub( pose.residue( residue_position_2 ).atom( res2_atom2_name ).xyz(),
159  pose.residue( residue_position_2 ).atom( res2_atom1_name ).xyz(),
160  pose.residue( residue_position_2 ).atom( res2_atom2_name ).xyz(),
161  pose.residue( residue_position_2 ).atom( res2_atom3_name ).xyz() ) ) ),
162  backward_jump_( forward_jump_.reversed() )
163 {
165  core::chemical::ResidueType const & rsd_type( rsd_set.name_map( restype_name1_ ) );
166  core::chemical::ResidueType const & rsd_type2( rsd_set.name_map( restype_name2_ ) );
167  res1_atom1_index_ = rsd_type.atom_index( res1_atom1_name_ );
168  res1_atom2_index_ = rsd_type.atom_index( res1_atom2_name_ );
169  res1_atom3_index_ = rsd_type.atom_index( res1_atom3_name_ );
170  res2_atom1_index_ = rsd_type2.atom_index( res2_atom1_name_ );
171  res2_atom2_index_ = rsd_type2.atom_index( res2_atom2_name_ );
172  res2_atom3_index_ = rsd_type2.atom_index( res2_atom3_name_ );
173 }
174 
175  // Matt's new constructor: This constructor gets the jump for you - Rosetta numbering
176  // Residue 1 is protein, residue 2 is ligand. For residue 1, just get the residue. For residue 2, get the residue and the 3 atom numbers as a vector.
178 core::conformation::Residue const & res1,
179 core::conformation::Residue const & res2,
180 utility::vector1< Size > const res2_atoms
181 )
182 {
183  if( (res1.is_protein() && res2.is_ligand() ) || (res1.is_protein() && res2.is_protein() ) ) {
184  restype_name1_ = res1.name3();
185  mt << "Res1 name is " << restype_name1_ << std::endl;
189  restype_name2_ = "LG1"; //We need to give the second residue (ligand residue) some random name
190  core::chemical::AtomType res2_atom1_type = res2.atom_type(res2_atoms[1]);
191  core::chemical::AtomType res2_atom2_type = res2.atom_type(res2_atoms[2]);
192  core::chemical::AtomType res2_atom3_type = res2.atom_type(res2_atoms[3]);
193 
194  res2_atom1_name_ = res2_atom1_type.atom_type_name();
195  mt << "atom1 name is " << res2_atom1_name_ << std::endl;
196  res2_atom2_name_ = res2_atom2_type.atom_type_name();
197  mt << "atom2 name is " << res2_atom2_name_ << std::endl;
198  res2_atom3_name_ = res2_atom3_type.atom_type_name();
199  mt << "atom3 name is " << res2_atom3_name_ << std::endl;
200  //Can't use motif atom name for
203  res1.atom( res1_atom1_name_ ).xyz(),
204  res1.atom( res1_atom2_name_ ).xyz(),
205  res1.atom( res1_atom3_name_ ).xyz() ),
206  core::kinematics::Stub( res2.atom( res2_atoms[2] ).xyz(),
207  res2.atom( res2_atoms[1] ).xyz(),
208  res2.atom( res2_atoms[2] ).xyz(),
209  res2.atom( res2_atoms[3] ).xyz() ) );
211 
212  } else{
213  mt << "Input motif residues do not match the expected combinations for this constructor; please use constructor that allows you to explicitly specify atoms involved." << std::endl;
214  }
216  core::chemical::ResidueType const & rsd_type1( rsd_set.name_map( restype_name1_ ) );
217  //core::chemical::ResidueType const & rsd_type2( rsd_set.name_map( restype_name2_ ) );
218  res1_atom1_index_ = rsd_type1.atom_index( res1_atom1_name_ );
219  res1_atom2_index_ = rsd_type1.atom_index( res1_atom2_name_ );
220  res1_atom3_index_ = rsd_type1.atom_index( res1_atom3_name_ );
221  res2_atom1_index_ = res2_atoms[1];
222  res2_atom2_index_ = res2_atoms[2];
223  res2_atom3_index_ = res2_atoms[3];
224 }
225 
226 // Search constructor for reading out the motifs from the motif file for ligands
228  std::string const resname1,
229  std::string const res1_atom1,
230  std::string const res1_atom2,
231  std::string const res1_atom3,
232  std::string const res2_atom1,
233  std::string const res2_atom2,
234  std::string const res2_atom3,
235  core::kinematics::Jump const & orientation
236 )
237 {
238  restype_name1_ = resname1;
239  res1_atom1_name_ = res1_atom1;
240  res1_atom2_name_ = res1_atom2;
241  res1_atom3_name_ = res1_atom3;
242  restype_name2_ = "LG1"; //We need to give the second residue (ligand residue) some random name
243  res2_atom1_name_ = res2_atom1;
244  res2_atom2_name_ = res2_atom2;
245  res2_atom3_name_ = res2_atom3;
246 
247  forward_jump_ = orientation;
249 
251  core::chemical::ResidueType const & rsd_type1( rsd_set.name_map( restype_name1_ ) );
252 
253  res1_atom1_index_ = rsd_type1.atom_index( res1_atom1_name_ );
254  res1_atom2_index_ = rsd_type1.atom_index( res1_atom2_name_ );
255  res1_atom3_index_ = rsd_type1.atom_index( res1_atom3_name_ );
256 // mt << "Res1: " << res1_atom1_name_ << res1_atom2_name_ << res1_atom3_name_ << " res2: " << res2_atom1_name_ << res2_atom2_name_ << res2_atom3_name_ << std::endl;
257  //int res1_atom1_int_ = rsd_type.atom_type_index( res1_atom1_index_);
258  //int res1_atom2_int_ = rsd_type.atom_type_index( res1_atom2_index_ );
259  //int res1_atom3_int_ = rsd_type.atom_type_index( res1_atom3_index_ );
261  res2_atom1_int_ = atset->atom_type_index(res2_atom1_name_);
262  res2_atom2_int_ = atset->atom_type_index(res2_atom2_name_);
263  res2_atom3_int_ = atset->atom_type_index(res2_atom3_name_);
264  // mt << " res2: " << res2_atom1_int_ << ", " << res2_atom2_int_ << ", " << res2_atom3_int_ << std::endl;
265 }
266 
268  core::conformation::Residue const & res1,
269  core::conformation::Residue const & res2
270 )
271 {
272  if( (res1.is_protein() && res2.is_protein() ) || (res1.is_protein() && res2.is_DNA() ) ) {
283  res1.atom( res1_atom1_name_ ).xyz(),
284  res1.atom( res1_atom2_name_ ).xyz(),
285  res1.atom( res1_atom3_name_ ).xyz() ),
287  res2.atom( res2_atom1_name_ ).xyz(),
288  res2.atom( res2_atom2_name_ ).xyz(),
289  res2.atom( res2_atom3_name_ ).xyz() ) );
291  } else if( res1.is_DNA() && res2.is_DNA() ) { // Can't use .build_motif_rotamers or .build_rotamers if both residues are DNA (at least right now)
302  res1.atom( res1_atom1_name_ ).xyz(),
303  res1.atom( res1_atom2_name_ ).xyz(),
304  res1.atom( res1_atom3_name_ ).xyz() ),
306  res2.atom( res2_atom1_name_ ).xyz(),
307  res2.atom( res2_atom2_name_ ).xyz(),
308  res2.atom( res2_atom3_name_ ).xyz() ) );
310  } else {
311  mt << "Input motif residues do not match the expected combinations for this constructor; please use constructor that allows you to explicitly specify atoms involved." << std::endl;
312  }
314  core::chemical::ResidueType const & rsd_type( rsd_set.name_map( restype_name1_ ) );
315  core::chemical::ResidueType const & rsd_type2( rsd_set.name_map( restype_name2_ ) );
316  res1_atom1_index_ = rsd_type.atom_index( res1_atom1_name_ );
317  res1_atom2_index_ = rsd_type.atom_index( res1_atom2_name_ );
318  res1_atom3_index_ = rsd_type.atom_index( res1_atom3_name_ );
319  res2_atom1_index_ = rsd_type2.atom_index( res2_atom1_name_ );
320  res2_atom2_index_ = rsd_type2.atom_index( res2_atom2_name_ );
321  res2_atom3_index_ = rsd_type2.atom_index( res2_atom3_name_ );
322 }
323 
325  Motif const & src
326 ) : utility::pointer::ReferenceCount(),
327  restype_name1_( src.restype_name1_ ),
328  res1_atom1_name_( src.res1_atom1_name_ ),
329  res1_atom2_name_( src.res1_atom2_name_ ),
330  res1_atom3_name_( src.res1_atom3_name_ ),
331  res1_atom1_int_( src.res1_atom1_int_ ),
332  res1_atom2_int_( src.res1_atom2_int_ ),
333  res1_atom3_int_( src.res1_atom3_int_ ),
334  res1_atom1_index_( src.res1_atom1_index_ ),
335  res1_atom2_index_( src.res1_atom2_index_ ),
336  res1_atom3_index_( src.res1_atom3_index_ ),
337  restype_name2_( src.restype_name2_ ),
338  res2_atom1_name_( src.res2_atom1_name_ ),
339  res2_atom2_name_( src.res2_atom2_name_ ),
340  res2_atom3_name_( src.res2_atom3_name_ ),
341  res2_atom1_int_( src.res2_atom1_int_ ),
342  res2_atom2_int_( src.res2_atom2_int_ ),
343  res2_atom3_int_( src.res2_atom3_int_ ),
344  res2_atom1_index_( src.res2_atom1_index_ ),
345  res2_atom2_index_( src.res2_atom2_index_ ),
346  res2_atom3_index_( src.res2_atom3_index_ ),
347  forward_jump_( src.forward_jump_ ),
348  backward_jump_( src.backward_jump_ ),
349  remark_( src.remark_ ),
350  path_( src.path_ ),
351  has_remark_( src.has_remark_ ),
352  has_path_( src.has_path_ )
353 {}
354 
355 MotifOP
357 {
358  return new Motif( *this );
359 }
360 
362 {}
363 
364 bool
366  core::conformation::Residue const & check_res
367 ) const
368 {
369  return( utility::trimmed_compare( check_res.name3(), restype_name1() ) );
370 }
371 
372 bool
374  core::conformation::Residue const & check_res
375 ) const
376 {
377  return( utility::trimmed_compare( check_res.name3(), restype_name2() ) );
378 }
379 
380 bool
382  core::pose::Pose const & pose,
383  Size const pos
384 ) const
385 {
386  if ( pose.residue(pos).is_DNA() )
387  {
388  return(
389  utility::trimmed_compare( protocols::dna::dna_full_name3(pose.residue( pos ).name3()), restype_name1_ ) ||
390  utility::trimmed_compare( protocols::dna::dna_full_name3(pose.residue( pos ).name3()), restype_name2_ )
391  );
392  }
393  return( utility::trimmed_compare( pose.residue( pos ).name3(), restype_name1_ ) ||
394  utility::trimmed_compare( pose.residue( pos ).name3(), restype_name2_ ) );
395 }
396 /*
397 // Search constructor for reading out the motifs from the motif file for ligands
398 Motif::Motif(
399  std::string const resname1,
400  std::string const res1_atom1,
401  std::string const res1_atom2,
402  std::string const res1_atom3,
403  std::string const res2_atom1,
404  std::string const res2_atom2,
405  std::string const res2_atom3,
406  core::kinematics::Jump const & orientation
407 )
408 {
409  restype_name1_ = resname1;
410  res1_atom1_name_ = res1_atom1;
411  res1_atom2_name_ = res1_atom2;
412  res1_atom3_name_ = res1_atom3;
413  restype_name2_ = "LG1"; //We need to give the second residue (ligand residue) some random name
414  res2_atom1_name_ = res2_atom1;
415  res2_atom2_name_ = res2_atom2;
416  res2_atom3_name_ = res2_atom3;
417 */
418 
419 /*
420 //Wasn't using this function, may want to put back in future.
421 void
422 Motif::generate_atom_ints(
423 )
424 {
425  core::chemical::AtomTypeSetCAP atset = core::chemical::ChemicalManager::get_instance()->atom_type_set( core::chemical::FA_STANDARD );
426  mt << "Res1: " << res1_atom1_name_ << res1_atom2_name_ << res1_atom3_name_ << " res2: " << res2_atom1_name_ << res2_atom2_name_ << res2_atom3_name_ << std::endl;
427 
428  // core::chemical::ResidueTypeSet & rsd_set( core::chemical::ChemicalManager::get_instance()->nonconst_residue_type_set( core::chemical::FA_STANDARD ) ); // Unused variable causes warning
429  // core::chemical::ResidueType const & rsd_type( rsd_set.name_map( restype_name1_ ) ); // Unused variable causes warning
430  // Size res1_atom1_index = rsd_type.atom_index( res1_atom1_name_ ); // Unused variable causes warning
431  // Size res1_atom2_index = rsd_type.atom_index( res1_atom2_name_ ); // Unused variable causes warning
432  // Size res1_atom3_index = rsd_type.atom_index( res1_atom3_name_ ); // Unused variable causes warning
433 
434  // FIXME: these local variables have the same name as data members!
435  // int res1_atom1_int_ = rsd_type.atom( res1_atom1_index).atom_type_index(); // Unused variable causes warning
436  // int res1_atom2_int_ = rsd_type.atom( res1_atom2_index ).atom_type_index(); // Unused variable causes warning
437  // int res1_atom3_int_ = rsd_type.atom( res1_atom3_index ).atom_type_index(); // Unused variable causes warning
438  int res2_atom1_int_ = atset->atom_type_index(res2_atom1_name_);
439  int res2_atom2_int_ = atset->atom_type_index(res2_atom2_name_);
440  int res2_atom3_int_ = atset->atom_type_index(res2_atom3_name_);
441  mt << " res2: " << res2_atom1_int_ << ", " << res2_atom2_int_ << ", " << res2_atom3_int_ << std::endl;
442  return;
443 }
444 */
445 
446 void
448  std::string const & remark_in
449 )
450 {
451  has_remark_ = true;
452  remark_ = remark_in;
453  return;
454 }
455 
456 void
458  std::string const & path_in
459 )
460 {
461  has_path_ = true;
462  path_ = path_in;
463  return;
464 }
465 
468  core::pose::Pose & pose,
469  Size const rotamer_build_position,
470  bool /*use_forward*/,
471  Size const ex_,
472  bool res2
473 ) const
474 {
475  using namespace core::pack::rotamer_set;
476  using namespace core::chemical;
477  using namespace core::scoring;
478  using namespace core::pack;
479  using namespace core::pack::task;
480 
481  RotamerSetFactory rsf;
482  RotamerSetOP rotset = rsf.create_rotamer_set( pose.residue( rotamer_build_position ) );
483  rotset->set_resid( rotamer_build_position );
484 
485  // Gather up the many things needed to build rotamers
486  ScoreFunction scorefxn;
487  scorefxn.set_weight( fa_atr, 1.00 );
488  scorefxn.set_weight( fa_rep, 1.00 );
489 
491  task->set_bump_check( false );
492  task->temporarily_fix_everything();
493  task->temporarily_set_pack_residue( rotamer_build_position, true );
495 
496  // Here's the aa to build
497  if( res2 ) {
498  aa_info[ aa_from_name( restype_name2() ) ] = true;
499  //use_forward = true; // set but never used ~Labonte
500  } else {
501  aa_info[ aa_from_name( restype_name1() ) ] = true;
502  //use_forward = false; // set but never used ~Labonte
503  }
504  // This functionality WILL fail if neither of the residues put into your constructor are amino acids
505  // Should put a safety check here to make sure that only amino acids are being rotamerized
506 
507  task->nonconst_residue_task( rotamer_build_position ).restrict_absent_canonical_aas( aa_info );
508 
509  //task->nonconst_residue_task( rotamer_build_position ).or_include_current( true );
510  // You can't "include_current" because there is no current or native residue
511  //task->nonconst_residue_task( rotamer_build_position).or_exrandom_sample_level(core::pack::task::NO_EXTRA_CHI_SAMPLES);
512  if( ex_ > 0 ) task->nonconst_residue_task( rotamer_build_position ).or_ex1( true );
513  if( ex_ > 1 ) task->nonconst_residue_task( rotamer_build_position ).or_ex2( true );
514  if( ex_ > 2 ) task->nonconst_residue_task( rotamer_build_position ).or_ex3( true );
515  if( ex_ > 3 ) task->nonconst_residue_task( rotamer_build_position ).or_ex4( true );
516  if( ex_ > 4 ) task->nonconst_residue_task( rotamer_build_position ).or_ex1_sample_level(core::pack::task::EX_FOUR_HALF_STEP_STDDEVS);
517  if( ex_ > 5 ) task->nonconst_residue_task( rotamer_build_position ).or_ex2_sample_level(core::pack::task::EX_FOUR_HALF_STEP_STDDEVS);
518  if( ex_ > 6 ) task->nonconst_residue_task( rotamer_build_position ).or_ex3_sample_level(core::pack::task::EX_FOUR_HALF_STEP_STDDEVS);
519  if( ex_ > 7 ) task->nonconst_residue_task( rotamer_build_position ).or_ex4_sample_level(core::pack::task::EX_FOUR_HALF_STEP_STDDEVS);
520 
521  scorefxn( pose );
522 
523  core::graph::GraphOP packer_neighbor_graph = create_packer_graph( pose, scorefxn, task );
524 
525  rotset->build_rotamers( pose, scorefxn, *task, packer_neighbor_graph, false );
526 
527  return rotset;
528 }
529 
532  core::pose::Pose & pose,
533  Size const motif_anchor_position,
534  bool use_forward,
535  Size rotamer_build_position
536 ) const
537 {
538  using namespace core::pack::rotamer_set;
539  using namespace core::chemical;
540  using namespace core::scoring;
541  using namespace core::pack;
542  using namespace core::pack::task;
543 
544 
545  // If no build position was passed, it will be the default value ( 0 ),
546  // and we need to find the closest bb position to the anchor residue
547  if( rotamer_build_position == Size( 0 ) ) {
548  // Find closest
549  // *********** TO DO ************
550  mt << "Using nonsense build residue in build_motif_rotamer - default argument not yet supported\n";
551  rotamer_build_position = 2;
552  }
553 
554  RotamerSetOP rotset;
555 
556  // Check to make sure the motif applies to the anchor residue
557  if( !apply_check( pose, motif_anchor_position ) ) {
558  mt << "Bailing from build_motif_rotamer - given anchor residue not in motif\n";
559  return rotset;
560  }
561 
562  rotset = build_rotamers( pose, rotamer_build_position, use_forward, forward_check( pose.residue(motif_anchor_position) ), use_forward );
563 
564  // Invert the rotamer library as specified by the motif
565  for( Size ir = 1 , end_ir = rotset->num_rotamers() ; ir <= end_ir ; ++ir ) {
566  place_residue( pose.residue( motif_anchor_position ), *(rotset->nonconst_rotamer( ir )) );
567  }
568 
569  return rotset;
570 }
571 
572 // place_atoms for ligands
573 void
575  core::conformation::Residue const & fixed,
577  utility::vector1< Size > const & atoms,
578  Size const & res2_atom1_index_in,
579  Size const & res2_atom2_index_in,
580  Size const & res2_atom3_index_in,
581  bool one_three
582 ) const
583 {
584 std::string ligand_name( "LG1" );
585 /* if( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) &&
586  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name2_ ) ) {
587  return place_atoms_( fixed, mobile, true, atoms, one_three );
588 
589  } else if ( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name2_ ) &&
590  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name1_ ) ) {
591  return place_atoms_( fixed, mobile, false, atoms, one_three );
592 
593  } else*/ if ( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) &&
594  utility::trimmed_compare( ligand_name , restype_name2_ ) ) {
595  return place_atoms_( fixed, mobile, true, atoms, res2_atom1_index_in, res2_atom2_index_in, res2_atom3_index_in, one_three ); //This is Matt's new test for ligands
596  } else {
597  mt << "Bad Mojo a! call to Motif::place_atom() with wrong residue(s)!\n";
598  mt << "Motif wants: " << restype_name1_ << " and " << restype_name2_ << "\n";
599  mt << "arguments are: " << fixed.name3() << " and " << mobile.name3() << "\n";
600  mt << "Neither order matches!\n";
601  }
602 
603  return;
604 }
605 
606 // place_atom for ligands
607 void
609  core::conformation::Residue const & fixed,
612  Size const & res2_atom1_index_in,
613  Size const & res2_atom2_index_in,
614  Size const & res2_atom3_index_in,
615  //std::string const & atomtype,
616  Size const & atomtype,
617  bool one_three
618 ) const
619 {
620  return place_atom_( fixed, mobile, true, atm, res2_atom1_index_in, res2_atom2_index_in, res2_atom3_index_in, atomtype, one_three );
621 }
622 
623 // place_residue for ligands
624 void
626  core::conformation::Residue const & fixed,
628  Size const & res2_atom1_index_in,
629  Size const & res2_atom2_index_in,
630  Size const & res2_atom3_index_in,
631  bool one_three
632 ) const
633 {
634 //restype_name1_ is amino acid
635 //restype_name2_ is ligand
636 //fixed should be amino acid
637 //mobile should be ligand (are there counterexamples?)
638 std::string ligand_name( "LG1" );
639  if( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) ) {
640  return Motif::place_residue_( fixed, mobile, true,res2_atom1_index_in, res2_atom2_index_in, res2_atom3_index_in, one_three );
641 
642  } else if ( utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name1_ ) ) {
643  return Motif::place_residue_( fixed, mobile, false, res2_atom1_index_in, res2_atom2_index_in, res2_atom3_index_in, one_three );
644  } else {
645  mt << "Bad Mojo b! call to Motif::place_residue() with wrong residue(s)!\n";
646  mt << "Motif wants: " << restype_name1_ << " and " << restype_name2_ << "\n";
647  mt << "arguments are: " << fixed.name3() << " and " << mobile.name3() << "\n";
648  mt << "Neither order matches!\n";
649  }
650 
651  return;
652 }
653 
654 //Matt's place_atom_ (this is where atoms are actually placed)
655 void
657  core::conformation::Residue const & fixed,
659  bool forward,
661  Size const & res2_atom1_index_in,
662  Size const & res2_atom2_index_in,
663  Size const & res2_atom3_index_in,
664  //std::string const & atomtype,
665  Size const & atomtype,
666  bool one_three
667 ) const
668 {
669  core::kinematics::Stub end_stub;
670  core::kinematics::Stub mobile_stub;
671  core::kinematics::Stub start_stub1;
672 
673  if( forward ) {
674  // Extract a stub from the fixed residue
675  if( one_three ) {
676  core::kinematics::Stub start_stub(
677  fixed.atom( res1_atom2_index_ ).xyz(),
678  fixed.atom( res1_atom1_index_ ).xyz(),
679  fixed.atom( res1_atom2_index_ ).xyz(),
680  fixed.atom( res1_atom3_index_ ).xyz()
681  );
682  start_stub1 = start_stub;
683  } else {
684  core::kinematics::Stub start_stub(
685  fixed.atom( res1_atom2_index_ ).xyz(),
686  fixed.atom( res1_atom3_index_ ).xyz(),
687  fixed.atom( res1_atom2_index_ ).xyz(),
688  fixed.atom( res1_atom1_index_ ).xyz()
689  );
690  start_stub1 = start_stub;
691  }
692 
693  mobile_stub.from_four_points(
694  mobile.atom( res2_atom2_index_in ).xyz(),
695  mobile.atom( res2_atom1_index_in ).xyz(),
696  mobile.atom( res2_atom2_index_in ).xyz(),
697  mobile.atom( res2_atom3_index_in ).xyz()
698  );
699 
700  // Get the stub at the other end of the jump
701  forward_jump_.make_jump( start_stub1, end_stub );
702  } else {
703  // Extract a stub from the fixed residue
704  core::kinematics::Stub start_stub(
705  fixed.atom( res2_atom2_index_in ).xyz(),
706  fixed.atom( res2_atom1_index_in ).xyz(),
707  fixed.atom( res2_atom2_index_in ).xyz(),
708  fixed.atom( res2_atom3_index_in ).xyz()
709  );
710 
711  if( one_three ) {
712  mobile_stub.from_four_points(
713  mobile.atom( res1_atom2_index_ ).xyz(),
714  mobile.atom( res1_atom1_index_ ).xyz(),
715  mobile.atom( res1_atom2_index_ ).xyz(),
716  mobile.atom( res1_atom3_index_ ).xyz()
717  );
718  } else {
719  mobile_stub.from_four_points(
720  mobile.atom( res1_atom2_index_ ).xyz(),
721  mobile.atom( res1_atom3_index_ ).xyz(),
722  mobile.atom( res1_atom2_index_ ).xyz(),
723  mobile.atom( res1_atom1_index_ ).xyz()
724  );
725  }
726 
727  // Get the stub at the other end of the jump
728  backward_jump_.make_jump( start_stub, end_stub );
729  }
730 
731  // Apply to the mobile residue
732  atm.xyz( end_stub.local2global( mobile_stub.global2local( mobile.xyz( atomtype ) ) ) );
733 
734  return;
735 }
736 
737 void
739  core::conformation::Residue const & fixed,
741  utility::vector1< std::string > const & atoms,
742  bool one_three
743 ) const
744 {
745  if( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) &&
746  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name2_ ) ) {
747  return place_atoms_( fixed, mobile, true, atoms, one_three );
748 
749  } else if ( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name2_ ) &&
750  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name1_ ) ) {
751  return place_atoms_( fixed, mobile, false, atoms, one_three );
752 
753  } else {
754  mt << "Bad Mojo! call to Motif::place_atom() with wrong residue(s)!\n";
755  mt << "Motif wants: " << restype_name1_ << " and " << restype_name2_ << "\n";
756  mt << "arguments are: " << fixed.name3() << " and " << mobile.name3() << "\n";
757  mt << "Neither order matches!\n";
758  }
759 
760  return;
761 }
762 
763 void
765  core::conformation::Residue const & fixed,
768  bool one_three,
769  std::string const atomtype
770 ) const
771 {
772  // PUT IN WARNING, ONLY CALL THIS FUNCTION WITH TRUE
773  // IE, WITH ATM BEING AN ATOM FROM THE MOBILE RESIDUE, NOT THE FIXED
774  return place_atom_( fixed, mobile, true, atm, one_three, atomtype );
775  /*if( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) &&
776  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name2_ ) ) {
777  return place_atom_( fixed, mobile, true, atm, one_three, atomtype );
778 
779  } else if ( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name2_ ) &&
780  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name1_ ) ) {
781  return place_atom_( fixed, mobile, false, atm, one_three, atomtype );
782 
783  } else {
784  mt << "Bad Mojo! call to Motif::place_atom() with wrong residue(s)!\n";
785  mt << "Motif wants: " << restype_name1_ << " and " << restype_name2_ << "\n";
786  mt << "arguments are: " << fixed.name3() << " and " << mobile.name3() << "\n";
787  mt << "Neither order matches!\n";
788  }
789 
790  return;*/
791 }
792 
793 void
795  core::conformation::Residue const & fixed,
797  bool one_three
798 ) const
799 {
800  if( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name1_ ) &&
801  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name2_ ) ) {
802  return place_residue_( fixed, mobile, true, one_three );
803 
804  } else if ( utility::trimmed_compare( protocols::dna::dna_full_name3( fixed.name3() ), restype_name2_ ) &&
805  utility::trimmed_compare( protocols::dna::dna_full_name3( mobile.name3() ), restype_name1_ ) ) {
806  return place_residue_( fixed, mobile, false, one_three );
807 
808  } else {
809  mt << "Bad Mojo! call to Motif::place_residue() with wrong residue(s)!\n";
810  mt << "Motif wants: " << restype_name1_ << " and " << restype_name2_ << "\n";
811  mt << "arguments are: " << fixed.name3() << " and " << mobile.name3() << "\n";
812  mt << "Neither order matches!\n";
813  }
814 
815  return;
816 }
817 
818 void
820  core::conformation::Residue const & fixed,
822  bool forward,
823  bool one_three
824 ) const
825 {
826  core::kinematics::Stub end_stub;
827  core::kinematics::Stub mobile_stub;
828  core::kinematics::Stub start_stub1;
829 
830  if( forward ) {
831  // Extract a stub from the fixed residue
832  if( one_three ) {
833  core::kinematics::Stub start_stub(
834  fixed.atom( res1_atom2_name_ ).xyz(),
835  fixed.atom( res1_atom1_name_ ).xyz(),
836  fixed.atom( res1_atom2_name_ ).xyz(),
837  fixed.atom( res1_atom3_name_ ).xyz()
838  );
839  start_stub1 = start_stub;
840  } else {
841  core::kinematics::Stub start_stub(
842  fixed.atom( res1_atom2_name_ ).xyz(),
843  fixed.atom( res1_atom3_name_ ).xyz(),
844  fixed.atom( res1_atom2_name_ ).xyz(),
845  fixed.atom( res1_atom1_name_ ).xyz()
846  );
847  start_stub1 = start_stub;
848  }
849 
850  mobile_stub.from_four_points(
851  mobile.atom( res2_atom2_name_ ).xyz(),
852  mobile.atom( res2_atom1_name_ ).xyz(),
853  mobile.atom( res2_atom2_name_ ).xyz(),
854  mobile.atom( res2_atom3_name_ ).xyz()
855  );
856 
857  // Get the stub at the other end of the jump
858  forward_jump_.make_jump( start_stub1, end_stub );
859 
860  } else {
861  // Extract a stub from the fixed residue
862  core::kinematics::Stub start_stub(
863  fixed.atom( res2_atom2_name_ ).xyz(),
864  fixed.atom( res2_atom1_name_ ).xyz(),
865  fixed.atom( res2_atom2_name_ ).xyz(),
866  fixed.atom( res2_atom3_name_ ).xyz()
867  );
868 
869  // This one_three bool assumes that res1 is always the amino acid of a base-protein interaction
870  // The base will never need automorphism
871  if( one_three ) {
872  mobile_stub.from_four_points(
873  mobile.atom( res1_atom2_name_ ).xyz(),
874  mobile.atom( res1_atom1_name_ ).xyz(),
875  mobile.atom( res1_atom2_name_ ).xyz(),
876  mobile.atom( res1_atom3_name_ ).xyz()
877  );
878  } else {
879  mobile_stub.from_four_points(
880  mobile.atom( res1_atom2_name_ ).xyz(),
881  mobile.atom( res1_atom3_name_ ).xyz(),
882  mobile.atom( res1_atom2_name_ ).xyz(),
883  mobile.atom( res1_atom1_name_ ).xyz()
884  );
885  }
886 
887  // Get the stub at the other end of the jump
888  backward_jump_.make_jump( start_stub, end_stub );
889  }
890 
891  // Apply to the mobile residue
892  for( Size i(1), end_i = mobile.natoms() ; i <= end_i ; ++i ) {
893  mobile.set_xyz( i, end_stub.local2global( mobile_stub.global2local( mobile.xyz( i ) ) ) );
894  }
895 
896  return;
897 }
898 
899 // place_residue_ for ligand motifs
900 void
902  core::conformation::Residue const & fixed,
904  bool forward,
905  Size const & res2_atom1_index_in,
906  Size const & res2_atom2_index_in,
907  Size const & res2_atom3_index_in,
908  bool one_three
909 ) const
910 {
911  core::kinematics::Stub end_stub;
912  core::kinematics::Stub mobile_stub;
913  core::kinematics::Stub start_stub1;
914 
915  if( forward ) {
916  // Extract a stub from the fixed residue
917  if( one_three ) {
918  core::kinematics::Stub start_stub(
919  fixed.atom( res1_atom2_name_ ).xyz(),
920  fixed.atom( res1_atom1_name_ ).xyz(),
921  fixed.atom( res1_atom2_name_ ).xyz(),
922  fixed.atom( res1_atom3_name_ ).xyz()
923  );
924  start_stub1 = start_stub;
925  } else {
926  core::kinematics::Stub start_stub(
927  fixed.atom( res1_atom2_name_ ).xyz(),
928  fixed.atom( res1_atom3_name_ ).xyz(),
929  fixed.atom( res1_atom2_name_ ).xyz(),
930  fixed.atom( res1_atom1_name_ ).xyz()
931  );
932  start_stub1 = start_stub;
933  }
934 
935  mobile_stub.from_four_points(
936  mobile.atom( res2_atom2_index_in ).xyz(),
937  mobile.atom( res2_atom1_index_in ).xyz(),
938  mobile.atom( res2_atom2_index_in ).xyz(),
939  mobile.atom( res2_atom3_index_in ).xyz()
940  );
941  // Get the stub at the other end of the jump
942  forward_jump_.make_jump( start_stub1, end_stub );
943  } else {
944  // Extract a stub from the fixed residue
945  core::kinematics::Stub start_stub(
946  fixed.atom( res2_atom2_index_in ).xyz(),
947  fixed.atom( res2_atom1_index_in ).xyz(),
948  fixed.atom( res2_atom2_index_in ).xyz(),
949  fixed.atom( res2_atom3_index_in ).xyz()
950  );
951 
952  // This one_three bool assumes that res1 is always the amino acid of a base-protein interaction
953  // The base will never need automorphism
954  if( one_three ) {
955  mobile_stub.from_four_points(
956  mobile.atom( res1_atom2_name_ ).xyz(),
957  mobile.atom( res1_atom1_name_ ).xyz(),
958  mobile.atom( res1_atom2_name_ ).xyz(),
959  mobile.atom( res1_atom3_name_ ).xyz()
960  );
961  } else {
962  mobile_stub.from_four_points(
963  mobile.atom( res1_atom2_name_ ).xyz(),
964  mobile.atom( res1_atom3_name_ ).xyz(),
965  mobile.atom( res1_atom2_name_ ).xyz(),
966  mobile.atom( res1_atom1_name_ ).xyz()
967  );
968  }
969  // Get the stub at the other end of the jump
970  backward_jump_.make_jump( start_stub, end_stub );
971  }
972  // Apply to the mobile residue
973  for( Size i(1), end_i = mobile.natoms() ; i <= end_i ; ++i ) {
974  mobile.set_xyz( i, end_stub.local2global( mobile_stub.global2local( mobile.xyz( i ) ) ) );
975  }
976  return;
977 }
978 
979 void
981  core::conformation::Residue const & fixed,
983  bool forward,
985  bool one_three,
986  std::string const atomtype
987 ) const
988 {
989  core::kinematics::Stub end_stub;
990  core::kinematics::Stub mobile_stub;
991  core::kinematics::Stub start_stub1;
992 
993  if( forward ) {
994  // Extract a stub from the fixed residue
995  if( one_three ) {
996  core::kinematics::Stub start_stub(
997  fixed.atom( res1_atom2_index_ ).xyz(),
998  fixed.atom( res1_atom1_index_ ).xyz(),
999  fixed.atom( res1_atom2_index_ ).xyz(),
1000  fixed.atom( res1_atom3_index_ ).xyz()
1001  );
1002  start_stub1 = start_stub;
1003  } else {
1004  core::kinematics::Stub start_stub(
1005  fixed.atom( res1_atom2_index_ ).xyz(),
1006  fixed.atom( res1_atom3_index_ ).xyz(),
1007  fixed.atom( res1_atom2_index_ ).xyz(),
1008  fixed.atom( res1_atom1_index_ ).xyz()
1009  );
1010  start_stub1 = start_stub;
1011  }
1012 
1013  mobile_stub.from_four_points(
1014  mobile.atom( res2_atom2_index_ ).xyz(),
1015  mobile.atom( res2_atom1_index_ ).xyz(),
1016  mobile.atom( res2_atom2_index_ ).xyz(),
1017  mobile.atom( res2_atom3_index_ ).xyz()
1018  );
1019 
1020  // Get the stub at the other end of the jump
1021  forward_jump_.make_jump( start_stub1, end_stub );
1022  } else {
1023  // Extract a stub from the fixed residue
1024  core::kinematics::Stub start_stub(
1025  fixed.atom( res2_atom2_index_ ).xyz(),
1026  fixed.atom( res2_atom1_index_ ).xyz(),
1027  fixed.atom( res2_atom2_index_ ).xyz(),
1028  fixed.atom( res2_atom3_index_ ).xyz()
1029  );
1030 
1031  if( one_three ) {
1032  mobile_stub.from_four_points(
1033  mobile.atom( res1_atom2_index_ ).xyz(),
1034  mobile.atom( res1_atom1_index_ ).xyz(),
1035  mobile.atom( res1_atom2_index_ ).xyz(),
1036  mobile.atom( res1_atom3_index_ ).xyz()
1037  );
1038  } else {
1039  mobile_stub.from_four_points(
1040  mobile.atom( res1_atom2_index_ ).xyz(),
1041  mobile.atom( res1_atom3_index_ ).xyz(),
1042  mobile.atom( res1_atom2_index_ ).xyz(),
1043  mobile.atom( res1_atom1_index_ ).xyz()
1044  );
1045  }
1046 
1047  // Get the stub at the other end of the jump
1048  backward_jump_.make_jump( start_stub, end_stub );
1049  }
1050 
1051  // Apply to the mobile residue
1052  atm.xyz( end_stub.local2global( mobile_stub.global2local( mobile.xyz( atomtype ) ) ) );
1053 
1054  return;
1055 }
1056 
1057 void
1059  core::conformation::Residue const & fixed,
1060  core::conformation::Residue & mobile,
1061  bool forward,
1062  utility::vector1< std::string > const & atoms,
1063  bool one_three
1064 ) const
1065 {
1066  core::kinematics::Stub end_stub;
1067  core::kinematics::Stub mobile_stub;
1068  core::kinematics::Stub start_stub1;
1069 
1070  if( forward ) {
1071  // Extract a stub from the fixed residue
1072  if( one_three ) {
1073  core::kinematics::Stub start_stub(
1074  fixed.atom( res1_atom2_name_ ).xyz(),
1075  fixed.atom( res1_atom1_name_ ).xyz(),
1076  fixed.atom( res1_atom2_name_ ).xyz(),
1077  fixed.atom( res1_atom3_name_ ).xyz()
1078  );
1079  start_stub1 = start_stub;
1080  } else {
1081  core::kinematics::Stub start_stub(
1082  fixed.atom( res1_atom2_name_ ).xyz(),
1083  fixed.atom( res1_atom3_name_ ).xyz(),
1084  fixed.atom( res1_atom2_name_ ).xyz(),
1085  fixed.atom( res1_atom1_name_ ).xyz()
1086  );
1087  start_stub1 = start_stub;
1088  }
1089 
1090  mobile_stub.from_four_points(
1091  mobile.atom( res2_atom2_name_ ).xyz(),
1092  mobile.atom( res2_atom1_name_ ).xyz(),
1093  mobile.atom( res2_atom2_name_ ).xyz(),
1094  mobile.atom( res2_atom3_name_ ).xyz()
1095  );
1096 
1097  // Get the stub at the other end of the jump
1098  forward_jump_.make_jump( start_stub1, end_stub );
1099 
1100  } else {
1101  // Extract a stub from the fixed residue
1102  core::kinematics::Stub start_stub(
1103  fixed.atom( res2_atom2_name_ ).xyz(),
1104  fixed.atom( res2_atom1_name_ ).xyz(),
1105  fixed.atom( res2_atom2_name_ ).xyz(),
1106  fixed.atom( res2_atom3_name_ ).xyz()
1107  );
1108 
1109  if( one_three ) {
1110  mobile_stub.from_four_points(
1111  mobile.atom( res1_atom2_name_ ).xyz(),
1112  mobile.atom( res1_atom1_name_ ).xyz(),
1113  mobile.atom( res1_atom2_name_ ).xyz(),
1114  mobile.atom( res1_atom3_name_ ).xyz()
1115  );
1116  } else {
1117  mobile_stub.from_four_points(
1118  mobile.atom( res1_atom2_name_ ).xyz(),
1119  mobile.atom( res1_atom3_name_ ).xyz(),
1120  mobile.atom( res1_atom2_name_ ).xyz(),
1121  mobile.atom( res1_atom1_name_ ).xyz()
1122  );
1123  }
1124 
1125  // Get the stub at the other end of the jump
1126  backward_jump_.make_jump( start_stub, end_stub );
1127  }
1128 
1129  // Apply to the mobile residue
1130  for( Size i(1), end_i = atoms.size() ; i <= end_i ; ++i ) {
1131  mobile.set_xyz( atoms[i], end_stub.local2global( mobile_stub.global2local( mobile.xyz( atoms[i] ) ) ) );
1132  }
1133 
1134  return;
1135 }
1136 
1137 // place_atoms_ for ligands
1138 void
1140  core::conformation::Residue const & fixed,
1141  core::conformation::Residue & mobile,
1142  bool forward,
1143  utility::vector1< Size > const & atoms,
1144  Size const & res2_atom1_index_in,
1145  Size const & res2_atom2_index_in,
1146  Size const & res2_atom3_index_in,
1147  bool one_three
1148 ) const
1149 {
1150  core::kinematics::Stub end_stub;
1151  core::kinematics::Stub mobile_stub;
1152  core::kinematics::Stub start_stub1;
1153 
1154  if( forward ) {
1155  // Extract a stub from the fixed residue
1156  if( one_three ) {
1157  core::kinematics::Stub start_stub(
1158  fixed.atom( res1_atom2_name_ ).xyz(),
1159  fixed.atom( res1_atom1_name_ ).xyz(),
1160  fixed.atom( res1_atom2_name_ ).xyz(),
1161  fixed.atom( res1_atom3_name_ ).xyz()
1162  );
1163  start_stub1 = start_stub;
1164  } else {
1165  core::kinematics::Stub start_stub(
1166  fixed.atom( res1_atom2_name_ ).xyz(),
1167  fixed.atom( res1_atom3_name_ ).xyz(),
1168  fixed.atom( res1_atom2_name_ ).xyz(),
1169  fixed.atom( res1_atom1_name_ ).xyz()
1170  );
1171  start_stub1 = start_stub;
1172  }
1173 
1174  mobile_stub.from_four_points(
1175  mobile.atom( res2_atom2_index_in ).xyz(),
1176  mobile.atom( res2_atom1_index_in ).xyz(),
1177  mobile.atom( res2_atom2_index_in ).xyz(),
1178  mobile.atom( res2_atom3_index_in ).xyz()
1179  );
1180 
1181  // Get the stub at the other end of the jump
1182  forward_jump_.make_jump( start_stub1, end_stub );
1183 
1184  } else {
1185  // Extract a stub from the fixed residue
1186  core::kinematics::Stub start_stub(
1187  fixed.atom( res2_atom2_index_in ).xyz(),
1188  fixed.atom( res2_atom1_index_in ).xyz(),
1189  fixed.atom( res2_atom2_index_in ).xyz(),
1190  fixed.atom( res2_atom3_index_in ).xyz()
1191  );
1192 
1193  if( one_three ) {
1194  mobile_stub.from_four_points(
1195  mobile.atom( res1_atom2_name_ ).xyz(),
1196  mobile.atom( res1_atom1_name_ ).xyz(),
1197  mobile.atom( res1_atom2_name_ ).xyz(),
1198  mobile.atom( res1_atom3_name_ ).xyz()
1199  );
1200  } else {
1201  mobile_stub.from_four_points(
1202  mobile.atom( res1_atom2_name_ ).xyz(),
1203  mobile.atom( res1_atom3_name_ ).xyz(),
1204  mobile.atom( res1_atom2_name_ ).xyz(),
1205  mobile.atom( res1_atom1_name_ ).xyz()
1206  );
1207  }
1208 
1209  // Get the stub at the other end of the jump
1210  backward_jump_.make_jump( start_stub, end_stub );
1211  }
1212 
1213  // Apply to the mobile residue
1214  for( Size i(1), end_i = atoms.size() ; i <= end_i ; ++i ) {
1215  mobile.set_xyz( atoms[i], end_stub.local2global( mobile_stub.global2local( mobile.xyz( atoms[i] ) ) ) );
1216  }
1217 
1218  return;
1219 }
1220 
1221 void
1222 Motif::print( std::ostream & out ) const
1223 {
1224 
1225  out << "SINGLE " << restype_name1() << " " << res1_atom1_name()
1226  << " " << res1_atom2_name()
1227  << " " << res1_atom3_name()
1228  << " " << restype_name2() << " " << res2_atom1_name()
1229  << " " << res2_atom2_name()
1230  << " " << res2_atom3_name();// << '\n';
1231 
1232  if( has_remark() ) {
1233  out << " ### REMARK " << remark();
1234  }
1235  out << '\n';
1236 
1237  out << forward_jump() << '\n';
1238 
1239 }
1240 
1243 {
1244  std::ostringstream os;
1245  print( os );
1246  return os.str();
1247 }
1248 
1249 std::ostream & operator <<(
1250  std::ostream & os,
1251  Motif const & motif
1252 )
1253 {
1254  os << motif.print();
1255  return os;
1256 }
1257 
1258 // Map of the atoms that are used in each motif, residues can be added to this file or modified if you want to use a different set of atoms (or you can use the alternative constructor that allows you set up the motif explicitly
1259 std::map < std::string, utility::vector1< std::string > > Motif::motifAtomIDs(
1260  utility::tools::make_map(
1261  std::string("ADE"), utility::tools::make_vector1( std::string("N6"), std::string("C5"), std::string("N7") ),
1262  std::string("CYT"), utility::tools::make_vector1( std::string("N4"), std::string("C4"), std::string("C5") ),
1263  std::string("GUA"), utility::tools::make_vector1( std::string("O6"), std::string("C5"), std::string("N7") ),
1264  std::string("THY"), utility::tools::make_vector1( std::string("O4"), std::string("C5"), std::string("C5M") ),
1265  std::string("ALA"), utility::tools::make_vector1( std::string("CB"), std::string("CA"), std::string("N") ),
1266  std::string("CYS"), utility::tools::make_vector1( std::string("SG"), std::string("CB"), std::string("CA") ),
1267  std::string("ASP"), utility::tools::make_vector1( std::string("OD1"), std::string("CG"), std::string("OD2") ),
1268  std::string("GLU"), utility::tools::make_vector1( std::string("OE1"), std::string("CD"), std::string("OE2") ),
1269  std::string("PHE"), utility::tools::make_vector1( std::string("CE1"), std::string("CZ"), std::string("CE2") ),
1270  std::string("HIS"), utility::tools::make_vector1( std::string("ND1"), std::string("CE1"), std::string("NE2") ),
1271  std::string("ILE"), utility::tools::make_vector1( std::string("CG1"), std::string("CB"), std::string("CG2") ),
1272  std::string("LYS"), utility::tools::make_vector1( std::string("NZ"), std::string("CE"), std::string("CD") ),
1273  std::string("LEU"), utility::tools::make_vector1( std::string("CD1"), std::string("CG"), std::string("CD2") ),
1274  std::string("MET"), utility::tools::make_vector1( std::string("CG"), std::string("SD"), std::string("CE") ),
1275  std::string("ASN"), utility::tools::make_vector1( std::string("OD1"), std::string("CG"), std::string("ND2") ),
1276  std::string("GLN"), utility::tools::make_vector1( std::string("OE1"), std::string("CD"), std::string("NE2") ),
1277  std::string("PRO"), utility::tools::make_vector1( std::string("CG"), std::string("CD"), std::string("NV") ),
1278  std::string("ARG"), utility::tools::make_vector1( std::string("NH1"), std::string("CZ"), std::string("NH2") ),
1279  std::string("SER"), utility::tools::make_vector1( std::string("OG"), std::string("CB"), std::string("CA") ),
1280  std::string("THR"), utility::tools::make_vector1( std::string("OG1"), std::string("CB"), std::string("CG2") ),
1281  std::string("VAL"), utility::tools::make_vector1( std::string("CG1"), std::string("CB"), std::string("CG2") ),
1282  std::string("TRP"), utility::tools::make_vector1( std::string("CG"), std::string("CD2"), std::string("CE2") ),
1283  std::string("TYR"), utility::tools::make_vector1( std::string("CE1"), std::string("CZ"), std::string("CE2") )
1284  ) );
1285 
1286 // Map of atoms used for base-base motifs
1287 // Do not try to use rotamer building functions if the motifs are basebase
1288 // This map isn't really used at this point
1289 std::map < std::string, utility::vector1< std::string > > Motif::basebaseAtomIDs(
1290  utility::tools::make_map(
1291  std::string("ADE"), utility::tools::make_vector1( std::string("N6"), std::string("N1"), std::string("C2") ),
1292  std::string("CYT"), utility::tools::make_vector1( std::string("N4"), std::string("N3"), std::string("O2") ),
1293  std::string("GUA"), utility::tools::make_vector1( std::string("O6"), std::string("N1"), std::string("N2") ),
1294  std::string("THY"), utility::tools::make_vector1( std::string("O4"), std::string("N3"), std::string("O2") )
1295  ) );
1296 
1297 } // namespace motifs
1298 } // namespace protocols