Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
optimizeH.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 core/pack/optimizeH.cc
11 /// @brief standard hydrogen optimization subroutine
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 // Unit headers
15 #include <core/pack/optimizeH.hh>
16 
17 // Package headers
19 // AUTO-REMOVED #include <core/id/AtomID_Mask.hh>
23 #include <core/pose/Pose.hh>
26 
27 // Project headers
28 #include <basic/options/option.hh>
29 #include <basic/Tracer.hh> // RENAME THIS FILE WITH A CAPITAL T
30 #include <basic/basic.hh>
31 
32 // ObjexxFCL headers
33 #include <ObjexxFCL/format.hh>
34 
35 // option key includes
36 
37 #include <basic/options/keys/score.OptionKeys.gen.hh>
38 #include <basic/options/keys/packing.OptionKeys.gen.hh>
39 
40 #include <core/id/AtomID_Map.hh>
41 #include <utility/vector0.hh>
42 #include <utility/vector1.hh>
43 
44 
45 
46 
47 
48 namespace core {
49 namespace pack {
50 
51 /// Tracer instance for this file
52 /// Named after the original location of this code
53 static basic::Tracer TR("core.io.pdb.file_data");
54 
55 void
57  pose::Pose & pose,
58  id::AtomID_Mask const & missing
59 )
60 {
61  using namespace scoring;
62  using namespace conformation;
63  using namespace basic::options;
64  using namespace basic::options::OptionKeys;
65 
66  ScoreFunctionOP sfxn;
67  if ( !option[ score::optH_weights ].user() && !option[ score::optH_patch ].user() ) {
69  } else if ( option[ score::optH_weights ].user() && option[ score::optH_patch ].user() ) {
70  sfxn = ScoreFunctionFactory::create_score_function( option[ score::optH_weights ](), option[ score::optH_patch ]() );
71  } else if ( option[ score::optH_weights ].user() ) {
72  sfxn = ScoreFunctionFactory::create_score_function( option[ score::optH_weights ]() );
73  } else {
74  // patch.user() and ! weights.user()
75  sfxn = ScoreFunctionFactory::create_score_function( STANDARD_WTS, option[ score::optH_patch ]() );
76  }
77 
78 
79  (*sfxn)(pose); // structure must be scored before pack_rotamers can be called.
80  pose::Pose const start_pose( pose );
81  pack::optimizeH( pose, *sfxn );
82  // warn about positions that changed
83  for ( Size i=1; i<= pose.total_residue(); ++i ){
84  Residue const & old_rsd( start_pose.residue(i) );
85  Residue const & new_rsd( pose.residue(i) );
86  assert( old_rsd.nchi() == new_rsd.nchi() && old_rsd.type().n_proton_chi() == new_rsd.type().n_proton_chi() );
87  for ( Size chino=1; chino<= old_rsd.nchi(); ++chino ) {
88  Real const chidev( std::abs( basic::subtract_degree_angles( old_rsd.chi( chino ), new_rsd.chi( chino ) ) ) );
89  bool const chi_atom_was_missing( missing[ id::AtomID( old_rsd.chi_atoms( chino )[4], i ) ] );
90  if ( chidev > 0.1 && !chi_atom_was_missing ) {
91  using namespace ObjexxFCL::fmt;
92  if ( old_rsd.type().is_proton_chi( chino ) ) {
93  TR << "[ OPT-H WARNING ] proton chi angle change: chidev= " << F(9,3,chidev) << " chino= " << I(2,chino) <<
94  " position: " << I(4,i) << ' ' << old_rsd.name() << ' ' << new_rsd.name() << std::endl;
95  } else {
96  TR << "[ OPT-H WARNING ] heavyatom chi angle change: chidev= " << F(9,3,chidev) << " chino= " <<
97  I(2,chino) << " position: " << I(4,i) << ' ' << old_rsd.name() << ' ' << new_rsd.name() << std::endl;
98  }
99  }
100  }
101  }
102 }
103 
104 void
106  pose::Pose & pose,
107  scoring::ScoreFunction const & sfxn
108 )
109 {
110  using namespace task;
111  using namespace basic::options;
112 
113  PackerTaskOP task = TaskFactory::create_packer_task( pose );
114 
115  task->initialize_from_command_line();
116  task->or_optimize_h_mode( true );
117  task->or_include_current( true );
118  task->or_flip_HNQ( option[ OptionKeys::packing::flip_HNQ ].user() );
119  task->or_multi_cool_annealer( option[ OptionKeys::packing::optH_MCA ]() );
120 
121  pack_rotamers( pose, sfxn, task );
122 
123 }
124 
125 }
126 }
127