Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InterfaceScoreCalculator.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/task/ResfileReader.cc
11 /// @brief implementation of resfile reader and its command classes
12 /// @author Gordon Lemmon (glemmon@gmail.com)
13 
14 // Unit Headers
17 
18 #include <utility/exit.hh>
19 #include <basic/Tracer.hh>
20 #include <core/types.hh>
21 #include <utility/tag/Tag.hh>
23 #include <basic/options/option.hh>
24 #include <basic/options/keys/in.OptionKeys.gen.hh>
25 
26 #include <core/pose/util.hh>
28 
29 //Auto Headers
31 #include <core/pose/Pose.hh>
32 #include <core/scoring/Energies.hh>
34 #include <protocols/jd2/Job.hh>
36 #include <utility/string_util.hh>
37 #include <utility/vector0.hh>
38 #include <utility/vector1.hh>
39 #include <utility/excn/Exceptions.hh>
40 #include <boost/foreach.hpp>
41 
42 #define foreach BOOST_FOREACH
43 
44 using basic::T;
45 using basic::Error;
46 using basic::Warning;
47 
48 namespace protocols {
49 namespace ligand_docking {
50 
51 static basic::Tracer InterfaceScoreCalculator_tracer("protocols.ligand_docking.ligand_options.InterfaceScoreCalculator", basic::t_debug);
52 
55 {
57 }
58 
61  return new InterfaceScoreCalculator;
62 }
63 
66 {
67  return "InterfaceScoreCalculator";
68 }
69 
70 ///@brief
72  Mover("InterfaceScoreCalculator"),
73  chains_(),
74  native_(NULL),
75  score_fxn_(NULL)
76 {}
77 
79  //utility::pointer::ReferenceCount(),
80  protocols::moves::Mover( that ),
81  chains_(that.chains_),
82  native_(that.native_),
83  score_fxn_(that.score_fxn_)
84 {}
85 
87 
89  return new InterfaceScoreCalculator( *this );
90 }
91 
93  return new InterfaceScoreCalculator;
94 }
95 
97  return "InterfaceScoreCalculator";
98 }
99 
100 void InterfaceScoreCalculator::chains(std::vector<std::string> const & chains)
101 {
102  chains_ = chains;
103 }
104 
105 
107 {
109 }
110 
111 
112 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
113 void
115  utility::tag::TagPtr const tag,
116  protocols::moves::DataMap & datamap,
117  protocols::filters::Filters_map const & /*filters*/,
118  protocols::moves::Movers_map const & /*movers*/,
119  core::pose::Pose const & /*pose*/
120 )
121 {
122  if ( tag->getName() != "InterfaceScoreCalculator" ){
123  throw utility::excn::EXCN_RosettaScriptsOption("This should be impossible");
124  }
125  if ( ! tag->hasOption("chains") ) throw utility::excn::EXCN_RosettaScriptsOption("'InterfaceScoreCalculator' requires 'chains' tag (comma separated chains to dock)");
126 
127  std::string const chains_str = tag->getOption<std::string>("chains");
128  chains_= utility::string_split(chains_str, ',');
129 
130  /// Score Function ///
131  if ( ! tag->hasOption("scorefxn") ) throw utility::excn::EXCN_RosettaScriptsOption("'HighResDocker' requires 'scorefxn' tag");
132  std::string scorefxn_name= tag->getOption<std::string>("scorefxn");
133  score_fxn_= datamap.get< core::scoring::ScoreFunction * >( "scorefxns", scorefxn_name);
134  assert(score_fxn_);
135 
136  if (tag->hasOption("native") ){
137  std::string const & native_str= tag->getOption<std::string>("native");
138  utility::vector1<std::string> natives_strs= utility::string_split(native_str, ',');
139  std::string natives_str = utility::join(natives_strs, " ");
140 
143  }
144  else if ( basic::options::option[ basic::options::OptionKeys::in::file::native ].user()){
145  std::string const & native_str= basic::options::option[ basic::options::OptionKeys::in::file::native ]().name();
148  }
149 }
150 
153  add_scores_to_job(pose, job);
154  append_ligand_docking_scores(pose, job);
155 }
156 
158  core::pose::Pose & pose,
160 ) const
161 {
162  assert(score_fxn_);
163  using namespace core::scoring;
164 
165  core::Real const tot_score = score_fxn_->score( pose );
166 
167  // Which score terms to use
168  typedef utility::vector1<ScoreType> ScoreTypeVec;
169  ScoreTypeVec score_types;
170  for(int i = 1; i <= n_score_types; ++i) {
171  ScoreType ii = ScoreType(i);
172  if ( score_fxn_->has_nonzero_weight(ii) ) score_types.push_back(ii);
173  }
174 
175  foreach(ScoreType score_type, score_types){
176  std::string const score_term = name_from_score_type(score_type);
177  core::Real const weight = score_fxn_->get_weight(score_type);
178  job->add_string_real_pair(score_term, weight * pose.energies().total_energies()[ score_type ]);
179  }
180  job->add_string_real_pair(name_from_score_type(core::scoring::total_score), tot_score);
181 }
182 
183 
184 /// @brief For multiple ligands, append ligand docking scores for each ligand
185 void
187  core::pose::Pose const & after,
189 ) const
190 {
191  foreach(std::string chain, chains_){
192  InterfaceScoreCalculator_tracer.Debug << "appending ligand: "<< chain << std::endl;
193  assert( core::pose::has_chain(chain, after));
194  if(native_)
195  {
196  if( !core::pose::has_chain(chain, *native_))
197  {
198  utility_exit_with_message("The native pose passed to InterfaceScoreCalculator does not have chain " +chain);
199  }
200  }
201 
203  foreach(core::Size jump_id, jump_ids){
204  append_interface_deltas(jump_id, job, after, score_fxn_);
205  append_ligand_docking_scores(jump_id, after, job);
206  }
207  }
208 }
209 
210 /// @brief Scores to be output that aren't normal scorefunction terms.
211 void
213  core::Size jump_id,
214  core::pose::Pose const & after,
216 ) const {
217 
218  if(native_)
219  {
220 
221  append_ligand_travel(jump_id, job, *native_, after);
222  append_radius_of_gyration(jump_id, job, *native_);
223  append_ligand_RMSD(jump_id, job, *native_, after);
224  }
225 
226  append_ligand_grid_scores(jump_id,job,after);
227 }
228 
229 
230 
231 } //namespace ligand_docking
232 } //namespace protocols