Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fibril_util.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/fibril/fibril_util.hh
10 /// @brief utility functions for handling of fibril symmetry modeling
11 /// @author Lin Jiang
12 
13 // Unit headers
16 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
17 
18 // AUTO-REMOVED #include <core/conformation/symmetry/SymDof.hh>
19 #include <core/id/AtomID_Map.hh>
20 #include <core/id/AtomID.hh>
21 // AUTO-REMOVED #include <core/scoring/symmetry/SymmetricEnergies.hh>
22 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
23 #include <core/pose/Pose.hh>
24 #include <core/scoring/rms_util.hh>
26 // AUTO-REMOVED #include <core/chemical/ResidueTypeSet.hh>
27 // AUTO-REMOVED #include <core/kinematics/MoveMap.hh>
28 #include <protocols/loops/Loop.hh>
29 #include <protocols/loops/Loops.hh>
30 
31 // AUTO-REMOVED #include <core/init.hh>
32 
33 // Utility functions
34 #include <basic/options/option.hh>
35 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
36 #include <basic/options/keys/in.OptionKeys.gen.hh>
37 #include <basic/options/keys/loops.OptionKeys.gen.hh>
38 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
39 // AUTO-REMOVED #include <numeric/random/random.hh>
40 
41 // Package Headers
42 #include <core/kinematics/Edge.hh>
43 
44 #include <basic/Tracer.hh>
45 
46 // ObjexxFCL Headers
47 #include <ObjexxFCL/FArray1D.hh>
48 #include <ObjexxFCL/FArray2D.hh>
49 
52 #include <core/pose/util.hh>
53 #include <utility/vector1.hh>
54 #include <numeric/xyz.functions.hh>
55 
56 //Auto Headers
57 #include <core/pose/util.tmpl.hh>
58 //namespaces
59 using namespace core;
60 using namespace core::conformation;
61 using namespace core::conformation::symmetry;
62 using namespace utility;
63 
64 
65 namespace protocols {
66 namespace fibril {
67 
68 static basic::Tracer TR("protocols.moves.symmetry.fibril_util");
69  //static numeric::random::RandomGenerator RG(40811111); // <- Magic number, do not change it!!!
70 
71 //lin functions for xyz coordinate
72 bool
74  Vector const & origin,
75  Vector const & x,
76  Vector const & y,
77  Vector & z,
78  bool check_angle
79 )
80 {
81  if( check_angle ) {
82  Real const angle_xy ( numeric::angle_radians(x,origin,y) );
83  if( angle_xy - 0.5*numeric::NumericTraits<Real>::pi() > 1e-3 ) {
84  return false;
85  }
86  }
87  z = origin + ( x - origin ).cross( y - origin ) ;
88  return true;
89 }
90 
91 
92 /////////////////////////////////////////////////////////////////////////////
93 void
95  Conformation & src_conformation,
96  SymmData & symmdata
97 )
98 {
99  using namespace core::kinematics;
100  using namespace id;
101 
102  kinematics::FoldTree f( src_conformation.fold_tree() );
103  Size anchor ( utility::string2int(symmdata.get_anchor_residue()) );
104  Size next_anchor ( anchor <= src_conformation.size() - 2 ? anchor + 2 : anchor - 2 );
105  chemical::ResidueType const& rt1 ( src_conformation.residue_type ( anchor ) );
106  chemical::ResidueType const& rt2 ( src_conformation.residue_type ( next_anchor ) );
107  AtomID a1( rt1.atom_index ("C") , anchor );
108  AtomID a2( rt2.atom_index ("C") , next_anchor );
109  AtomID a3( rt1.atom_index ("O") , anchor );
110  Vector origin ( src_conformation.xyz(a1) );
111  Vector y ( src_conformation.xyz(a2) );
112  Vector z ( src_conformation.xyz(a3) );
113  Vector x;
114  set_xyz_coord( origin, y, z, x, false);
115  x = ( x - origin ).normalized() + origin;
116  z = ( z - origin ).normalized() + origin;
117  Stub const rot_stub ( origin, x, z );
118  Stub const src_stub ( Vector(0,0,0), Vector(1,0,0), Vector(0,0,1) );
119 
120  for ( Size i = 1; i <= src_conformation.size(); ++i ) {
121  for ( Size j = 1; j <= src_conformation.residue_type(i).natoms(); ++j ) {
122  AtomID id( j, i );
123  Vector const old_xyz( src_conformation.xyz(id) );
124  Vector const new_xyz( src_stub.local2global( rot_stub.global2local( old_xyz ) ) );
125  src_conformation.set_xyz( id, new_xyz );
126  }
127  }
128  //pose.apply_transform_Rx_plus_v( rt.get_rotation(), rt.get_translation() );
129 }
130 
131 /////////////////////////////////////////////////////////////////////////////
132 void
134  pose::Pose & pose
135 )
136 {
137  using namespace basic::options;
138  using namespace basic::options::OptionKeys;
139 
140 
141  SymmData symmdata( pose.n_residue(), pose.num_jump() );
142  std::string symm_def = option[ OptionKeys::symmetry::symmetry_definition ];
143  symmdata.read_symmetry_data_from_file(symm_def);
144  if( option[ in::file::native ].user() ) {
145  pose::Pose monomer_pose;
146  core::import_pose::pose_from_pdb( monomer_pose, option[ in::file::native ]().name() );
147  protocols::loops::Loops loop1, loop2;
148  bool default_loop_file_is_present = option[ OptionKeys::loops::loop_file ].user();
149  loop1 = protocols::loops::Loops( default_loop_file_is_present );
150  if( !default_loop_file_is_present ) {
151  //make for monomer_pose
152  loop1.push_back( protocols::loops::Loop( 1, monomer_pose.total_residue(), 0, 0.0, false) );
153  }
154  if( option[ OptionKeys::loops::extended_loop_file ].user() ) {
155  loop2 = protocols::loops::Loops( option[ OptionKeys::loops::extended_loop_file ]() );
156  } else {
157  loop2 = loop1;
158  }
159  //monomer_pose.dump_pdb("before.pdb");
160  protocols::fibril::superimpose_pose_on_subset_bb( pose, monomer_pose, loop1, loop2 );
161  //monomer_pose.dump_pdb("after.pdb");
162  } else if( option[ in::file::alignment ].user() ) {
164  }
166  std::cout<<"fold tree: "<<pose.fold_tree()<<std::endl;
167 }
168 
169 /////////////////////////////////////////////////////////////////////////////
170 void
172  pose::Pose& pose,
173  pose::Pose& ref_pose,
175  protocols::loops::Loops ref_core
176 )
177 {
178 
179  using namespace protocols;
180  using namespace core::scoring;
181 
182  //set atom map for superimpose_pose
184  core::pose::initialize_atomid_map( atom_map, pose, core::id::BOGUS_ATOM_ID ); // maps every atomid to bogus atom
185 
188 
189  for ( loops::Loops::const_iterator region = core.begin(); region != core.end(); ++region ) {
190  for ( core::Size i=region->start(); i<= region->stop(); ++i ){
191  core::id::AtomID dummy_atomid1( pose.residue(i).atom_index("CA"), i);
192  ids.push_back(dummy_atomid1);
193  core::id::AtomID dummy_atomid2( pose.residue(i).atom_index("N"), i);
194  ids.push_back(dummy_atomid2);
195  core::id::AtomID dummy_atomid3( pose.residue(i).atom_index("C"), i);
196  ids.push_back(dummy_atomid3);
197  core::id::AtomID dummy_atomid4( pose.residue(i).atom_index("O"), i);
198  ids.push_back(dummy_atomid4);
199  }
200  }
201 
202  for ( loops::Loops::const_iterator region = ref_core.begin(); region != ref_core.end(); ++region ) {
203  for ( core::Size i=region->start(); i<= region->stop(); ++i ){
204  core::id::AtomID dummy_atomid1( ref_pose.residue(i).atom_index("CA"), i);
205  ref_ids.push_back(dummy_atomid1);
206  core::id::AtomID dummy_atomid2( ref_pose.residue(i).atom_index("N"), i);
207  ref_ids.push_back(dummy_atomid2);
208  core::id::AtomID dummy_atomid3( ref_pose.residue(i).atom_index("C"), i);
209  ref_ids.push_back(dummy_atomid3);
210  core::id::AtomID dummy_atomid4( ref_pose.residue(i).atom_index("O"), i);
211  ref_ids.push_back(dummy_atomid4);
212  }
213  }
214  assert( ids.size()== ref_ids.size());
215 
216  for ( core::Size i=1; i<=ids.size(); ++i ) {
217  atom_map.set( ids[i], ref_ids[i] );
218  }
219  superimpose_pose( pose, ref_pose, atom_map );
220 }
221 
222 } // fibril
223 } // protocols