42 #include <basic/datacache/BasicDataCache.hh>
45 #include <basic/options/keys/abinitio.OptionKeys.gen.hh>
46 #include <basic/options/keys/out.OptionKeys.gen.hh>
63 #include <ObjexxFCL/string.functions.hh>
64 #include <ObjexxFCL/FArray1D.hh>
65 #include <ObjexxFCL/FArray2D.hh>
68 #include <utility/vector1.fwd.hh>
69 #include <utility/pointer/ReferenceCount.hh>
73 #include <numeric/numeric.functions.hh>
75 #include <basic/prof.hh>
76 #include <basic/Tracer.hh>
77 #include <basic/options/option.hh>
78 #include <basic/options/keys/OptionKeys.hh>
79 #include <basic/options/option_macros.hh>
91 #include <utility/vector0.hh>
92 #include <utility/vector1.hh>
93 #include <numeric/random/random.fwd.hh>
96 namespace ObjexxFCL { }
using namespace ObjexxFCL;
97 namespace ObjexxFCL {
namespace fmt { } }
using namespace ObjexxFCL::fmt;
103 static basic::Tracer
tr(
"protocols.membrane.abinitio",basic::t_info);
107 using namespace core;
108 using namespace basic;
109 using namespace basic::options;
110 using namespace basic::options::OptionKeys;
128 using namespace basic::options;
129 using namespace basic::options::OptionKeys;
130 option.add_relevant( OptionKeys::abinitio::increase_cycles );
131 option.add_relevant( OptionKeys::abinitio::smooth_cycles_only );
133 option.add_relevant( OptionKeys::abinitio::skip_convergence_check );
134 NEW_OPT( abinitio::debug_structures_2,
"write structures to debug-out files",
false );
136 NEW_OPT( abinitio::test_2,
"if set the protocol will run quickly to test your setup (files, cmd-line, etc. )",
false );
137 NEW_OPT( abinitio::log_frags_2,
"fragment insertions (each trial) will be logged to file",
"" );
138 NEW_OPT( abinitio::only_stage1_2,
"useful for benchmarks sets cycle of all higher stages to 0",
false );
139 NEW_OPT( abinitio::end_bias_2,
"set the endbias for Fragment moves", 30.0 );
140 NEW_OPT( templates::change_movemap_2,
"stage in which movemap is switched to allow all bb-residues to move, valid stages: 3..4 (HACK)", 3);
141 NEW_OPT( abinitio::symmetry_residue_2,
"hacky symmetry mode for dimers, fragments are inserted at i and i + SR - 1", -1 );
145 namespace protocols {
151 MembraneAbinitio::MembraneAbinitio(
158 brute_move_small_( brute_move_small ),
159 brute_move_small_top25_( brute_move_small_top25 ),
160 brute_move_large_( brute_move_large ),
161 smooth_move_small_( smooth_move_small ),
162 checkpoint_(
"MembraneAbinitio" )
169 movemap_ = brute_move_large->movemap();
180 checkpoint_(
"MembraneAbinitio" )
183 using namespace basic::options;
197 using namespace protocols::simple_moves;
234 using namespace moves;
235 using namespace scoring;
248 PROF_START( basic::STAGE1 );
249 clock_t starttime = clock();
251 tr.Info <<
"\n===================================================================\n";
252 tr.Info <<
" Stage 1 \n";
253 tr.Info <<
" Folding with score0 for max of " <<
stage1_cycles() << std::endl;
287 clock_t endtime = clock();
288 PROF_STOP( basic::STAGE1 );
291 tr <<
"Timeperstep: " << (double(endtime) - starttime )/(CLOCKS_PER_SEC ) << std::endl;
313 Size tmh_inserted(0);
318 while(tmh_inserted<total_tmhelix)
320 tr.Info <<
"\n===================================================================\n";
321 tr.Info <<
" Stage 2 \n";
322 tr.Info <<
" Starting sequencial insertion of " << total_tmhelix <<
", membrane helices " << tmh_inserted <<
" inserted so far\n";
323 tr.Info <<
" Folding with score_membrane for " <<
stage2_cycles() << std::endl;
326 PROF_START( basic::STAGE2 );
327 clock_t starttime = clock();
341 clock_t endtime = clock();
342 PROF_STOP( basic::STAGE2 );
347 tr <<
"Timeperstep: " << (double(endtime) - starttime )/(CLOCKS_PER_SEC ) << std::endl;
361 tr.Info <<
"\n===================================================================\n";
362 tr.Info <<
" Stage 3 \n";
363 tr.Info <<
" Folding all inserted regions with score_membrane for " <<
stage3_cycles() <<std::endl;
366 PROF_START( basic::STAGE3 );
367 clock_t starttime = clock();
380 clock_t endtime = clock();
381 PROF_STOP( basic::STAGE3);
385 tr <<
"Timeperstep: " << (double(endtime) - starttime )/( CLOCKS_PER_SEC) << std::endl;
393 tr.Info <<
"\n===================================================================\n";
394 tr.Info <<
" Stage 3b \n";
395 tr.Info <<
" Folding all inserted regions with score_membrane for " <<
stage3_cycles() <<std::endl;
398 PROF_START( basic::STAGE3 );
399 clock_t starttime = clock();
412 clock_t endtime = clock();
413 PROF_STOP( basic::STAGE3);
417 tr <<
"Timeperstep: " << (double(endtime) - starttime )/( CLOCKS_PER_SEC) << std::endl;
435 tr.Info <<
"\n===================================================================\n";
436 tr.Info <<
" Stage 4 \n";
437 tr.Info <<
" Folding ALL REGIONS with score_membrane for " <<
stage4_cycles() <<std::endl;
439 PROF_START( basic::STAGE4 );
440 clock_t starttime = clock();
454 clock_t endtime = clock();
455 PROF_STOP( basic::STAGE4 );
459 tr <<
"Timeperstep: " << (double(endtime) - starttime )/( CLOCKS_PER_SEC ) << std::endl;
463 tr.Info <<
"\n===================================================================\n";
464 tr.Info <<
" Finished Abinitio \n";
466 tr.Info << std::endl;
485 return "MembraneAbinitio";
604 using namespace basic::options;
613 using namespace scoring;
614 tr.Debug <<
"creating membrane scoring functions" << std::endl;
626 tr.Debug <<
"set score weights for ";
628 else tr.Debug <<
"stage " << (stage <=
STAGE_3a ? stage : ( stage-1 ) ) << ( stage ==
STAGE_3b ?
"b " :
" " );
655 using namespace basic::options;
662 set_cycles( option[ OptionKeys::abinitio::increase_cycles ] );
686 Size new_membrane_region=0;
693 Size const total_tmhelix=topology.tmhelix();
699 tr.Info <<
"Adding region tmh:" << total_tmhelix <<
" tmh_inserted: " << topology.tmh_inserted() <<
" nres: " << total_residue <<
" num_jumps: " << num_jumps << std::endl;
706 FArray2D_int jump_point(num_cutpoints,2);
709 FArray1D_bool new_region(total_residue,
false);
710 FArray1D_bool inserted_regions(total_residue,
false);
714 FArray2D_bool nb_tmh_list(total_tmhelix,total_tmhelix,
false);
717 FArray2D_bool tmh_jump(total_tmhelix,total_tmhelix,
false);
719 new_region(j) =
false;
720 inserted_regions(j) =
false;
723 if(j<=topology.span_end(1))
725 res_TMH_mapping(j)=1;
726 }
else if(j>topology.span_end(total_tmhelix)) {
727 res_TMH_mapping(j)=total_tmhelix;
731 for (
Size reg = 2; reg <= total_tmhelix; ++reg ) {
732 if(j>topology.span_end(reg-1) && j<=topology.span_end(reg))
734 res_TMH_mapping(j)=reg;
742 for (
Size reg = 1; reg < total_tmhelix; ++reg ) {
745 for(
Size i=topology.span_end(reg);i<topology.span_begin(reg+1);++i) {
746 for(
Size j=1;j<=num_cutpoints;++j){
753 nb_tmh_list(reg,reg+1)=
true;
754 nb_tmh_list(reg+1,reg)=
true;
762 for(
Size i=1;i<=num_jumps;++i)
766 tmh_jump(res_TMH_mapping(d),res_TMH_mapping(u))=
true;
767 tmh_jump(res_TMH_mapping(d),res_TMH_mapping(d))=
true;
768 tmh_jump(res_TMH_mapping(u),res_TMH_mapping(d))=
true;
769 tmh_jump(res_TMH_mapping(u),res_TMH_mapping(u))=
true;
770 nb_tmh_list(res_TMH_mapping(d),res_TMH_mapping(u))=
true;
771 nb_tmh_list(res_TMH_mapping(u),res_TMH_mapping(d))=
true;
783 FArray1D<Size> insertable_region(total_tmhelix);
785 if(topology.tmh_inserted()==0)
787 for (
Size i = 1; i <= total_tmhelix; ++i ) {
788 if(tmh_jump(i,i) && !topology.allow_tmh_scoring(i))
791 insertable_region(k)=i;
792 tr.Info <<
"INSERTABLE JUMP REGION: " << i << std::endl;
799 if(topology.tmh_inserted()==0)
801 for (
Size j = 1; j <= total_tmhelix; ++j ) {
803 insertable_region(k)=j;
804 tr.Info <<
"INSERTABLE REGION FIRST PASS: " << j << std::endl;
807 for (
Size i = 1; i <= total_tmhelix; ++i ) {
808 if(topology.allow_tmh_scoring(i))
810 for (
Size j = 1; j <= total_tmhelix; ++j ) {
811 if(!topology.allow_tmh_scoring(j) && nb_tmh_list(i,j))
814 insertable_region(k)=j;
815 tr.Info <<
"INSERTABLE REGION: " << j << std::endl;
824 Size index=1 +
static_cast< int >( numeric::random::uniform()*k);
825 FArray1D_bool new_membrane_regions(total_tmhelix,
false);
826 new_membrane_region=insertable_region(index);
827 new_membrane_regions(new_membrane_region)=
true;
828 if(tmh_jump(new_membrane_region,new_membrane_region))
832 for(
Size i=1;i<=total_tmhelix;++i) {
833 new_membrane_regions(i)=tmh_jump(new_membrane_region,i);
834 if(new_membrane_regions(i)) {
835 for(
Size j=1;j<=total_tmhelix;++j) {
836 new_membrane_regions(j)=tmh_jump(i,j);
840 for(
Size i=1;i<=total_tmhelix;++i) {
841 if(new_membrane_regions(i))
843 topology.set_allow_tmh_scoring(i,
true);
844 tr.Info <<
"NEW JUMP REGION: index " << i << std::endl;
851 if(topology.tmh_inserted()==0) {
852 Size new_membrane_region2;
853 if(new_membrane_region==1){
854 new_membrane_region2=new_membrane_region+1;
855 }
else if(new_membrane_region==total_tmhelix) {
856 new_membrane_region2=new_membrane_region-1;
857 }
else if( numeric::random::uniform() < 0.5) {
858 new_membrane_region2=new_membrane_region+1;
861 new_membrane_region2=new_membrane_region-1;
863 tr.Info <<
"NEW REGION FIRST PASS: region1 region2 " << new_membrane_region <<
" " << new_membrane_region2 << std::endl;
864 new_membrane_regions(new_membrane_region2)=
true;
865 topology.set_allow_tmh_scoring(new_membrane_region2,
true);
870 tr.Info <<
"NEW REGION: index " << new_membrane_region <<
" " << index <<
" " << k << std::endl;
872 topology.set_allow_tmh_scoring(new_membrane_region,
true);
887 for (
Size i = 1; i <= total_tmhelix; ++i ) {
888 if(topology.allow_tmh_scoring(i)) {
892 start=topology.span_end(i-1);
894 if(i==total_tmhelix){
897 end=topology.span_begin(i+1);
899 for(
Size j=1;j<=num_cutpoints;++j) {
900 if(cuts[j] >= start && cuts[j] <= end) {
901 if(cuts[j]-start >= end-cuts[j]) {
909 inserted_regions(j)=
true;
910 if(new_membrane_regions(i)) {
922 for (
Size j = 1; j <= total_residue; ++j ) {
923 inserted_regions(j) =
true;
927 topology.set_tmh_inserted(TMHs);
931 new_mm->set_bb(
true );
932 for (
Size i = 1; i <= total_residue; ++i ) {
933 topology.set_allow_scoring(i,
true);
936 for (
Size i = 1; i <= total_residue; ++i ) {
937 if(inserted_regions(i)) {
938 topology.set_allow_scoring(i,
true);
940 topology.set_allow_scoring(i,
false);
943 new_mm->set_bb(i,
true);
945 new_mm->set_bb(i,
false);
986 tr.Info <<
"max_tm new_reg TMHs done tmh_inserted " << std::endl;
988 tr.Info << I( 7, total_tmhelix ) <<
' ' << I( 7, new_membrane_region ) <<
' ' << I(4, TMHs) <<
' ' << done <<
' ' << topology.tmh_inserted() << std::endl;
1016 new_mm->set_bb(i,
true);
1018 new_mm->set_bb(i,
false);
1034 for (
Size reg = 1; reg <= total_tmhelix; ++reg ) {
1042 res_TMH_mapping(j)=tmh;
1047 std::cout <<
"TMH : ";
1051 std::cout << res_TMH_mapping(i);
1054 std::cout <<
"SCORING : ";
1063 std::cout <<
"MOVEMAP : ";
1085 insert_pos_( pose.total_residue(), false )
1087 set_initial_pose( pose );
1088 compute_insert_pos( insert_map );
1093 for ( core::fragment::InsertMap::const_iterator it = insert_map.begin(),
1094 eit = insert_map.end(); it != eit; ++it ) {
1095 Size const pos ( *it );
1096 if ( pos > insert_pos_.size() )
break;
1097 insert_pos_[ pos ] =
true;
1102 for (
unsigned int i = 1; i <= pose.
total_residue(); ++i ) {
1103 initial_phis.push_back( pose.
phi(i) );
1104 initial_psis.push_back( pose.
psi(i) );
1107 original_sequence_ = pose.
sequence();
1112 assert( original_sequence_ == pose.
sequence() );
1113 for (
unsigned int i = 1; i <= pose.
total_residue(); ++i ) {
1114 if ( initial_phis[i] == pose.
phi(i) && insert_pos_[ i ] ) {
1117 if ( initial_psis[i] == pose.
psi(i) && insert_pos_[ i ] ) {
1139 class MonteCarloExceptionConverge;
1140 typedef utility::pointer::owning_ptr< MonteCarloExceptionConverge > MonteCarloExceptionConvergeOP;
1142 class MonteCarloExceptionConverge : public moves::PoseCondition {
1144 MonteCarloExceptionConverge() : bInit_( false ), ct_( 0 ) {};
1145 void reset() { ct_ = 0; bInit_ = false; };
1146 void set_trials( moves::TrialMoverOP trin ) {
1148 assert( trials_->keep_stats() );
1151 virtual bool operator() ( const core::pose::Pose & pose );
1153 pose::Pose very_old_pose_;
1156 moves::TrialMoverOP trials_;
1160 // keep going --> return true
1161 bool MonteCarloExceptionConverge::operator() ( const core::pose::Pose & pose ) {
1164 very_old_pose_ = pose;
1168 tr.Trace << "TrialCounter in MonteCarloExceptionConverge: " << trials_->num_accepts() << std::endl;
1169 if ( numeric::mod(trials_->num_accepts(),100) != 0 ) return true;
1170 if ( (Size) trials_->num_accepts() <= last_move_ ) return true;
1171 last_move_ = trials_->num_accepts();
1172 // change this later to this: (after we compared with rosetta++ and are happy)
1173 // if ( numeric::mod(++ct_, 1000) != 0 ) return false; //assumes an approx acceptance rate of 0.1
1175 // still here? do the check:
1177 core::Real converge_rms = core::scoring::CA_rmsd( very_old_pose_, pose );
1178 very_old_pose_ = pose;
1179 if ( converge_rms >= 3.0 ) {
1182 // if we get here thing is converged stop the While-Loop
1183 tr.Info << " stop cycles in stage3 due to convergence " << std::endl;
1202 tr.Info <<
"Step (score0) " << j << std::endl;
1205 tr.Info <<
"Replaced extended chain after " << j <<
" cycles" << std::endl;
1211 tr.Info <<
"Warning: extended chain may still remain after " <<
stage1_cycles() <<
" cycles!" << std::endl;
1330 for (
int lct1 = 1; lct1 <= nloop1; lct1++) {
1332 for (
int lct2 = 1; lct2 <= nloop2; lct2++, iteration++ ) {
1333 tr.Debug <<
"Loop: " << lct1 <<
" " << lct2 << std::endl;
1335 if ( !
recover_checkpoint( pose,
"stage_3_iter"+ObjexxFCL::string_of( lct1)+
"_"+ObjexxFCL::string_of(lct2) )) {
1339 if ( numeric::mod( lct2, 2 ) == 0 || lct2 > 7 ) {
1340 Real chainbreak_weight=lct1*lct2*0.25;
1341 mc_->recover_low( pose );
1342 tr.Debug <<
"select score_stage3a..." << std::endl;
1347 Real chainbreak_weight=lct1*lct2*0.05;
1348 mc_->recover_low( pose );
1349 tr.Debug <<
"select score_stage3b..." << std::endl;
1355 tr.Debug <<
" Score stage3 loop iteration " << lct1 <<
" " << lct2 << std::endl;
1381 return nloop1*nloop2*cycles;
1409 for (
int lct1 = 1; lct1 <= nloop1; lct1++) {
1411 for (
int lct2 = 1; lct2 <= nloop2; lct2++, iteration++ ) {
1412 tr.Debug <<
"Loop: " << lct1 <<
" " << lct2 << std::endl;
1414 if ( !
recover_checkpoint( pose,
"stage_3_iter"+ObjexxFCL::string_of( lct1)+
"_"+ObjexxFCL::string_of(lct2) )) {
1418 if ( numeric::mod( lct2, 2 ) == 0 || lct2 > 7 ) {
1419 Real chainbreak_weight=lct1*lct2*0.25;
1420 mc_->recover_low( pose );
1421 tr.Debug <<
"select score_stage3a..." << std::endl;
1426 Real chainbreak_weight=lct1*lct2*0.05;
1427 mc_->recover_low( pose );
1428 tr.Debug <<
"select score_stage3b..." << std::endl;
1434 tr.Debug <<
" Score stage3 loop iteration " << lct1 <<
" " << lct2 << std::endl;
1459 return nloop1*nloop2*cycles;
1495 Size nloop_stage4 = 3;
1497 for (
Size kk = 1; kk <= nloop_stage4; ++kk ) {
1506 tr.Debug <<
"switch to smooth moves" << std::endl;
1509 Real chainbreak_weight=kk*0.5+2.5;
1513 tr.Debug <<
"prepare ..." << std::endl ;
1519 tr.Debug <<
"finished" << std::endl;
1520 checkpoint( pose,
"stage4_kk_" + ObjexxFCL::string_of(kk));
1540 (*score_stage1_)( pose );
1543 new_mm->set_bb(
true );
1553 (*score_stage2_)(pose);
1579 (*score_stage4_)( pose );
1673 using namespace core::io::silent;
1674 if ( option[ basic::options::OptionKeys::out::file::silent ].user() ) {
1676 std::string silent_file = option[ basic::options::OptionKeys::out::file::silent ]() +
"_" + prefix;
1685 sfd.
write_silent_struct( pss, silent_file, !option[ OptionKeys::abinitio::debug_structures_2 ]() );
1688 if ( option[ basic::options::OptionKeys::abinitio::explicit_pdb_debug ]() ) {
1731 return *membrane_topology;
1756 return *membrane_embed;