Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopAnalyzerMover.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 /protocols/analysis/LoopAnalyzerMover.cc
11 /// @brief LoopAnalyzerMover implementation - class for in-depth loop structure quality analysis
12 /// @author Steven Lewis
13 
14 // Unit Headers
16 
17 // Package Headers
18 #include <protocols/loops/Loop.hh>
19 #include <protocols/loops/Loops.hh>
20 
21 // Project Headers
22 // AUTO-REMOVED #include <core/conformation/Conformation.hh>
24 
26 
27 #include <core/scoring/Energies.hh>
29 
30 #include <core/pose/Pose.hh>
31 
32 
34 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh> //CENTROID, FA_STANDARD
35 
37 #include <protocols/jd2/Job.hh>
38 
39 // Utility Headers
40 #include <ObjexxFCL/FArray1D.hh> //necessary for fold tree tricks
41 #include <ObjexxFCL/FArray2D.hh>
42 #include <core/types.hh>
43 #include <basic/Tracer.hh>
44 #include <utility/exit.hh>
45 // AUTO-REMOVED #include <numeric/xyz.io.hh>
46 
47 // C++ Headers
48 #include <sstream>
49 #include <iomanip>
50 
52 #include <core/pose/util.hh>
53 #include <utility/vector1.hh>
54 
55 
56 using basic::T;
57 using basic::Error;
58 using basic::Warning;
59 
60 static basic::Tracer TR("protocols.analysis.LoopAnalyzerMover");
61 
62 namespace protocols{
63 namespace analysis{
64 
65 ///stupid helper function needed because ternary operator does not allow variable return types
66 std::ostream & which_ostream( std::ostream & ost, std::ostream & oss, bool const tracer){
67  if(tracer) return ost;
68  return oss;
69 }
70 
71 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
72 //////////////////////////LoopAnalyzerMover////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
75  Mover(), loops_(new protocols::loops::Loops(loops)), tracer_(tracer), sf_(NULL), chbreak_sf_(NULL)
76 {
77  protocols::moves::Mover::type( "LoopAnalyzer" );
78  set_sf();
79 }
80 
82 
83 ///@brief do not use a default constructor with this class - function exists as part of the remove #include drive
84 LoopAnalyzerMover::LoopAnalyzerMover() : tracer_(false) { utility_exit_with_message("do not use default constructor of class LoopAnalyzerMover"); }
85 
87  //utility::pointer::ReferenceCount(),
88  Mover(),
89  loops_(new protocols::loops::Loops(*(rhs.loops_))),
90  tracer_(rhs.tracer_),
91  positions_(rhs.positions_), //this is useless data
92  sf_(new core::scoring::ScoreFunction(*(rhs.sf_))),
93  chbreak_sf_(new core::scoring::ScoreFunction(*(rhs.chbreak_sf_))),
94  scores_(rhs.scores_) //useless
95 {}
96 
98  using namespace core::scoring;
99 
100  sf_ = new ScoreFunction;
101  sf_->set_weight( rama, 1.0 );
102  sf_->set_weight( omega, 1.0 );
103  sf_->set_weight( fa_dun, 1.0 );
104  //sf_->set_weight( p_aa_pp, 1.0 );
105  //sf_->set_weight( chainbreak, 1.0 );
106  sf_->set_weight( peptide_bond, 1.0 );
107 
109  chbreak_sf_->set_weight( chainbreak, 20.0 );
110 
111  return;
112 }
113 
114 ///@details LoopAnalyzerMover is mostly a container for other movers for the anchored design protocol.
116 {
117  TR << "running LoopAnalyzerMover" << std::endl;
118 
119  //prep pose
120  core::pose::Pose pose(input_pose); //protecting input pose from our chainbreak changes (and its energies object)
121  find_positions(pose);
123  (*sf_)(pose);
124 
125  //make output
126  std::ostringstream results_oss;
127  std::ostream & results = which_ostream(TR, results_oss, tracer_); //easy swap between tracer/job output
128  core::Real total_rama(0), total_omega(0), total_peptide_bond(0), total_chbreak(0);
129 
130  results << "LoopAnalyzerMover: unweighted bonded terms and angles (in degrees)" << std::endl
131  << "position phi_angle psi_angle omega_angle peptide_bond_C-N_distance rama_score omega_score dunbrack_score peptide_bond_score chainbreak_score" << std::endl
132  << " pos phi_ang psi_ang omega_ang pbnd_dst rama omega_sc dbrack pbnd_sc cbreak" << std::endl;
133 
134  for( core::Size i(1); i <= positions_.size(); ++i ){
135  core::Size const res(positions_[i]);
136  //peptide_bond distance
137  core::Real const pbnd_dist(input_pose.residue(res).atom("C").xyz().distance(input_pose.residue(res+1).atom("N").xyz()));
138  //phi/psi/omega
139  // results.precision(3);
140  results << std::setw(4) << res
141  << std::setw(8) << std::setprecision(4) << pose.phi(res)
142  << std::setw(8) << std::setprecision(4) << pose.psi(res)
143  << std::setw(10) << std::setprecision(4) << pose.omega(res)
144  << std::setw(9) << std::setprecision(4) << pbnd_dist;
145 
146  using namespace core::scoring;
147  EnergyMap const & emap(pose.energies().residue_total_energies(res));
148  results << std::setw(8) << std::setprecision(3) << emap[rama]
149  //<< std::setw(8) << std::setprecision(4) << emap[p_aa_pp]
150  << std::setw(10) << std::setprecision(3) << emap[omega]
151  << std::setw(7) << std::setprecision(3) << emap[fa_dun]
152  << std::setw(8) << std::setprecision(3) << emap[peptide_bond]
153  << std::setw(9) << std::setprecision(3) << scores_[i]
154  << std::setprecision(6) << std::endl;
155  total_rama += emap[rama];
156  total_omega += emap[omega];
157  total_peptide_bond += emap[peptide_bond];
158  total_chbreak += scores_[i];
159  }//for all loop positions
160 
161  results << "total_rama " << total_rama << std::endl;
162  results << "total_omega " << total_omega << std::endl;
163  results << "total_peptide_bond " << total_peptide_bond << std::endl;
164  results << "total_chainbreak " << total_chbreak << std::endl;
165  core::Real const loop_total(total_rama + total_omega + total_peptide_bond + total_chbreak);
166  results << "total rama+omega+peptide bond+chainbreak " << loop_total << std::endl;
167 
168 
169  if(!tracer_){
170  protocols::jd2::JobDistributor::get_instance()->current_job()->add_string(results_oss.str());
171  //store the loop_total where jd2 silent file can get it
172  protocols::jd2::JobDistributor::get_instance()->current_job()->add_string_real_pair("LAM_total", loop_total);
173  }
174 
175  return;
176 }//LoopAnalyzerMover::apply
177 
180  return "LoopAnalyzerMover";
181 }
182 
184  positions_.clear();
185  for( protocols::loops::Loops::const_iterator it=loops_->begin(), it_end=loops_->end(); it != it_end; ++it ){
186  core::Size start(it->start());
187  core::Size end(it->stop());
188  if(!pose.residue(start).is_terminus() && start != 1) --start;
189  if(!pose.residue(end).is_terminus() && end != pose.total_residue()) ++end;
190  for( core::Size i(start); i <= end; ++i ) positions_.push_back(i);
191  }//for all loops
192  scores_.clear();
193  scores_.resize(positions_.size(), 0);
194  return;
195 }//find_positions
196 
198 {
199  using namespace core::chemical;
201 
202  //remove all chainbreak variants within loop
203  core::Size const numpos(positions_.size());
204  for(core::Size i(1); i<=numpos; ++i){
205  core::Size const pos = positions_[i];
208  }
209 
210  //create a chainbreak at the desired position, score it, store the score, and revert changes
211  for(core::Size i(1); i<=numpos; ++i){
212  core::Size const pos = positions_[i];
213 
214  //create chainbreak variant
217 
218  //create cut in fold tree
220  ft.clear(); //remove initial edge
221  ft.add_edge(Edge(1, pos, Edge::PEPTIDE));
222  ft.add_edge(Edge(pos+1, pose.total_residue(), Edge::PEPTIDE));
223  ft.add_edge(Edge(pos, pos+1, 1)); //a jump and therefore a cut
224  ft.reorder(1);
225  pose.fold_tree(ft);
226 
227  //score the sucker
228  scores_[i] = (*chbreak_sf_)(pose);
229 
230  //undo that chainbreak variant
233  }
234 
235  //revert to innocuous fold tree
237 
238  return;
239 }//calculate_all_chainbreaks
240 
241 
242 }//analysis
243 }//protocols