Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResiduePairJumpSetup.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
11 /// @brief
12 /// @detailed
13 /// @author Chu Wang
14 ///
15 
16 
17 // Unit Headers
19 
20 // Package Headers
23 #include <core/fragment/Frame.hh>
25 #ifdef WIN32
26 #include <core/fragment/FragID.hh>
27 #endif
28 
32 
35 
36 // Project Headers
37 #include <basic/Tracer.hh>
38 
39 // Numeric headers
40 // AUTO-REMOVED #include <numeric/random/random.hh>
41 
42 // ObjexxFCL Headers
43 #include <ObjexxFCL/FArray2D.hh>
44 
45 // Utility headers
46 #include <utility/io/izstream.hh>
47 
49 #include <utility/vector1.hh>
50 #include <numeric/random/random.fwd.hh>
51 
52 
53 //numeric headers
54 
55 // C++ headers
56 
57 
58 namespace protocols {
59 namespace jumping {
60 
61 using namespace core;
62 using namespace fragment;
63 
64 static basic::Tracer tr("protocols.jumping");
65 
66 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67 void
69 
70 
71  utility::io::izstream data( fname.c_str() );
72  tr.Info << "read ResiduePair jump-definitions from " << fname << std::endl;
73  if ( !data ) {
74  utility_exit_with_message( "Unable to open constraints file: " + fname +"\n");
75  }
76 
77  core::chemical::ResidueTypeSetCAP residue_type_set(
79  );
80 
81  std::string line, tag;
82  core::Size root = 1;
83  ResiduePairJumpOP residue_pair_jump = NULL;
84  while ( getline(data, line ) ) {
85  std::istringstream in( line );
86  in >> tag;
87  if ( tag == "BEGIN" ) {
88  residue_pair_jump = new ResiduePairJump;
89  continue;
90  } else if ( tag == "END" ) {
91  residue_pair_jump->init_mini_pose();
92  add_residue_pair_jump( residue_pair_jump );
93  residue_pair_jump = NULL;
94  continue;
95  } else if ( tag == "ROOT" ) {
96  in >> root;
97  }
98 
99  if ( ! residue_pair_jump ) continue;
100 
101  if ( tag == "jump_def:" ) {
102  Interval jump, cuts;
103  in >> jump.start_ >> jump.end_ >> cuts.start_ >> cuts.end_;
104  add_jump( jump, cuts );
105  } else if ( tag == "aa:" ) {
106  for ( int i = 1; i <= 2; ++i ) {
107  std::string name;
108  in >> name;
109  if ( residue_type_set->name_map(name).is_protein() )
110  name = name + "_p:CtermProteinFull_p:NtermProteinFull";
111  core::chemical::ResidueType const & res_type( residue_type_set->name_map(name) );
112  residue_pair_jump->add_residue_single( res_type );
113  }
114  } else if ( tag == "cst_atoms:" ) {
115  for ( int i = 1; i <= 2; ++i ) {
116  std::string name;
117  for ( int j = 1; j <= 3; ++j ) {
118  in >> name;
119  residue_pair_jump->set_cstAtoms(i,j,name);
120  }
121  }
122  } else if ( tag == "jump_atoms:" ) {
123  for ( int i = 1; i <= 2; ++i ) {
124  std::string name;
125  for ( int j = 1; j <= 3; ++j ) {
126  in >> name;
127  residue_pair_jump->set_jumpAtoms(i,j,name);
128  }
129  }
130  } else if ( tag == "disAB:" ) {
131  Real value;
132  while (in >> value) {
133  residue_pair_jump->set_cstInfo( disAB, value );
134  }
135  } else if ( tag == "angleA:" ) {
136  Real value;
137  while (in >> value) {
138  residue_pair_jump->set_cstInfo( angleA, value );
139  }
140  } else if ( tag == "angleB:" ) {
141  Real value;
142  while (in >> value) {
143  residue_pair_jump->set_cstInfo( angleB, value );
144  }
145  } else if ( tag == "dihedralA:" ) {
146  Real value;
147  while (in >> value) {
148  residue_pair_jump->set_cstInfo( dihedralA, value );
149  }
150  } else if ( tag == "dihedralB:" ) {
151  Real value;
152  while (in >> value) {
153  residue_pair_jump->set_cstInfo( dihedralB, value );
154  }
155  } else if ( tag == "dihedralAB:" ) {
156  Real value;
157  while (in >> value) {
158  residue_pair_jump->set_cstInfo( dihedralAB, value );
159  }
160  }
161  }
162  set_root( root );
163 }
164 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
165 FragSetOP
167  OrderedFragSetOP frags = new OrderedFragSet;
168  FrameList jump_geometries;
169  //runtime_assert( jumps.total_residue() == total_residue() );
170  ObjexxFCL::FArray2D_int const & in_jumps ( jumps.jumps() );
171  int ct = 1;
172  for ( ResiduePairJumpSetup::const_iterator it=begin(), eit=end(); it!=eit; it++, ct++ ) {
173  Size jump_number = 0;
174  for ( Size i = 1; i <= jumps.size(); ++i ) {
175  if ( ( in_jumps( 1, i ) == int( it->jump_.start_) ) && ( in_jumps( 2, i ) == int( it->jump_.end_ ) ) ){
176  jump_number = i;
177  break;
178  }
179  }
180  // did not find a match jump, so skip
181  if ( jump_number == 0 ) continue;
182  // this jump is not a flexible jump
183  if ( ! mm.get_jump(jump_number) ) continue;
184  // generate a frame based on this ResiduePairJump
185  FrameOP jump_frame = ResiduePairJumps_[ct]->generate_frame();
186  jump_frame->show( tr.Info );
187  // map ResiduePairJump index 1 and 2 to the correct seqpos number defined in JumpSample
188  core::id::SequenceMapping map;// 2, jumps.total_residue());
189  map.insert_aligned_residue( 1, in_jumps(1,jump_number));
190  map.insert_aligned_residue( 2, in_jumps(2,jump_number));
191  // align the jump frame to the whole pose context so that they can be used in protocols level
192  jump_frame->align( map );
193  // save this frame to FrameList
194  jump_geometries.push_back( jump_frame);
195  }
196  // add FrameList to FragSet
197  frags->add( jump_geometries );
198 
199  return frags;
200 }
201 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
204 {
205  ObjexxFCL::FArray2D_int jumps( 2, jumps_.size() );
206  ObjexxFCL::FArray1D_int cuts( jumps_.size() );
207  ObjexxFCL::FArray2D<std::string> jump_atoms(2, jumps_.size(),"");
208 
209  int ct = 1;
210  Size total_residue = total_residue_;
211  for ( ResiduePairJumpSetup::const_iterator it=begin(), eit=end(); it!=eit; it++, ct++ ) {
212  jumps( 1, ct ) = it->jump_.start_;
213  jumps( 2, ct ) = it->jump_.end_;
214  Size const crs ( it->cut_reg_.start_ );
215  Size const cre ( it->cut_reg_.end_ );
216  if ( crs > total_residue ) total_residue = crs;
217  if ( cre > total_residue ) total_residue = cre;
218  if ( it->jump_.end_ > total_residue ) total_residue = it->jump_.end_;
219  if ( it->jump_.start_ > total_residue ) total_residue = it->jump_.start_;
220  cuts( ct ) = crs+int( numeric::random::uniform()*( cre-crs ) + 0.5 );
221  jump_atoms(1, ct) = ResiduePairJumps_[ct]->jumpAtoms(1)[1];
222  jump_atoms(2, ct) = ResiduePairJumps_[ct]->jumpAtoms(2)[1];
223  }
224  return JumpSample( total_residue, jumps_.size(), jumps, jump_atoms, cuts, root() );
225 }
226 
227 } //jumping
228 } //protocols