23 #include <numeric/random/random.hh>
24 #include <basic/Tracer.hh>
33 #include <utility/tag/Tag.hh>
34 #include <utility/exit.hh>
35 #include <utility/vector0.hh>
36 #include <utility/vector1.hh>
37 #include <utility/string_util.hh>
38 #include <utility/io/izstream.hh>
40 #include <utility/json_spirit/json_spirit_reader.h>
43 #include <boost/foreach.hpp>
44 #define foreach BOOST_FOREACH
46 #include <utility/excn/Exceptions.hh>
54 namespace ligand_docking {
56 static basic::Tracer
start_from_tracer(
"protocols.ligand_docking.ligand_options.Start_from", basic::t_debug);
84 protocols::moves::Mover( that ),
86 starting_points_(that.starting_points_),
87 potential_starting_positions_(that.potential_starting_positions_)
114 if ( tag->getName() !=
"StartFrom" ){
115 throw utility::excn::EXCN_RosettaScriptsOption(
"This should be impossible");
117 if ( ! tag->hasOption(
"chain") )
throw utility::excn::EXCN_RosettaScriptsOption(
"'StartFrom' mover requires chain tag");
123 if( name ==
"features"){
124 std::cout <<
"found features tag with type '" << child_tag->getOption<
std::string>(
"type") <<
"'" << std::endl;
126 }
else if( name ==
"Coordinates")
128 if ( ! child_tag->hasOption(
"x") )
throw utility::excn::EXCN_RosettaScriptsOption(
"'StartFrom' mover Coordinates tag requires 'x' coordinates option");
129 if ( ! child_tag->hasOption(
"y") )
throw utility::excn::EXCN_RosettaScriptsOption(
"'StartFrom' mover Coordinates tag requires 'y' coordinates option");
130 if ( ! child_tag->hasOption(
"z") )
throw utility::excn::EXCN_RosettaScriptsOption(
"'StartFrom' mover Coordinates tag requires 'z' coordinates option");
133 if(child_tag->hasOption(
"pdb_tag"))
135 pdb_tag = child_tag->getOption<
std::string>(
"pdb_tag");
145 }
else if(name ==
"File")
147 if(!child_tag->hasOption(
"filename"))
throw utility::excn::EXCN_RosettaScriptsOption(
"'StartFrom' mover File tag requires 'filename' coordinates option");
156 std::map< std::string, utility::vector1<core::Vector> >::iterator start_point_it =
starting_points_.find(pdb_tag);
161 new_point_set.push_back(coords);
165 start_point_it->second.push_back(coords);
180 utility_exit_with_message(
"StartFrom mover cannot find the chain " +
chain_+
" in the current pose.");
186 std::list<std::string> component_tags(utility::split_to_list(input_tag));
190 for(std::list<std::string>::iterator tag_it = component_tags.begin(); tag_it != component_tags.end();++tag_it)
192 std::map< std::string, utility::vector1<core::Vector> >::iterator tag_points(
starting_points_.find(*tag_it));
195 centroid_points = tag_points->second;
202 utility_exit_with_message(
"There are no default starting coordinates specified in the StartFrom mover, and none of the specified coordinates match the current tag");
204 centroid_points = tag_points->second;
208 assert(centroid_points.size());
210 core::Vector desired_centroid = centroid_points[starting_point_index];
224 start_from_tracer <<
"cannot find structure with hash " <<hash <<
" and tag " <<
226 utility_exit_with_message(
"the current structure is not in the startfrom_file");
230 utility_exit_with_message(
"You must specify either a Coordinates or a File tag in the StartFrom mover");
236 utility::io::izstream infile;
237 infile.open(filename.c_str(),std::ifstream::in);
238 utility::json_spirit::mValue startfrom_data;
239 utility::json_spirit::read(infile,startfrom_data);
255 utility::json_spirit::mArray start_positions = startfrom_data.get_array();
256 for(utility::json_spirit::mArray::iterator start_it = start_positions.begin(); start_it != start_positions.end();++start_it)
258 utility::json_spirit::mObject position_data(start_it->get_obj());
260 std::string hash = position_data[
"hash"].get_str();
269 start_from_tracer <<
"WARNING: There is more than one entry in the startfrom_file with the hash " << hash <<std::endl;
285 core::Vector const trans_vec = desired_centroid - ligand_centroid;
286 core::Real const trans_len = trans_vec.length();
287 if (trans_len > 1e-3) {