Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EnzdesCacheableObserver.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 .cc file for enzdes cacheable observer
11 /// @brief
12 /// @author Florian Richter, floric@u.washington.edu, september 09
13 
14 
15 //unit headers
17 
18 //package headers
22 
23 //project headers
24 #include <basic/Tracer.hh>
25 
30 #include <core/pose/Pose.hh>
35 //MSA
37 
39 
40 //utility headers
41 #include <utility/signals/Link.hh>
42 
43 //option key includes
44 #include <basic/options/option.hh>
45 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
46 #include <basic/options/keys/in.OptionKeys.gen.hh>
47 
48 #include <utility/vector1.hh>
49 
50 
51 namespace protocols {
52 namespace toolbox {
53 namespace match_enzdes_util {
54 
55 static basic::Tracer tr("protocols.enzdes.EnzdesCacheableObserver");
56 
57 
60  core::pose::Pose & pose )
61 {
62  //using namespace core::pose::datacache::CacheableObserverType;
63  using namespace core::pose::datacache;
64 
66 
69  //std::cout << " setting new cacheable observer for pose " << std::endl;
70  }
72  //return (pose.observer_cache().get_ptr( core::pose::datacache::CacheableObserverType::ENZDES_OBSERVER ) );
73  //std::cout << " returning nonconst enzdes observer " << std::endl;
74  return utility::pointer::dynamic_pointer_cast< EnzdesCacheableObserver >( enz_obs );
75  //return static_cast< EnzdesCacheableObserverOP > (enz_obs);
76 }
77 
80  core::pose::Pose const & pose )
81 {
82  //using namespace core::pose::datacache::CacheableObserverType;
83  using namespace core::pose::datacache;
84 
85  //const access: if cacheable observer hasn't been set, return NULL pointer
87 
89  //std::cout << " returning const enzdes observer with val " << enz_obs << std::endl;
90  return utility::pointer::static_pointer_cast< EnzdesCacheableObserver const >( enz_obs );
91  //return static_cast< EnzdesCacheableObserverCOP > (pose.observer_cache().get_const_ptr( core::pose::datacache::CacheableObserverType::ENZDES_OBSERVER ) );
92 }
93 
96  cst_cache_(NULL),
97  seq_recovery_cache_(NULL),
98  enz_loops_file_(NULL)
99 {
101  lig_rigid_body_confs_.clear();
102 }
103 
105  : CacheableObserver( other ),
106  cst_cache_( NULL ),
107  seq_recovery_cache_(NULL),
108  favor_native_constraints_(other.favor_native_constraints_),
109  enz_loops_file_(other.enz_loops_file_ ),
110  lig_rigid_body_confs_( other.lig_rigid_body_confs_ )
111 {
114 }
115 
117 
120 {
121  return new EnzdesCacheableObserver( *this );
122 }
123 
126 {
127  return new EnzdesCacheableObserver();
128 }
129 
130 bool
132  return length_event_link_.valid(); }
133 
134 void
136 
138 
139 }
140 
141 void
143  length_event_link_.invalidate();
144 }
145 
146 void
148 
150  //don't know what the best behaviour is in this case
151  //probably nothing, because pose destruction is imminent
152  return;
153  }
154  core::id::SequenceMapping smap( event );
155  if( cst_cache_ ) cst_cache_->remap_resid( smap );
156  if( seq_recovery_cache_ ) seq_recovery_cache_ -> remap_residues( smap );
157 
158  //remap favor native constraints (if they exist)
159  //note: in case residues were deleted, the constraints
160  //will be null pointers, so the vector might change size
161  if( favor_native_constraints_.size() > 0 ){
163  for( core::scoring::constraints::ConstraintCOPs::iterator cst_it = favor_native_constraints_.begin();
164  cst_it != favor_native_constraints_.end(); ++cst_it ){
165  core::scoring::constraints::ConstraintCOP remappedcst = (*cst_it)->remap_resid( smap );
166  if( remappedcst ) new_favor_native_csts.push_back( remappedcst );
167  }
169  favor_native_constraints_ = new_favor_native_csts;
170  }
171 }
172 
173 
174 void
177 {
179 }
180 
183 {
184  return cst_cache_;
185 }
186 
189 {
190  return cst_cache_;
191 }
192 
193 std::map< core::Size, utility::vector1< core::conformation::ResidueCOP > > const &
195  return lig_rigid_body_confs_;
196 }
197 
198 
199 void
201  core::Size seqpos,
203 )
204 {
207  for( core::Size i = 1; i <= rg_confs.size(); ++i ){
208  core::conformation::ResidueOP res( rg_confs[i]->clone());
209  res->seqpos( seqpos ); //security measure
210  resvec.push_back( res );
211  }
213 
214  //conf_it = lig_rigid_body_confs_.find( seqpos );
215  //std::cout << "enzdes cache observer rb confs for position " << seqpos << " are being set. " << conf_it->second.size() << " rb positions were set" << std::endl;
216 }
217 
218 void
220  core::Size seqpos )
221 {
222  std::map< core::Size, utility::vector1< core::conformation::ResidueCOP > >::iterator conf_it( lig_rigid_body_confs_.find( seqpos ) );
223  if( conf_it != lig_rigid_body_confs_.end() ) lig_rigid_body_confs_.erase( conf_it );
224 }
225 
227  return seq_recovery_cache_;
228 }
229 
231  return seq_recovery_cache_;
232 }
233 
235  EnzdesSeqRecoveryCacheOP seq_recovery_cache
236 ){
237  seq_recovery_cache_ = seq_recovery_cache;
238 }
239 
240 void
242  EnzdesLoopsFileCOP loopfile_in
243 ){
244  enz_loops_file_ = loopfile_in;
245 }
246 
249 {
250  return enz_loops_file_;
251 }
252 
253 
254 void
256  core::pose::Pose & pose,
258  core::pose::Pose const & native_pose
259 )
260 {
261  using namespace basic::options;
262 
263  if( option[OptionKeys::enzdes::favor_native_res].user() ) {
264  using namespace core::scoring::constraints;
265 
266  core::Real bonus = option[OptionKeys::enzdes::favor_native_res].value();
267 
268  tr.Info << "favor_native_res: adding a bonus of " << bonus << " for native residues to pose." << std::endl;
269 
270  //safety check first
271  if( favor_native_constraints_.size() != 0 ){
272  tr.Info << "Warning: when setting up favor native constraints, there might already be some previously generated favor_native constraints in the pose, trying to remove these first." << std::endl;
274 
275  }
276 
278  for( core::Size i = 1; i <= pose.total_residue(); ++i){
279 
280  if( task->design_residue(i) ){
281 
282  ConstraintOP resconstraint = new ResidueTypeConstraint( native_pose, i, bonus );
283  favor_native_constraints_.push_back( resconstraint );
284 
285  }
286  }
288  } else if (option[ OptionKeys::in::file::pssm ].user() ) {
289  //multiple sequence aligniment (adapted from MSA app)
290 
291  using namespace core;
292  using namespace scoring;
293  using namespace constraints;
294  using namespace sequence;
295 
296  using namespace protocols;
297 
298  tr << " Starting MSA design " << std::endl;
299 
300  // register SequenceProfileConstraint with the ConstraintFactory so that it can be constructed from a constraint file
301  //ConstraintIO::get_cst_factory().add_type(
302  //new core::scoring::constraints::SequenceProfileConstraint( Size(), utility::vector1< id::AtomID >(), NULL ) );
303 
304  // add constraints to bias design toward a sequence profile
305  SequenceProfileOP profile = new SequenceProfile;
306  utility::file::FileName filename( option[ OptionKeys::in::file::pssm ]().front() );
307 
308  profile->read_from_file( filename );
309  profile->convert_profile_to_probs( 1 ); // was previously implicit in read_from_file()
310 
311  tr << *profile << std::endl;
312 
313  for ( Size seqpos(1), end( pose.total_residue() ); seqpos <= end; ++seqpos ) {
314  // add individual profile constraint for each residue position
315  // because of the underlying constraint implementation, this enures that the constraint is
316  // a context-independent 1-body energy, or (intra)residue constraint
317  pose.add_constraint( new core::scoring::constraints::SequenceProfileConstraint( pose, seqpos, profile ) );
318  }
319  }// else if ( option[ OptionKeys::constraints::in::file::pssm ].user() ){
320  //}
321 
322 }//setup_favor_native_constraints
323 
324 //migrate in second step
325 void
327  core::pose::Pose & pose
328 )
329 {
331  tr.Info << "Warning: some of the favor native constraints that were previously added to the pose are not there anymore, something's a little unclean somewhere." << std::endl;
332  }
334 }
335 
336 
337 
338 } //match_enzdes_util
339 } //toolbox
340 } //protocols