Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VIP_Mover.cc
Go to the documentation of this file.
1 //
2 // (c) Copyright Rosetta Commons Member Institutions.
3 // (c) This file is part of the Rosetta software suite and is made available under license.
4 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
5 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
6 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
7 
8 /// @file VIP_Mover.cc
9 /// @brief Void Identification and Packing Mover. Identifies buried voids in an input structure
10 /// and attempts to fill these using fixed backbone packing and the GOE energy
11 /// @author ben bborgo@genetics.wustl.edu
12 
16 
17 #include "basic/Tracer.hh"
18 #include <basic/options/option.hh>
19 #include <basic/options/keys/cp.OptionKeys.gen.hh>
20 
23 #include <core/scoring/Energies.hh>
30 #include <core/pose/PDBInfo.hh>
31 
35 
40 
41 #include <iostream>
42 #include <fstream>
43 #include <algorithm>
44 #include <iterator>
45 
47 
48 
49 namespace protocols {
50 namespace vip {
51 
52 
53  static basic::Tracer TR("VIP");
54 
66  core::Size nc,
71  core::Real fe ){
72  initial_pose = p;
73  cavity_pose = cp;
74  final_pose = fp;
75  temp_residues = tr;
76  temp_positions = tp;
77  temp_energies = te;
78  favorable_residues = vr;
79  favorable_positions = fav_p;
80  favorable_energies = fav_e;
81  number_cavities = nc;
82  cavity_balls = cb;
84  void_neighbors = vn;
85  void_mutatables = vm;
86  final_energy = fe;
87  }
88 
90 
92 // using namespace basic::options;
93 // using namespace basic::options::OptionKeys;
94 // core::pose::Pose pose;
95 // core::io::pdb::build_pose_from_pdb_as_is( pose, option[ OptionKeys::in::file::s ]().vector().front() );
96  initial_pose = pose;
97  }
98 
99 
101  using namespace basic::options;
102  using namespace basic::options::OptionKeys;
103 
107  movemap->set_jump(false);
108  movemap->set_chi(true);
109  movemap->set_bb(true);
110  protocols::moves::MoverOP min_native = new protocols::simple_moves::MinMover( movemap, sf2, "dfpmin_armijo_nonmonotone", 1e-2, true );
111  min_native->apply( pose );
112  initial_pose = pose;
113  }
114 
115 
116 
118  core::Size numsuck = 0;
119  for( core::Size a = 1 ; a < (cavity_pose.total_residue()+1) ; a++ ){
120  if( cavity_pose.residue(a).name() == "SUCK" ){
121  numsuck = numsuck + 1;
122  }
123  }
124  number_cavities = numsuck;
125  }
126 
127 
128 
132  cavget.apply( pose );
133  cavity_pose = pose;
134  }
135 
136 
137 
139  utility::vector1<core::Size> cav_positions;
140  for( core::Size i = 1; i <= cavity_pose.total_residue(); i++ ){
141  if( cavity_pose.residue(i).name() == "SUCK" ){
142  cav_positions.push_back(i);
143  }
144  }
145  cavity_balls = cav_positions;
146  }
147 
148 
150  posey.dump_pdb(filename);
151  }
152 
153 
154  core::Real
157  core::Real min = 99999.9;
158  for( core::Size i = 1; i <= initial_pose.total_residue(); i++ ){
159  for( core::Size j = 1; j <= initial_pose.residue(i).nheavyatoms(); j++ ){
160  if( initial_pose.residue(i).xyz(j).distance( cppos ) < min ){
161  min = initial_pose.residue(i).xyz(j).distance( cppos );
162  }
163  }
164  }
165  return min;
166  }
167 
169  using namespace basic::options;
170  using namespace basic::options::OptionKeys;
172 
173  if ( cavity_balls.size() < 1 ) {
174  initial_pose.dump_pdb("intermediate.pdb");
175  TR.Error << "No more cavities! Dumping structure to intermediate.pdb" << std::endl;
176  return;
177  }
178 
179  for( core::Size i = 1; i <= cavity_balls.size(); i++ ){
181  core::Real min = get_cav_approx( i );
182  for( core::Size a = 1; a <= initial_pose.total_residue(); a++ ){
183  for( core::Size b = 1; b <= initial_pose.residue(a).nheavyatoms(); b++ ){
185  if( test_position.distance(cav_center) <= (option[cp::cutoff]+min) ){
186  neighbors.push_back( a );
187  neighbors.push_back( b );
188  }
189  }
190  }
191  }
192  void_neighbors = neighbors;
193  }
194 
195 
196  void
198 
199  utility::vector1<core::Size> mutatable_residues;
200  for( core::Size i = 1; i <= void_neighbors.size(); i+=2 ){
201  if( (initial_pose.residue(void_neighbors[i]).is_surface() == false) &&
202  (initial_pose.residue(void_neighbors[i]).is_polar() == false) &&
203  (std::find( excluded_positions.begin(), excluded_positions.end(), void_neighbors[i]) == excluded_positions.end() ) &&
204  (initial_pose.residue(void_neighbors[i]).aa() < core::chemical::num_canonical_aas ) && // Don't try amino acid if APOLAR will choke on it
206  mutatable_residues.push_back(void_neighbors[i]);
207  }
208  }
209 
211  for( core::Size ii = 1; ii < mutatable_residues.size(); ii++ ){
212  if( mutatable_residues[ii] != mutatable_residues[ii+1] ){
213  mm_res.push_back( mutatable_residues[ii] );
214  }
215  }
216 
217  std::sort( mm_res.begin(), mm_res.end() );
218  utility::vector1<core::Size>::iterator new_end_itr = std::unique( mm_res.begin(), mm_res.end() );
219 
220  utility::vector1<core::Size> unique_mm_res;
221  std::copy( mm_res.begin(), new_end_itr, std::back_inserter( unique_mm_res ) );
222 
223  void_mutatables = unique_mm_res;
224  }
225 
226 
227 
229  using namespace basic::options;
230  using namespace basic::options::OptionKeys;
231 
232  for( core::Size i = 1; i <= void_mutatables.size(); i++ ){
233  temp_positions.push_back(void_mutatables[i]);
234  }
235 
236  // TR << "Num void_mutatables is " << void_mutatables.size() << std::endl;
237  // TR << "Num temp_positions is " << temp_positions.size() << std::endl;
238 
240 
241  for( core::Size aa = 1; aa <= void_mutatables.size(); aa++ ){
242  core::pose::Pose pack_pose;
243  pack_pose = initial_pose;
247  for( core::Size j = 1; j <= pack_pose.total_residue(); j++ ){
248  if( j != void_mutatables[aa] ){
249  task->nonconst_residue_task(j).prevent_repacking();
250  } else {
251  task->nonconst_residue_task(void_mutatables[aa]).or_ex1(true);
252  task->nonconst_residue_task(void_mutatables[aa]).or_ex2(true);
253  task->nonconst_residue_task(void_mutatables[aa]).or_ex3(true);
254  command->residue_action(*task,void_mutatables[aa]);
255  }
256  }
258  pack_mover->apply( pack_pose );
259  // Store this single residue
260  temp_residues.push_back( pack_pose.residue(temp_positions[aa]).clone() );
261  temp_energies.push_back( pack_pose.energies().total_energy() );
262  }
263 
264  // TR << "Done try_point_mutants" << std::endl;
265 
266  }
267 
268 
269 
271  VIP_Report();
272  VIP_Report vip_report;
273 
275  }
276 
277 
279  using namespace basic::options;
280  using namespace basic::options::OptionKeys;
281 
284  score_em->apply( initial_pose );
285 
287  core::pose::Pose basePose = initial_pose;
288  for( core::Size i = 1; i <= temp_energies.size(); i++ ){
289  core::Real tempE = temp_energies[i];
290  if( tempE < baseE ){
291  if( initial_pose.residue(temp_positions[i]).name() != temp_residues[i]->name() ){
292  core::pose::Pose temp_pose;
293  temp_pose = initial_pose;
294  temp_pose.replace_residue( temp_positions[i], *(temp_residues[i]), true );
295  favorable_residues.push_back( temp_residues[i] );
296  favorable_positions.push_back( temp_positions[i] );
297  favorable_energies.push_back( temp_energies[i] );
299  }
300  }
301  }
302 
303  if( option[ cp::print_reports ] ){
305  }
306  }
307 
308 
310  VIP_Report();
311  VIP_Report vip_report;
312 
314 // vip_report.get_GOE_packstat_report( initial_pose, favorable_energies );
315  }
316 
318  using namespace basic::options;
319  using namespace basic::options::OptionKeys;
320 
321  core::Real bestE = 99999;
322  core::Size bestP = 0;
323  for( core::Size i = 1; i <= favorable_energies.size(); i++ ){
324  if( favorable_energies[i] < bestE ){
325  bestE = favorable_energies[i];
326  bestP = i;
327  }
328  }
329 
330  if( favorable_positions.size() == 0 || favorable_residues.size() == 0 ) { // Avoid segmentation fault
331  TR.Warning << "WARNING: No favorable positions found." << std::endl;
332  return;
333  }
336 
337  dump_pdb_to_file( final_pose, "final.pdb" );
338  final_energy = bestE;
339  }
340 
341 
342 
344 
345  using namespace basic::options;
346  using namespace basic::options::OptionKeys;
347 
348  core::Real bestE = 99999;
349 
351 
352  std::string rmover = option[ cp::relax_mover ];
353 
354  for( core::Size i = 1; i <= favorable_residues.size(); i++ ){
355 
357  relax_pose.replace_residue( favorable_positions[i], *(favorable_residues[i]), true );
358 
359  if( rmover == "relax" ){
360  protocols::relax::RelaxProtocolBaseOP relaxmover = new protocols::relax::FastRelax( relax_score_fxn );
361  if( option[ cp::local_relax ] ) {
363  if( option[ cp::local_relax ] ) {
364  set_local_movemap( relax_pose, favorable_positions[i], mmap_ptr );
365  }
366  relaxmover->set_movemap( mmap_ptr );
367  }
368  relaxmover->apply(relax_pose);
369  } else if( rmover == "classic_relax" ){
370  protocols::relax::RelaxProtocolBaseOP relaxmover = new protocols::relax::ClassicRelax( relax_score_fxn );
371  if( option[ cp::local_relax ] ) {
373  if( option[ cp::local_relax ] ) {
374  set_local_movemap( relax_pose, favorable_positions[i], mmap_ptr );
375  }
376  relaxmover->set_movemap( mmap_ptr );
377  }
378  relaxmover->apply(relax_pose);
379  } else if( rmover == "cst_relax" ){
380  protocols::relax::RelaxProtocolBaseOP cstrelaxmover = new protocols::relax::MiniRelax( relax_score_fxn );
381  if( option[ cp::local_relax ] ) {
383  if( option[ cp::local_relax ] ) {
384  set_local_movemap( relax_pose, favorable_positions[i], mmap_ptr );
385  }
386  cstrelaxmover->set_movemap( mmap_ptr );
387  }
388  cstrelaxmover->apply(relax_pose);
389  }
390 
394  score_em->apply( relax_pose );
395  favorable_energies[i] = relax_pose.energies().total_energy();
396  if( favorable_energies[i] < bestE ) {
397  bestE = favorable_energies[i];
399  final_energy = bestE;
400  }
401  }
402  }
403 
405  using namespace basic::options;
406  using namespace basic::options::OptionKeys;
407 
408  if( option[ cp::print_reports ] ){
410  }
411  }
412 
415  apply_holes();
417  get_neighbors();
419  }
420 
422  using namespace basic::options;
423  using namespace basic::options::OptionKeys;
424 
427  if( option[ cp::skip_relax ] ){
428  skip_relax();
429  } else {
432  }
433  }
434 
437  nook_finder();
438  cranny_packer();
439  }
440 
441  void
443  using namespace basic::options;
444  using namespace basic::options::OptionKeys;
445 
446  excluded_positions.clear();
447 
448  if( option[ cp::exclude_file ].active() ){
449  std::string exclude_file_name( option[ cp::exclude_file ] );
450 
451  // Probe for file
452  std::ifstream exc_file( exclude_file_name.c_str() );
453 
454  if( !exc_file ) {
455  TR << "Exclude_file " << exclude_file_name << " not found." << std::endl;
456  TR << "No positions will be excluded." << std::endl;
457  return;
458  }
459 
460  // Process one at a time
461 
462  core::Size exc_pos;
463  char exc_chain;
464 
465  exc_file >> exc_pos;
466  while( !exc_file.eof() ) {
467  exc_file >> exc_chain;
468  TR << "Adding position " << exc_pos << " chain " << exc_chain << " to exclude list." << std::endl;
469  excluded_positions.push_back( initial_pose.pdb_info()->pdb2pose( exc_chain, exc_pos ) );
470  exc_file >> exc_pos;
471  }
472 
473  TR << "Found " << excluded_positions.size() << " positions excluded from mutation" << std::endl;
474  exc_file.close();
475  return;
476  }
477 
478  TR << "No positions will be excluded." << std::endl;
479  return;
480  }
481 
482  bool
484  for( core::Size j = 1; j <= p1.total_residue(); j++ ){
485  if( p1.residue(j).name() != p2.residue(j).name() ){
486  return true;
487  }
488  }
489  return false;
490  }
491 
492 
493 }}