Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlaceProbeMover.cc
Go to the documentation of this file.
1 // Project Headers
2 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
3 // vi: set ts=2 sw=2 noet:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/hotspot_hashing/movers/PlaceProbeMover.cc
12 /// @brief
13 /// @author Alex Ford fordas@uw.edu
14 //
15 
16 #include <sstream>
17 
18 #include <basic/Tracer.hh>
19 
20 #include <boost/algorithm/string.hpp>
21 #include <boost/lexical_cast.hpp>
22 
23 #include <utility/tag/Tag.hh>
24 #include <utility/exit.hh>
25 
30 #include <core/pose/Pose.hh>
31 #include <core/pose/util.hh>
35 
37 
38 #include <protocols/moves/Mover.hh>
41 
44 #include <protocols/jd2/Job.hh>
45 
47 
51 
53 
55 
56 namespace protocols
57 {
58 namespace hotspot_hashing
59 {
60 namespace movers
61 {
62 
63 static basic::Tracer TR( "protocols.hotspot_hashing.movers.PlaceProbeMover" );
64 
66  residue_name_(""),
67  target_residue_(NULL),
68  current_mode_(RunAll),
69  search_partition_(0),
70  total_search_partition_(1),
71  initialized_pattern_(false),
72  search_points_()
73 {}
74 
76  std::string residue_name,
77  core::conformation::ResidueCOP target_residue,
78  core::Size search_partition,
79  core::Size total_search_partition) :
80  residue_name_(residue_name),
81  target_residue_(target_residue),
82  current_mode_(RunAll),
83  search_partition_(search_partition),
84  total_search_partition_(total_search_partition),
85  initialized_pattern_(false),
86  search_points_()
87 {}
88 
90 {
92 
94  {
95  core::Size nstruct = jd2::JobDistributor::get_instance()->current_job()->nstruct_index();
96 
97  core::Size search_index = nstruct % search_points_.size();
98  if( search_index == 0 )
99  {
100  search_index = search_points_.size();
101  }
102 
103  execute_one_search(pose, search_index);
104  }
105  else
106  {
107  for (core::Size i = 1; i <= search_points_.size(); i++)
108  {
109  core::pose::Pose tmp_pose(pose);
110  execute_one_search(tmp_pose, i);
111  }
112  }
113 }
114 
116 {
117  //TODO extract placement into a separate task
118  core::kinematics::Stub transform = search_points_[search_index];
119 
120  core::Size residuejumpindex;
121  core::Size residueindex;
122 
123  StubGenerator::placeResidueAtTransform(pose, target_residue_, transform, residuejumpindex, residueindex);
124 
125  {
126  std::stringstream sstream;
127  stub_to_points(sstream, transform);
128 
129  jd2::JobDistributor::get_instance()->current_job()->add_string_string_pair(
130  "placeprobe_prerefine_centroid_stub", sstream.str());
131  }
132 
133  perform_local_refinement(pose, residueindex);
134 
135  core::conformation::ResidueCOP post_refinement_residue(pose.residue(residueindex));
136 
137  {
138  core::kinematics::Stub post_refinement_centroid_transform = StubGenerator::residueStubCentroidFrame(post_refinement_residue);
139  std::stringstream sstream;
140  stub_to_points(sstream, post_refinement_centroid_transform);
141 
142  jd2::JobDistributor::get_instance()->current_job()->add_string_string_pair(
143  "placeprobe_postrefine_centroid_stub", sstream.str());
144  }
145 
146  {
147  core::kinematics::Stub post_refinement_orient_transform = StubGenerator::residueStubOrientFrame(post_refinement_residue);
148  std::stringstream sstream;
149  stub_to_points(sstream, post_refinement_orient_transform);
150 
151  jd2::JobDistributor::get_instance()->current_job()->add_string_string_pair(
152  "placeprobe_postrefine_orient_stub", sstream.str());
153  }
154 
155  jd2::JobDistributor::get_instance()->current_job()->add_string_string_pair(
156  "placeprobe_residue_name", post_refinement_residue->name());
157 
158  jd2::JobDistributor::get_instance()->current_job()->add_string_string_pair(
159  "placeprobe_residue_number", boost::lexical_cast<std::string>(residueindex));
160 }
161 
163 {
164  using namespace protocols::hotspot_hashing;
165 
167  {
168  return;
169  }
170 
171  initialized_pattern_ = true;
172 
173  TR.Debug << "Initializing search pattern." << std::endl;
174 
175  SearchPatternOP search_pattern = create_partitioned_search_pattern(target_pose);
176 
177  search_points_ = search_pattern->Searchpoints();
178 
179  TR.Info << "Initialized search pattern. Size: " << search_points_.size() << std::endl;
180 
182 
183  if (current_job->nstruct_max() < search_points_.size())
184  {
185  TR.Error << "Current job nstruct_max: " << current_job->nstruct_max() << " less than search pattern size: " << search_points_.size() << std::endl;
186  }
187 
188  if (current_job->nstruct_max() > search_points_.size())
189  {
190  TR.Warning << "Current job nstruct_max: " << current_job->nstruct_max() << " greater than search pattern size: " << search_points_.size() << " (Search points will be repeated.)" << std::endl;
191  }
192 }
193 
195 {
197 }
198 
200 {
201  return new ConstPattern();
202 }
203 
205 {
206  core::pack::task::PackerTaskOP packer_task = create_refinement_packing_task(target_pose, target_residue);
207 
210 
211  packer->apply(target_pose);
212 }
213 
215 {
216  TR.Debug << "Creating refinement packing task." << std::endl;
217  core::pack::task::TaskFactory taskfactory;
218 
220  taskfactory.push_back( new AddSearchPatternRotSetOp(
221  target_residue,
222  create_refinement_pattern(target_pose, target_residue)));
223 
225 
226  utility::vector1<bool> packmask(target_pose.total_residue(), false);
227  packmask[target_residue] = true;
228  task->restrict_to_residues(packmask);
229 
230  task->nonconst_residue_task(target_residue).restrict_to_repacking();
231 
232  return task;
233 }
234 
235 void
240  core::pose::Pose const & target_pose)
241 {
242  // Residue spec
243  if(tag->hasOption("residue_name"))
244  {
245  residue_name_ = tag->getOption<std::string>("residue_name");
246  }
247  else
248  {
249  utility_exit_with_message( "residue_name not specified" );
250  }
251 
252  // Partition Spec
253  search_partition_ = tag->getOption< core::Size >( "search_partition", 0 );
254  total_search_partition_ = tag->getOption< core::Size >( "total_search_partition", 1 );
255 
256  if (!(search_partition_ < total_search_partition_ && total_search_partition_ > 0))
257  {
258  TR.Error << "Invalid search partition specficition. Partition: " << search_partition_ << " Total partitions: " << total_search_partition_ << std::endl;
259 
260  utility_exit_with_message("Invalid search partition specification.");
261  }
262 
263  std::string mode_specification = tag->getOption<std::string>("execution_mode", "all");
264  boost::algorithm::to_lower(mode_specification);
265 
266  if(mode_specification == "all")
267  {
269  }
270  else if(mode_specification == "one")
271  {
273  }
274  else
275  {
276  TR.Error << "Invalid mode specification: " << mode_specification << std::endl;
277  utility_exit_with_message("Invalid mode specification: " + mode_specification);
278  }
279 
280  // Refinement scorefunction
282 
283  // Initialize residue representation
286 }
287 
288 
290 {
291  boost::algorithm::to_lower(name);
292 
293  if(name == "none")
294  {
295  return None;
296  }
297  else if(name == "probe")
298  {
299  return Probe;
300  }
301  else if(name == "full")
302  {
303  return Full;
304  }
305  else
306  {
307  TR.Error << "Invalid output mode specification: " << name << std::endl;
308  utility_exit_with_message("Invalid output mode specification: " + name);
309  }
310 }
311 
312 }
313 }
314 }