Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RRProtocolRTMin.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 src/protocols/rotamer_recovery/RRProtocol.cc
11 /// @author Matthew O'Meara (mattjomeara@gmail.com)
12 
13 // Unit Headers
15 
16 // Project Headers
19 
20 // Platform Headers
21 #include <basic/Tracer.hh>
22 #include <core/chemical/AA.hh>
23 #include <core/pack/rtmin.hh>
25 #include <core/pose/Pose.hh>
27 
28 #include <core/graph/Graph.hh>
34 
35 // C++ Headers
36 #include <string>
37 #include <sstream>
38 
39 //Auto Headers
40 #include <utility/vector1.hh>
41 using std::string;
42 using std::stringstream;
43 using core::Size;
44 using core::pack::RTMin;
47 using core::pose::Pose;
50 using basic::Tracer;
51 
52 namespace protocols {
53 namespace rotamer_recovery {
54 
55 static Tracer TR("protocol.moves.RRProtocolRTMin");
56 
58  nonideal_(false),
59  cartesian_(false)
60 {}
61 
63  nonideal_(src.nonideal_),
64  cartesian_(src.cartesian_)
65 {}
66 
68 
69 string
71  return "RRProtocolRTMin";
72 }
73 
74 string
76  stringstream params;
77  params
78  << "nonideal:" << get_nonideal()
79  << ",cartesian:" << get_cartesian();
80  return params.str();
81 }
82 
83 void
85  bool setting
86 ) {
87  nonideal_ = setting;
88 }
89 
90 bool
92  return nonideal_;
93 }
94 
95 void
97  bool setting
98 ) {
99  cartesian_ = setting;
100 }
101 
102 bool
104  return cartesian_;
105 }
106 
107 /// @details For each residue, minimize it, and measure the rotamer
108 /// compared to where it started
109 void
111  RRComparerOP comparer,
112  RRReporterOP reporter,
113  Pose const & pose,
114  ScoreFunction const & score_function,
115  PackerTask const & packer_task
116 ) {
117 
119 
120  // Assume score_function.setup_for_scoring(pose) has already been called.
121 
122  PackerTaskOP one_res_task( packer_task.clone() );
123  core::graph::GraphOP packer_neighbor_graph = core::pack::create_packer_graph( pose, score_function, one_res_task );
124 
125  RTMin rtmin;
126  rtmin.set_nonideal(nonideal_);
127  rtmin.set_cartesian(cartesian_);
128 
129  // I don't know if rtmin looks at more than pack_residue(..)
130  one_res_task->temporarily_fix_everything();
131  Pose working_pose = pose; // deep copy
132 
133  // For each residue in the packer task,
134  // rtmin residue -> and measure recovery
135  for( Size ii = 1; ii <= pose.total_residue(); ++ii ){
136  if ( !packer_task.pack_residue(ii) ) continue;
137 
138  one_res_task->temporarily_set_pack_residue( ii, true );
139  if ( ! packer_task.include_current( ii ) ) {
140  // if we're not asking for the input sidechains, then don't use them -- replace the input sidechain with a rotamer that will be sampled inside
141  // rotamer trials anyways
144  rotset->set_resid( ii );
145  rotset->build_rotamers( pose, score_function, *one_res_task, packer_neighbor_graph );
146  if ( rotset->num_rotamers() > 0 ) {
147  working_pose.replace_residue( ii, *rotset->rotamer(1), false );
148  }
149  }
150 
151  rtmin.rtmin( working_pose, score_function, one_res_task );
153  comparer, reporter,
154  pose, working_pose,
155  pose.residue(ii), working_pose.residue(ii) );
156  working_pose.replace_residue( ii, pose.residue( ii ), false ); // restore the original conformation.
157  one_res_task->temporarily_set_pack_residue( ii, false );
158  }
159 }
160 
161 } // rotamer_recovery
162 } // protocols