28 #include <boost/foreach.hpp>
29 #define foreach BOOST_FOREACH
37 #include <basic/options/option.hh>
38 #include <basic/options/keys/inout.OptionKeys.gen.hh>
41 #include <basic/Tracer.hh>
42 #include <utility/string_util.hh>
43 #include <utility/vector1.hh>
44 #include <utility/tag/Tag.hh>
45 #include <utility/sql_database/types.hh>
46 #include <utility/vector0.hh>
47 #include <utility/excn/Exceptions.hh>
49 static basic::Tracer
TR(
"protocols.RosettaScripts.util" );
52 namespace rosetta_scripts {
54 using namespace core::scoring;
55 using namespace protocols::moves;
65 using namespace core::pack::task;
66 using namespace core::pack::task::operation;
69 if ( ! tag->hasOption(
"task_operations") )
return new_task_factory;
70 TR<<
"Object "<<tag->getOption<
std::string >(
"name",
"no_name" )<<
" reading the following task_operations: ";
77 using namespace core::pack::task;
78 using namespace core::pack::task::operation;
83 StringVec
const t_o_keys( utility::string_split( t_o_val,
',' ) );
84 TR<<
"Adding the following task operations\n";
85 for ( StringVec::const_iterator t_o_key( t_o_keys.begin() ),
end( t_o_keys.end() );
86 t_o_key !=
end; ++t_o_key ) {
87 if ( data.
has(
"task_operations", *t_o_key ) ) {
88 new_task_factory->push_back( data.
get<
TaskOperation * >(
"task_operations", *t_o_key ) );
91 throw utility::excn::EXCN_RosettaScriptsOption(
"TaskOperation " + *t_o_key +
" not found in DataMap.");
95 return new_task_factory;
102 using namespace core::pack::task;
103 using namespace core::pack::task::operation;
105 if ( tag->hasOption(
"task_factory" ) ){
107 TR <<
"taskfacotry name: " << name << std::endl;
109 if( data.
has(
"TaskFactory", name ) ){
111 TR<<
"found helper task_factory: "<< name <<
" for mover: "<<tag->getName()<< std::endl;
117 data.
add( tf_string , name , task_factory );
118 TR<<
"adding new TaskFactory to the datamap: "<< name <<std::endl;
122 if ( ! tag->hasOption(
"task_operations") )
return task_factory;
126 StringVec
const t_o_keys( utility::string_split( t_o_val,
',' ) );
127 TR<<
"Adding the following task operations to mover "<<tag->getName()<<
" called "<<tag->getOption<
std::string>(
"name",
"no_name" )<<
":\n";
129 for ( StringVec::const_iterator t_o_key( t_o_keys.begin() ),
end( t_o_keys.end() );
130 t_o_key !=
end; ++t_o_key ) {
132 if ( data.
has(
"task_operations", *t_o_key ) ) {
133 task_factory->push_back( data.
get<
TaskOperation * >(
"task_operations", *t_o_key ) );
137 throw utility::excn::EXCN_RosettaScriptsOption(
"TaskOperation " + *t_o_key +
" not found in DataMap.");
152 String
const t_o_val( tag->getOption<String>(
"task_operations",
"" ) );
156 t_o_key !=
end; ++t_o_key ) {
157 if ( data.
has(
"task_operations", *t_o_key ) ) {
158 task_operations.push_back( data.
get<
TaskOperation* >(
"task_operations", *t_o_key ) );
160 throw utility::excn::EXCN_RosettaScriptsOption(
"TaskOperation " + *t_o_key +
" not found in DataMap.");
164 return task_operations;
175 if ( ! data.
has(
"scorefxns", scorefxn_key ) ) {
176 throw utility::excn::EXCN_RosettaScriptsOption(
"ScoreFunction " + scorefxn_key +
" not found in DataMap.");
184 if( in_tag->hasOption(
"reference_name") ){
188 if( !data_map.
has(
"spm_ref_poses",refpose_name) ){
190 data_map.
add(
"spm_ref_poses",refpose_name,refpose );
196 else std::cerr <<
"WARNING: saved_reference_pose function called even though tag has no 'reference_name' entry. something's unclean somewhere." << std::endl;
203 using namespace core::kinematics;
204 using namespace utility::tag;
206 foreach(
TagPtr const tag, in_tag->getTags() ){
208 runtime_assert( name ==
"Jump" || name ==
"Chain" || name ==
"Span" );
209 if( name ==
"Jump" ){
211 bool const setting( tag->getOption<
bool >(
"setting" ) );
212 if( num == 0 ) mm->set_jump( setting );
213 else mm->set_jump( num, setting );
215 if( name ==
"Chain" ){
217 bool const chi( tag->getOption<
bool >(
"chi" ) );
218 bool const bb( tag->getOption<
bool >(
"bb" ) );
221 for(
core::Size i( chain_begin ); i <= chain_end; ++i ){
222 mm->set_chi( i, chi );
225 bool const bondangle( tag->getOption<
bool >(
"bondangle",
false ) );
226 bool const bondlength( tag->getOption<
bool >(
"bondlength",
false ) );
227 if (bondangle || bondlength) {
228 for(
core::Size i( chain_begin ); i <= chain_end; ++i ){
236 if( name ==
"Span" ){
239 runtime_assert( end >= begin );
240 bool const chi( tag->getOption<
bool >(
"chi" ) );
241 bool const bb( tag->getOption<
bool >(
"bb" ) );
243 mm->set_chi( i, chi );
246 bool const bondangle( tag->getOption<
bool >(
"bondangle",
false ) );
247 bool const bondlength( tag->getOption<
bool >(
"bondlength",
false ) );
248 if (bondangle || bondlength) {
264 using namespace core::kinematics;
266 if( in_tag() == NULL )
return;
270 for( tag_it = branch_tags.begin(); tag_it!=branch_tags.end(); ++tag_it ){
271 if( (*tag_it)->getName() ==
"MoveMap" ){
278 mm->set_jump(
true );
280 if( tag_it == branch_tags.end() )
return;
282 if( (*tag_it)->hasOption(
"name" ) ){
284 if( data.
has(
"movemaps", name ) ){
285 mm = data.
get<
MoveMap * >(
"movemaps", name );
286 TR<<
"Found movemap "<<name<<
" on datamap"<<std::endl;
289 data.
add(
"movemaps", name, mm );
290 TR<<
"Adding movemap "<<name<<
" to datamap"<<std::endl;
301 using namespace core::kinematics;
303 if( in_tag() == NULL )
return;
307 for( tag_it = branch_tags.begin(); tag_it!=branch_tags.end(); ++tag_it ){
308 if( (*tag_it)->getName() ==
"MoveMap" ){
314 mm->set_jump(
true );
315 if( tag_it == branch_tags.end() )
return;
317 if( (*tag_it)->hasOption(
"name" ) ){
318 TR<<
"ERROR in "<<*tag_it<<
'\n';
319 throw utility::excn::EXCN_RosettaScriptsOption(
"Tag called with option name but this option is not available to this mover. Note that FastRelax cannot work with a prespecified movemap b/c its movemap is parsed at apply time. Sorry." );
321 if( tag_it == branch_tags.end() )
return;
328 protocols::filters::Filters_map::const_iterator filter_it( filters.find( filter_name ) );
329 if( filter_it == filters.end() )
330 throw utility::excn::EXCN_RosettaScriptsOption(
"Filter "+filter_name+
" not found" );
331 return filter_it->second;
336 protocols::moves::Movers_map::const_iterator mover_it( movers.find( mover_name ) );
337 if( mover_it == movers.end() )
338 throw utility::excn::EXCN_RosettaScriptsOption(
"Mover "+mover_name+
" not found" );
339 return mover_it->second;
345 if ( ! xyz_vector_tag->hasOption(
"x") )
throw utility::excn::EXCN_RosettaScriptsOption(
"xyz_vector requires 'x' coordinates option");
346 if ( ! xyz_vector_tag->hasOption(
"y") )
throw utility::excn::EXCN_RosettaScriptsOption(
"xyz_vector requires 'y' coordinates option");
347 if ( ! xyz_vector_tag->hasOption(
"z") )
throw utility::excn::EXCN_RosettaScriptsOption(
"xyz_vector requires 'z' coordinates option");
366 if( chain && source.
residue( i ).
chain() != chain )
continue;
368 if( dist <= min_dist ){
373 if( min_dist <= 3.0 )
return nearest_res;
380 designable_vec.clear(); packable_vec.clear(); both.clear();
383 if( packer_task->being_designed( resi ) )
384 designable_vec.push_back( resi );
385 else if( packer_task->being_packed( resi ) )
386 packable_vec.push_back( resi );
388 if( designable && packable ){
389 both.insert( both.begin(), designable_vec.begin(), designable_vec.end() );
390 both.insert( both.end(), packable_vec.begin(), packable_vec.end() );
394 return designable_vec;