37 #include <basic/options/option.hh>
42 #include <ObjexxFCL/format.hh>
45 #include <basic/Tracer.hh>
52 #include <basic/options/keys/packing.OptionKeys.gen.hh>
54 #include <utility/vector1.hh>
56 using namespace ObjexxFCL;
57 using namespace ObjexxFCL::fmt;
63 basic::Tracer
T(
"core.pack.task", basic::t_info );
71 ResidueLevelTask_::ResidueLevelTask_(
75 include_current_( false ),
77 original_residue_type_( original_residue.type() ),
78 target_residue_type_(0),
79 designing_( original_residue.is_protein() ),
81 optimize_H_mode_( false ),
82 preserve_c_beta_( false ),
84 fix_his_tautomer_( false ),
86 design_disabled_( false ),
87 sample_proton_chi_( true ),
88 sample_rna_chi_( false ),
95 ex1aro_exposed_( false ),
96 ex2aro_exposed_( false ),
107 operate_on_ex1_( false ),
108 operate_on_ex2_( false ),
109 operate_on_ex3_( false ),
110 operate_on_ex4_( false )
112 using namespace chemical;
121 for ( ResidueTypeCOPs::const_iterator
122 aas_iter = aas.begin(),
123 aas_end = aas.end(); aas_iter != aas_end; ++aas_iter ) {
130 if (original_residue.
aa() ==
aa_unk)
132 }
else if ( original_residue.
is_DNA() ) {
135 for ( ResidueTypeCOPs::const_iterator type( dna_types.begin() ),
end( dna_types.end() );
136 type !=
end; ++type ) {
166 if ( concrete_residue->is_DNA() ) {
167 runtime_assert( chi == 1 );
170 if ( concrete_residue->is_aromatic() && chi <= 2 ) {
185 if ( buried && chi <= 4 ) {
188 }
else if ( chi == 2 ) {
190 }
else if ( chi == 3 ) {
203 using namespace basic::options;
204 using namespace OptionKeys::packing;
209 if ( option[ OptionKeys::packing::preserve_c_beta ].user() )
or_preserve_c_beta(
true );
210 if ( option[ OptionKeys::packing::prevent_repacking ].value() )
prevent_repacking();
217 using namespace basic::options;
218 using namespace OptionKeys::packing;
220 if ( option[ ex1::ex1 ].user() ) {
or_ex1( option[ ex1::ex1 ].value() ); }
221 if ( option[ ex2::ex2 ].user() ) {
or_ex2( option[ ex2::ex2 ].value() ); }
222 if ( option[ ex3::ex3 ].user() ) {
or_ex3( option[ ex3::ex3 ].value() ); }
223 if ( option[ ex4::ex4 ].user() ) {
or_ex4( option[ ex4::ex4 ].value() ); }
225 if ( option[ ex1aro::ex1aro ].user() )
226 {
or_ex1aro( option[ ex1aro::ex1aro ].value() ); }
228 if ( option[ ex2aro::ex2aro ].user() )
229 {
or_ex2aro( option[ ex2aro::ex2aro ].value() ); }
231 if ( option[ ex1aro_exposed::ex1aro_exposed ].user() )
234 if ( option[ ex2aro_exposed::ex2aro_exposed ].user() )
237 if ( option[ ex1::level ].user() )
240 if ( option[ ex2::level ].user() )
243 if ( option[ ex3::level ].user() )
246 if ( option[ ex4::level ].user() )
249 if ( option[ ex1aro::level ].user() )
252 if ( option[ ex2aro::level ].user() )
255 if ( option[ ex1aro_exposed::level ].user() )
258 if ( option[ ex2aro_exposed::level ].user() )
261 if ( option[ ex1::operate ].user() ) {
or_operate_on_ex1( option[ ex1::operate ]() ); }
262 if ( option[ ex2::operate ].user() ) {
or_operate_on_ex2( option[ ex2::operate ]() ); }
263 if ( option[ ex3::operate ].user() ) {
or_operate_on_ex3( option[ ex3::operate ]() ); }
264 if ( option[ ex4::operate ].user() ) {
or_operate_on_ex4( option[ ex4::operate ]() ); }
267 if ( option[ exdna::exdna ].user() && option[ exdna::level ].user() ) {
268 if ( option[ exdna::exdna ].value() && option[ exdna::level ].value() ) {
272 else if ( option[ exdna::exdna ].user() && !option[ exdna::level ].user() ) {
273 if ( option[ exdna::exdna ].value() ) {
277 else if ( !option[ exdna::exdna ].user() && option[ exdna::level ].user() ) {
278 if ( option[ exdna::level ].value() ) {
284 if ( option[ OptionKeys::packing::extrachi_cutoff ].user() ) {
317 T.Error <<
"Target type " << type->name() <<
" is not an allowed type!" << std::endl;
331 if ( setting )
return;
336 next_itr = type_itr; ++next_itr;
644 allowed_iter != allowed_end; ) {
645 iter_next = allowed_iter;
650 bool comp_HIS((*allowed_iter)->has_atom_name(
" HE2"));
651 bool comp_HIS_D((*allowed_iter)->has_atom_name(
" HD1"));
653 if ( (HIS != comp_HIS) || (HIS_D != comp_HIS_D) ) {
657 allowed_iter = iter_next;
700 Size num_allowed = std::count( allowed_aas.begin(), allowed_aas.end(),
true);
701 std::ostringstream aas;
702 if (num_allowed == 0){
709 if( allowed_aas[ i ] ){
710 aas << chemical::oneletter_code_from_aa( static_cast<chemical::AA>(i) );
716 if( !allowed_aas[ i ] ){
717 aas << chemical::oneletter_code_from_aa( static_cast<chemical::AA>(i) );
741 allowed_iter != allowed_end; ) {
742 iter_next = allowed_iter;
745 if ( ! allowed_aas[ (*allowed_iter)->aa() ] ) {
749 allowed_iter = iter_next;
763 allowed_iter != allowed_end; ) {
764 iter_next = allowed_iter;
768 if ( ! allowed_aas[ (*allowed_iter)->aa() ] && !
is_original_type( *allowed_iter ) ) {
772 allowed_iter = iter_next;
795 for ( AAs::const_iterator na( keep_nas.begin() ); na != keep_nas.end(); ++na ) {
796 if ( (*type_itr)->aa() == *na ) { keep =
true;
break; }
805 std::ostringstream nas;
827 allowed_iter != allowed_end; ) {
828 iter_next = allowed_iter;
831 allowed_iter = iter_next;
872 for ( chemical::ResidueTypeCOPs::const_iterator aas_iter = aas.begin(), aas_end = aas.end(); aas_iter != aas_end; ++aas_iter ) {
875 aaname == (**aas_iter).name3() )
912 for ( chemical::ResidueTypeCOPs::const_iterator
913 aas_iter = aas.begin(), aas_end = aas.end(); aas_iter != aas_end; ++aas_iter ) {
948 if ( !allowed )
return 0;
957 os <<
'\t' << (**type).name() <<
'\n';
1021 bool found_aa_difference =
false;
1025 allowed_iter != allowed_end; ++allowed_iter ) {
1028 found_aa_difference =
true;
1033 runtime_assert( ! found_aa_difference );
1104 for(rotamer_set::RotSetOperationList::const_iterator i = o.
rotsetops_.begin(); i != o.
rotsetops_.end(); ++i){
1174 new_behaviors.push_back(*i);
1183 new_rotamer_operations.push_back(*i);
1191 for(rotamer_set::RotSetOperationList::const_iterator i = o.
rotsetops_.begin(); i != o.
rotsetops_.end(); ++i){
1194 new_rotsetops.push_back(*i);
1199 std::vector<std::string> new_mode_tokens;
1203 new_mode_tokens.push_back(*i);
1212 new_allowed_residue_types.push_back(*i);
1303 my_allowed_residue_types.sort();
1304 o_allowed_residue_types.sort();
1307 myiter = my_allowed_residue_types.begin(),
1308 myend = my_allowed_residue_types.end(),
1309 oiter = o_allowed_residue_types.begin(),
1310 oend = o_allowed_residue_types.end();
1311 myiter != myend && oiter != oend; ) {
1313 if ( *myiter == *oiter ) {
1314 common.push_back( *myiter );
1318 }
else if ( *myiter < *oiter ) {
1328 myiter = my_allowed_residue_types2.begin(),
1329 myend = my_allowed_residue_types2.end();
1330 myiter != myend; ++myiter ) {
1331 if ( std::find( common.begin(), common.end(), *myiter ) != common.end() ) {
1351 residue_tasks_[resid].update_union(o);
1352 pack_residue_[resid] = residue_tasks_[resid].being_packed();
1361 residue_tasks_[resid].update_intersection(o);
1362 pack_residue_[resid] = residue_tasks_[resid].being_packed();
1371 residue_tasks_[resid].update_commutative(o);
1372 pack_residue_[resid] = residue_tasks_[resid].being_packed();
1386 PackerTask_ const & o(dynamic_cast<PackerTask_ const &>(t));
1388 if( nres_ != o.
nres_ ) utility_exit_with_message(
"unmatching nres_");
1392 for(
Size i = 1; i <= pack_residue_.size(); ++i) pack_residue_[i] =
true;
1397 n_to_be_packed_up_to_date_ =
false;
1426 IG_edge_reweights_->add_reweighter(*i);
1429 IG_edge_reweights_ = NULL;
1440 utility_exit_with_message(
"PackerTask can be symmetrized by union or by intersection but not both.");
1450 utility_exit_with_message(
"PackerTask can be symmetrized by union or by intersection but not both.");
1468 pack_residue_( nres_, true ),
1469 n_to_be_packed_( nres_ ),
1470 n_to_be_packed_up_to_date_( true ),
1471 linmem_ig_( false ),
1473 double_lazy_ig_( false ),
1474 dlig_mem_limit_( 0 ),
1475 multi_cool_annealer_( false ),
1476 mca_history_size_( 1 ),
1477 optimize_H_( false ),
1478 bump_check_( true ),
1479 max_rotbump_energy_( 5.0 ),
1482 disallow_quench_( false ),
1495 nres_( pose.total_residue() ),
1496 pack_residue_( nres_, true ),
1497 n_to_be_packed_( nres_ ),
1498 n_to_be_packed_up_to_date_( true ),
1499 linmem_ig_( false ),
1501 double_lazy_ig_( false ),
1502 dlig_mem_limit_( 0 ),
1503 multi_cool_annealer_( false ),
1504 mca_history_size_( 1 ),
1505 optimize_H_( false ),
1506 bump_check_( true ),
1507 max_rotbump_energy_( 5.0 ),
1510 disallow_quench_( false ),
1515 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1595 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1610 if ( setting < 0 )
return;
1624 if ( ! setting )
return;
1625 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1642 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1667 if ( ! setting )
return;
1668 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1682 if ( ! setting )
return;
1687 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1694 if ( ! setting )
return;
1695 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1702 if ( ! setting )
return;
1703 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1711 if ( ! setting )
return;
1712 if ( positions.size() == 0 ) {
1717 for (
Size ii=1; ii<=positions.size(); ++ii ) {
1755 if ( nbytes_for_rpes != 0 ) {
1771 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1772 residue_tasks_[ ii ].initialize_extra_rotamer_flags_from_command_line();
1802 out <<
"#Packer_Task" << std::endl;
1806 out <<
"resid\tpack?\tdesign?\tallowed_aas" << std::endl;
1817 allowed_iter(
residue_task( i ).allowed_residue_types_begin() );
1821 (*allowed_iter)->name();
1827 if( basic::options::option[ basic::options::OptionKeys::packing::print_pymol_selection ].value() ){
1841 out <<
" \tpack?\t\t\t\t" << (
pack_residue(resid) ?
"TRUE" :
"FALSE") <<
1842 "\n" <<
" \tdesign?\t\t\t\t" << (
design_residue(resid) ?
"TRUE" :
"FALSE") <<
1845 "\n" <<
" \tinclude adducts?\t\t" << (
residue_task(resid).
adducts() ?
"TRUE" :
"FALSE") <<
1853 "\n" <<
" \textra rotamer for chi 1\t\t" << (
residue_task(resid).
ex1() ?
"TRUE" :
"FALSE") <<
1854 "\n" <<
" \textra rotamer for chi 2\t\t" << (
residue_task(resid).
ex2() ?
"TRUE" :
"FALSE") <<
1855 "\n" <<
" \textra rotamer for chi 3\t\t" << (
residue_task(resid).
ex3() ?
"TRUE" :
"FALSE") <<
1856 "\n" <<
" \textra rotamer for chi 4\t\t" << (
residue_task(resid).
ex4() ?
"TRUE" :
"FALSE") <<
1857 "\n" <<
" \textra rotamer for chi 1 (aromatics)\t\t" << (
residue_task(resid).
ex1aro() ?
"TRUE" :
"FALSE") <<
1858 "\n" <<
" \textra rotamer for chi 2 (aromatics)\t\t" << (
residue_task(resid).
ex2aro() ?
"TRUE" :
"FALSE") <<
1859 "\n" <<
" \textra rotamer for chi 1 (exposed aromatics)\t" <<
1861 "\n" <<
" \textra rotamer for chi 2 (exposed aromatics)\t" <<
1887 using namespace basic::options;
1888 using namespace basic::options::OptionKeys;
1890 T <<
"Packer task: initialize from command line() " << std::endl;
1892 if ( option[ packing::linmem_ig ].user() && !
optimize_H_ ) {
1895 if ( option[ packing::lazy_ig ] && !
optimize_H_ ) {
1898 if ( option[ packing::double_lazy_ig ] && !
optimize_H_ ) {
1901 if ( option[ packing::multi_cool_annealer ].user() ) {
1906 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1910 if ( option[ packing::fix_his_tautomer ].user() ) {
1914 if ( option[ packing::repack_only ].value() ) {
1931 for (
Size ii = 1; ii <=
nres_; ++ii ) {
1932 if ( ! residues_allowed_to_be_packed[ ii ] ) {
1946 for (
Size ii = 1; ii <=
nres_; ++ii ) {
2054 for (
Size ii = 1; ii <=
nres_; ++ii ) {
2064 for (
Size ii = 1; ii <=
nres_; ++ii ) {
2073 for (
Size ii = 1; ii <=
nres_; ++ii ) {
2107 std::ostringstream modes;
2108 for( std::vector<std::string>::const_iterator i = mode_tokens_.begin(); i < mode_tokens_.end(); ++i){
2116 Size const exaro_sample_level,
2117 Size const ex_sample_level
2119 std::ostringstream ex_flags;
2121 if (exaro_sample_level == 1){
2122 ex_flags <<
"EX ARO " << chiid;
2123 }
else if (exaro_sample_level > 1) {
2124 ex_flags <<
"EX ARO " << chiid <<
" LEVEL " << exaro_sample_level;
2125 }
else if (ex_sample_level == 1){
2126 ex_flags <<
"EX " << chiid;
2127 }
else if (ex_sample_level > 1){
2128 ex_flags <<
"EX " << chiid <<
" LEVEL " << ex_sample_level;
2132 return ex_flags.str();
2137 std::ostringstream command_string;
2139 if (task_name !=
"NATRO") command_string <<
" " << task_name;
2141 std::string ex1 = get_ex_flags( 1, ex1aro_sample_level_, ex1_sample_level_);
2142 if (ex1 !=
"") command_string <<
" " << ex1;
2144 std::string ex2 = get_ex_flags( 2, ex2aro_sample_level_, ex2_sample_level_);
2145 if (ex2 !=
"") command_string <<
" " << ex2;
2147 std::string ex3 = get_ex_flags( 3, 0, ex3_sample_level_);
2148 if (ex3 !=
"") command_string <<
" " << ex3;
2150 std::string ex4 = get_ex_flags( 4, 0, ex4_sample_level_);
2151 if (ex4 !=
"") command_string <<
" " << ex4;
2153 if( extrachi_cutoff_ != 18) command_string <<
" EX_CUTOFF " << extrachi_cutoff_;
2159 if (*i ==
"TARGET"){
2160 command_string <<
" TARGET ";
2162 command_string <<
"_";
2167 command_string <<
" " << *i;
2171 return command_string.str();
2176 task_string <<
"start" << std::endl;
2180 if (residue_task_string !=
"" && residue_task_string !=
" ") {
2182 task_string << pose.
pdb_info()->number(i);
2183 task_string <<
" " << pose.
pdb_info()->chain(i);
2184 task_string <<
" " << residue_task_string << std::endl;
2187 return task_string.str();
2228 remapped_residue_tasks[ii].initialize_from_command_line();
2229 remapped_pack_residue.push_back(
true );
2230 }
else if( old_pos != 0 ){
2233 remapped_pack_residue.push_back(
pack_residue_[ old_pos ] );
2246 utility_exit_with_message(
"illegal");