Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JumpSRFD.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/fragments/JumpSRFD.cc
12 /// @brief A fragment that changes a RigidBody Transform ( Jump )
13 /// @author Oliver Lange (olange@u.washington.edu)
14 /// @date Wed Oct 20 12:08:31 2007
15 ///
16 
17 
18 // Unit Headers
20 
21 // Package Headers
22 // AUTO-REMOVED #include <core/fragment/FragData.hh>
23 #include <core/fragment/Frame.hh>
24 
25 // Project Headers
27 #include <core/pose/Pose.hh>
28 #include <core/pose/util.hh>
29 
30 #include <core/id/AtomID.hh>
31 #include <core/id/NamedStubID.hh>
32 
33 #include <core/kinematics/Jump.hh>
35 
36 // ObjexxFCL Headers
37 #include <ObjexxFCL/format.hh>
38 
39 // Utility headers
40 #include <utility/vector1.fwd.hh>
41 #include <basic/Tracer.hh>
42 
43 #include <utility/vector1.hh>
44 
45 //Auto Headers
47 
48 namespace core {
49 namespace fragment {
50 
51 using namespace ObjexxFCL::fmt;
52 
53 static basic::Tracer tr("core.fragment.JumpSRFD");
54 using namespace core::id;
55 //void DownJumpSRFD::get_stubs( pose::Pose const& pose, Size downstream_res_nr, id::StubID &up_stub, id::StubID &down_stub ) const {
56 
57  // kinematics::Edge jump_edge = pose.fold_tree().get_residue_edge( downstream_res_nr );
58  // runtime_assert( jump_edge.is_jump() ); // being paranoid
59  //work out upstream and downstream residue
60  // Size res1=jump_edge.start();
61  //Size res2=jump_edge.stop();
62  //obsolet code:
63 // runtime_assert( 0 );
64  //up_stub = StubID( NamedStubID( upstream_stub_atoms_, res1 ), pose );
65  // down_stub = StubID( NamedStubID( downstream_stub_atoms_, res2 ), pose );
66 
67 
68 // // work out the stubID
69 // chemical::ResidueType const& rt1 ( pose.residue_type ( res1 ) );
70 // chemical::ResidueType const& rt2 ( pose.residue_type ( res2 ) );
71 
72 // id::AtomID b1( rt2.atom_index (upstream_stub_atoms_[ 1 ]) , res2 );
73 // id::AtomID b2( rt2.atom_index (upstream_stub_atoms_[ 2 ]) , res2 );
74 // id::AtomID b3( rt2.atom_index (upstream_stub_atoms_[ 3 ]) , res2 );
75 // up_stub = id::StubID( b1, b2, b3 );
76 
77 // id::AtomID a1( rt1.atom_index (downstream_stub_atoms_[ 1 ]) , res1 );
78 // id::AtomID a2( rt1.atom_index (downstream_stub_atoms_[ 2 ]) , res1 );
79 // id::AtomID a3( rt1.atom_index (downstream_stub_atoms_[ 3 ]) , res1 );
80 // down_stub = id::StubID( a1, a2, a3 );
81 
82 //}
83 
84 
85 /// @brief for DownJumpSRFD this function should never be called, instead use Frame version
86 /// @return always false
87 /// @warning will trigger a false runtime assert
88 bool DownJumpSRFD::apply( kinematics::MoveMap const &, pose::Pose &, Size const ) const {
89  runtime_assert( 0 );
90  return false;
91 }
92 
93 
94 bool DownJumpSRFD::apply( pose::Pose& pose, Size ipos, Frame const& frame ) const {
95  //at this point we are the downstream partner
96  runtime_assert( ipos > 1 );
97  Size const upstream_resnr ( frame.seqpos( ipos-1 ) );
98  Size const downstream_resnr( frame.seqpos( ipos ) );
99  tr.Trace << "DownJumpSRFD applied for jump " << upstream_resnr << " ---> "<< downstream_resnr << std::endl;
100 
101  //check if there is a jump!
102  bool has_jump ( pose.fold_tree().is_jump_point( upstream_resnr ) && pose.fold_tree().is_jump_point( downstream_resnr ) );
103  if ( !has_jump ) {
104  tr.Warning << "WARNING: DownJump-Frag could not be applied to current pose... need to have a jump at "
105  << upstream_resnr << " " << downstream_resnr << std::endl;
106  return false;
107  }
108 
109  // do the dof-change
110  id::StubID up_stub( pose::named_stub_id_to_stub_id( NamedStubID( upstream_stub_atoms_, upstream_resnr ), pose ) );
111  id::StubID down_stub( pose::named_stub_id_to_stub_id( NamedStubID( downstream_stub_atoms_, downstream_resnr ), pose ) );
112  tr.Trace << "apply stub transform to " << std::endl;
113  tr.Trace << "up stub: " << NamedStubID( upstream_stub_atoms_, upstream_resnr ) << std::endl;
114  tr.Trace << "down stub: " << NamedStubID( downstream_stub_atoms_, downstream_resnr ) << std::endl;
115  pose.conformation().set_stub_transform( up_stub, down_stub, rt_ );
116  return true;
117 }
118 
119 
121  kinematics::MoveMap const & movemap,
122  pose::Pose & pose,
123  Size const intra_frame_pos,
124  Frame const & frame
125 ) const {
126 
127  Size const upstream_resnr( frame.seqpos( intra_frame_pos - 1 ) );
128  Size const downstream_resnr( frame.seqpos( intra_frame_pos ) );
129 
130  if ( movemap.get_jump( upstream_resnr, downstream_resnr ) ) {
131  return apply( pose, intra_frame_pos, frame );
132  } else {
133  return false;
134  }
135 }
136 
137 
138 bool DownJumpSRFD::steal( pose::Pose const& pose, Size ipos, Frame const& frame ) {
139  //at this point we are the downstream partner
140  runtime_assert( ipos > 1 );
141  Size const upstream_resnr ( frame.seqpos( ipos-1 ) );
142  Size const downstream_resnr( frame.seqpos( ipos ) );
143 
144 
145  id::StubID up_stub( pose::named_stub_id_to_stub_id( NamedStubID( upstream_stub_atoms_, upstream_resnr ), pose ) );
146  id::StubID down_stub( pose::named_stub_id_to_stub_id( NamedStubID( downstream_stub_atoms_, downstream_resnr ), pose ) );
147  rt_ = pose.conformation().get_stub_transform( up_stub, down_stub );
148  return true; //can something go wrong ? check has_torsion() ?
149 }
150 
152  //DownJumpSRFD const* ptr = dynamic_cast< DownJumpSRFD const* > ( & aSRFD );
153  //if ( ptr ) {
154  // return true;
155  //}
156  return dynamic_cast< DownJumpSRFD const* > ( & aSRFD );
157 }
158 
159 
161  //UpJumpSRFD const* ptr = dynamic_cast< UpJumpSRFD const* > ( & aSRFD );
162  //if ( ptr ) {
163  // return true;
164  //}
165  return dynamic_cast< UpJumpSRFD const* > ( & aSRFD );
166 }
167 
169  kinematics::MoveMap const& move_map,
170  Size ipos,
171  Frame const& frame
172 ) const {
173  runtime_assert( ipos > 1 ); //UpJump DownJump: must be at least second in Frame
174  Size const upstream_resnr ( frame.seqpos( ipos-1 ) );
175  Size const downstream_resnr( frame.seqpos( ipos ) );
176  return move_map.get_jump( upstream_resnr, downstream_resnr );
177 }
178 
179 
180 void DownJumpSRFD::set_stub_atoms( AtomList downstream, AtomList upstream ) {
181  upstream_stub_atoms_ = upstream;
182  downstream_stub_atoms_ = downstream;
183 }
184 
186  downstream_stub_atoms_.reserve(4);
187  downstream_stub_atoms_.push_back( "CA" );
188  downstream_stub_atoms_.push_back( "N" );
189  downstream_stub_atoms_.push_back( "CA" );
190  downstream_stub_atoms_.push_back( "C" );
191  upstream_stub_atoms_ = downstream_stub_atoms_;
192 }
193 
194 
195 void DownJumpSRFD::show( std::ostream &out ) const {
196  Parent::show( out );
197 
198  //only the downstream_partner has to show his cards
199  out << " "<< rt_;
200  out << " UPSTUB ";
201  for ( AtomList::const_iterator it = upstream_stub_atoms_.begin(),
202  eit = upstream_stub_atoms_.end(); it!=eit; ++it ) {
203  out << A(3, (*it));
204  }
205  if ( upstream_stub_atoms_ != downstream_stub_atoms_ ) {
206  out << " DOWNSTUB ";
207  for ( AtomList::const_iterator it = downstream_stub_atoms_.begin(),
208  eit = downstream_stub_atoms_.end(); it!=eit; ++it ) {
209  out << A(3, (*it));
210  }
211  }
212 }
213 
214 void DownJumpSRFD::read( std::istream &in ) {
215  Parent::read_data( in );
216  in >> rt_;
217  tr.Trace << "read RT " << rt_ << " status of stream: " << (in.fail() ? "FAIL" : "GOOD" ) << std::endl;
218 
219  std::string line;
220  getline( in, line );
221  std::istringstream is( line );
222 
223  std::string tag;
224  is >> tag;
225  if ( !is.fail() && tag == "UPSTUB" ) {
226  upstream_stub_atoms_.clear();
227  while ( is >> tag ) {
228  if ( tag == "DOWNSTUB" ) break;
229  upstream_stub_atoms_.push_back( tag );
230  }
231  if ( !is.fail() && tag == "DOWNSTUB" ) {
232  downstream_stub_atoms_.clear();
233  while ( is >> tag ) {
234  downstream_stub_atoms_.push_back( tag );
235  }
236  } else {
237  downstream_stub_atoms_=upstream_stub_atoms_;
238  }
239  } else {
240  set_standard_stub_atoms();
241  }
242  tr.Trace << "set the STUB atoms: " << std::endl;
243  tr.Trace << " UPSTUB ";
244  for ( AtomList::const_iterator it = upstream_stub_atoms_.begin(),
245  eit = upstream_stub_atoms_.end(); it!=eit; ++it ) {
246  tr.Trace << A(3, (*it));
247  }
248  tr.Trace << " DOWNSTUB ";
249  for ( AtomList::const_iterator it = downstream_stub_atoms_.begin(),
250  eit = downstream_stub_atoms_.end(); it!=eit; ++it ) {
251  tr.Trace << A(3, (*it));
252  }
253  if ( upstream_stub_atoms_.size() != 4 || downstream_stub_atoms_.size() !=4 ) {
254  utility_exit_with_message( "[ERROR] reading JumpSRFD... need 4 or NONE of the stub atoms...");
255  }
256  tr.Trace << std::endl;
257 }
258 
259 } //fragment
260 } //core