Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CompoundTranslate.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
11 /// @brief
12 /// @author Gordon Lemmon (glemmon@gmail.com)
13 
14 // Unit Headers
18 // AUTO-REMOVED #include <protocols/ligand_docking/grid_functions.hh>
19 // AUTO-REMOVED #include <protocols/rigid/RB_geometry.hh>
20 // AUTO-REMOVED #include <protocols/rigid/RigidBodyMover.hh>
21 
22 #include <utility/exit.hh>
23 #include <basic/Tracer.hh>
24 #include <core/types.hh>
25 #include <numeric/random/random_permutation.hh>
26 
27 // AUTO-REMOVED #include <core/chemical/AtomType.hh>
28 #include <core/kinematics/Jump.hh>
29 #include <core/pose/util.hh>
30 #include <utility/vector0.hh>
31 #include <utility/vector1.hh>
32 #include <utility/tag/Tag.hh>
33 
34 #include <utility/excn/Exceptions.hh>
35 #include <boost/foreach.hpp>
36 
37 //Auto Headers
38 #define foreach BOOST_FOREACH
39 using basic::T;
40 using basic::Error;
41 using basic::Warning;
42 
43 namespace protocols {
44 namespace ligand_docking {
45 
46 static basic::Tracer translate_tracer("protocols.ligand_docking.CompoundTranslate", basic::t_debug);
47 
48 
51 {
53 }
54 
57  return new CompoundTranslate;
58 }
59 
62 {
63  return "CompoundTranslate";
64 }
65 
66 ///@brief
68  //utility::pointer::ReferenceCount(),
69  Mover("CompoundTranslate")
70 {}
71 
73  //utility::pointer::ReferenceCount(),
74  protocols::moves::Mover( that ),
75  translates_(that.translates_),
76  randomize_order_(that.randomize_order_),
77  allow_overlap_(that.allow_overlap_)
78 {}
79 
81 
83  return new CompoundTranslate( *this );
84 }
85 
87  return new CompoundTranslate;
88 }
89 
91  return "CompoundTranslate";
92 }
93 
94 ///@brief parse XML (specifically in the context of the parser/scripting scheme)
95 void
97  utility::tag::TagPtr const tag,
98  protocols::moves::DataMap & datamap,
99  protocols::filters::Filters_map const & filters,
100  protocols::moves::Movers_map const & movers,
101  core::pose::Pose const & pose
102 )
103 {
104  if ( tag->getName() != "CompoundTranslate" ){
105  throw utility::excn::EXCN_RosettaScriptsOption("This should be impossible");
106  }
107  if ( ! tag->hasOption("randomize_order")){
108  throw utility::excn::EXCN_RosettaScriptsOption("CompoundTranslate needs a 'randomize_order' option");
109  }
110  if ( ! tag->hasOption("allow_overlap")){
111  throw utility::excn::EXCN_RosettaScriptsOption("CompoundTranslate needs an 'allow_overlap' option");
112  }
113  {// parsing randomize_order tag
114  std::string allow_overlap_string= tag->getOption<std::string>("randomize_order");
115  if(allow_overlap_string == "true" || allow_overlap_string == "True")
116  randomize_order_= true;
117  else if(allow_overlap_string == "false" || allow_overlap_string == "False")
118  randomize_order_= false;
119  else throw utility::excn::EXCN_RosettaScriptsOption("'randomize_order' option takes arguments 'true' or 'false'");
120  }
121  {// parsing allow_overlap tag
122  std::string allow_overlap_string= tag->getOption<std::string>("allow_overlap");
123  if(allow_overlap_string == "true" || allow_overlap_string == "True")
124  allow_overlap_= true;
125  else if(allow_overlap_string == "false" || allow_overlap_string == "False")
126  allow_overlap_= false;
127  else throw utility::excn::EXCN_RosettaScriptsOption("'allow_overlap' option takes arguments 'true' or 'false'");
128  }
129 
130  foreach(utility::tag::TagPtr tag, tag->getTags()){
131  std::string const name= tag->getName();
132  if( name == "Translate"){
134  translate->parse_my_tag(tag, datamap, filters, movers, pose);
135  translates_.push_back(translate);
136  }
137  else if( name == "Translates"){
138  if ( ! tag->hasOption("chain") ) throw utility::excn::EXCN_RosettaScriptsOption("'Translates' mover requires chain tag");
139  if ( ! tag->hasOption("distribution") ) throw utility::excn::EXCN_RosettaScriptsOption("'Translates' mover requires distribution tag");
140  if ( ! tag->hasOption("angstroms") ) throw utility::excn::EXCN_RosettaScriptsOption("'Translates' mover requires angstroms tag");
141  if ( ! tag->hasOption("cycles") ) throw utility::excn::EXCN_RosettaScriptsOption("'Translates' mover requires cycles tag");
142 
143  std::string const chain = tag->getOption<std::string>("chain");
145 
146  foreach(core::Size chain_id, chain_ids){
147  Translate_info translate_info;
148  translate_info.chain_id= chain_id;
149  translate_info.jump_id = core::pose::get_jump_id_from_chain_id(chain_id, pose);
150  std::string distribution_str= tag->getOption<std::string>("distribution");
151  translate_info.distribution= get_distribution(distribution_str);
152  translate_info.angstroms = tag->getOption<core::Real>("angstroms");
153  translate_info.cycles = tag->getOption<core::Size>("cycles");
154  if(tag->hasOption("force")){
155  if(tag->getOption<std::string>("force") == "true")
156  translate_info.force= true;
157  else if(tag->getOption<std::string>("force") != "false")
158  throw utility::excn::EXCN_RosettaScriptsOption("'force' option is true or false");
159  }
160  translates_.push_back(new Translate(translate_info));
161  }
162  }
163  else{
164  throw utility::excn::EXCN_RosettaScriptsOption("CompoundTranslate only takes Translate or Translates child tags");
165  }
166  }
167 }
168 
170  if(randomize_order_)
171  numeric::random::random_permutation(translates_, numeric::random::RG);
172 
173  std::set<core::Size> chains_to_translate;
174 
175  // TranslateOPs::iterator begin= translates_.begin(); // Unused variable causes warning.
176  // TranslateOPs::iterator const end= translates_.end(); // Unused variable causes warning.
177 
179  core::Size chain_id= translate->get_chain_id(pose);
180  chains_to_translate.insert(chain_id);
181  }
182 
183  if(allow_overlap_){
184  foreach(TranslateOP translate, translates_){
185  translate->add_excluded_chains(chains_to_translate.begin(), chains_to_translate.end());
186  translate->apply(pose);
187  }
188  }
189  else{ // remove each chain from the exclusion list so that placed chains are in the grid
190  foreach(TranslateOP translate, translates_){
191  translate->add_excluded_chains(chains_to_translate.begin(), chains_to_translate.end());
192  translate->apply(pose);
193  core::Size chain_id= translate->get_chain_id(pose);
194  chains_to_translate.erase(chain_id);
195  }
196  }
197 }
198 
199 } //namespace ligand_docking
200 } //namespace protocols