54 #include <basic/options/option.hh>
55 #include <basic/options/keys/loops.OptionKeys.gen.hh>
56 #include <basic/options/keys/evaluation.OptionKeys.gen.hh>
59 #include <ObjexxFCL/format.hh>
60 #include <ObjexxFCL/string.functions.hh>
63 #include <basic/Tracer.hh>
71 #include <utility/vector1.hh>
72 #define foreach BOOST_FOREACH
79 #include <utility/string_util.hh>
80 #include <utility/vector1.hh>
81 #include <boost/foreach.hpp>
84 namespace ObjexxFCL {
namespace fmt { } }
using namespace ObjexxFCL::fmt;
86 static basic::Tracer
TR(
"protocols.loops.util");
94 using namespace kinematics;
103 bool const bReadWeights = ( weights.size() >= pose.
total_residue() );
104 if ( !bReadWeights ) {
110 for (
Size pos = it->start(); pos <= it->stop(); ++pos ) {
111 Size const seq_dist( std::min( (
int) pos - it->start(), (
int) it->stop() - pos ) + 1);
113 if ( bReadWeights ) {
114 coord_sdev = weights[ pos ];
116 coord_sdev = ( 1.0/seq_dist );
117 weights[ pos ] = coord_sdev;
121 for (
Size ii = 1; ii<= rsd.natoms(); ++ii ) {
134 rsd.xyz( atomID.atomno() ),
149 using namespace core::fragment;
162 Size const total_insert = insert_map.size();
163 TR.Trace <<
"size of insertmap: " << total_insert <<
" -- ";
164 for (
Size i = 1; i<=total_insert; i++ )
TR.Trace <<
" " << insert_map[ i ];
165 TR.Trace <<
"insert_size: \nRESIDUES: ";
166 for (
Size i = 1; i<=insert_map[ total_insert ]; i++ )
TR.Trace <<
" " << RJ(3,i);
167 TR.Trace <<
"\nINSERT: ";
168 for (
Size i = 1; i<=insert_map[ total_insert ]; i++ )
TR.Trace <<
" " << RJ(3,insert_size[ i ]);
169 TR.Trace << std::endl;
172 Size const total_insert = insert_map.size();
174 for (
Size i = 1; i<=total_insert; i++ ) {
175 Size const pos ( insert_map[ i ] );
176 Size const size ( insert_size[ pos ] );
178 source.
frames( pos, copy_frames );
179 for ( FrameList::iterator it = copy_frames.begin(), eit = copy_frames.end();
181 TR.Trace <<
"add frame at pos " << pos <<
" " << (*it)->length() <<
" insert_size " << size << std::endl;
182 if ( (*it)->length() ==
size ) loop_frags.
add( *it );
183 else if ( shorten && size > shorten ) loop_frags.
add( (*it)->generate_sub_frame( size ) );
207 TR.Debug <<
"extend structure for " << loops << std::endl;
211 const Loop& loop = *i;
230 using namespace core;
234 for(
Size i = 1; i < nres; i ++ ){
240 Real score = scorefxn(pose);
242 for(
Size l = 1; l <= nloops; l++ ){
243 if( l > loops.
size() ){
251 for(
Size i = 1; i < nres; i ++ ){
252 if( ( i < loops[l].
start() ) || ( i > loops[l].
stop() ) ){
253 loop_list.push_back( i );
255 non_loop_list.push_back( i );
261 setPoseExtraScores( pose,
"ScoreLoopI" + ObjexxFCL::right_string_of(l,3,
'0'), loopscore );
262 setPoseExtraScores( pose,
"ScoreLoopC" + ObjexxFCL::right_string_of(l,3,
'0'), score - loopscore - nonloopscore );
263 setPoseExtraScores( pose,
"ScoreLoopL" + ObjexxFCL::right_string_of(l,3,
'0'), score - nonloopscore );
273 runtime_assert( ir <= native_pose_super.total_residue() );
275 id::AtomID const id1( native_pose_super.residue(ir).atom_index(
"CA"), ir );
277 atom_map.set(id1, id2);
285 for(
Size l = 1; l <= nloops; l++ ){
286 if( l > loops.
size() ){
315 if ( last + max_gap < pos ) {
316 if ( last - start >= min_length ) {
328 using namespace basic::options;
329 using namespace basic::options::OptionKeys;
330 std::string const weights( option[ OptionKeys::loops::cen_weights ]() ),
331 patch( option[ OptionKeys::loops::cen_patch ]() );
332 return scoring::ScoreFunctionFactory::create_score_function(
343 using namespace conformation;
344 using namespace core;
345 using namespace core::scoring;
346 using namespace core::scoring::constraints;
348 using namespace scoring::constraints;
357 coordconstraint_segments = exclude_regions.
invert( nnonvrt_cst_target );
361 if ( nnonvrt_pose != nnonvrt_cst_target ) {
362 TR.Error <<
"ERROR coord constraint pose length mismatch with input pose: " << nnonvrt_cst_target <<
" vs. " << nnonvrt_pose << std::endl;
374 Real const coord_sdev( 0.5 );
375 for (
Size i = 1; i<= (
Size)nres; ++i ) {
377 if( coordconstraint_segments.is_loop_residue( i ) ) {
379 for (
Size ii = 1; ii<= nat_i_rsd.last_backbone_atom(); ++ii ) {
397 foreach(
std::string const residue_pair, loops_vec ){
399 if(residues.size() != 2 && residues.size() != 3){
400 utility_exit_with_message(
401 "To specify a loops string it must have the format "
402 "\"loop_start:loop_end:cut[,loop_start:loop_end:cut...]\". "
403 "If the cut is not set, then it is taken to be zero. "
404 "The residue numbering can use the pdb numbering.");
409 if( residues.size() == 3 )
411 runtime_assert( loop_start <= loop_stop );
412 runtime_assert( loop_start >= 1 );
414 loops_from_tag->add_loop( loop_start, loop_stop, loop_cut );
416 return( loops_from_tag );
423 using namespace core;
424 using namespace basic::options;
427 Size const max_loop_size( option[ OptionKeys::evaluation::score_sscore_maxloop ]() );
428 Size const max_short_helix( option[ OptionKeys::evaluation::score_sscore_short_helix ]() );
445 if ( lpos > max_loop_size ) {
446 unscored_loops.
add_loop( pos, pos+lpos-1 );
455 if ( hpos <= max_short_helix ) {
456 for (
Size ipos = 0; ipos < hpos; ++ipos ) {
457 short_helix[ pos+ipos] =
true;
468 Size npos( it->stop() + 1 );
469 while ( short_helix[ npos ] ) {
470 removed_short_helices.
add_loop( npos-1, npos );
480 char const extracted_ss_type) {
481 using namespace core;
483 Loops secondary_structure_chunks;
485 bool ss_chunk_started =
false;
486 Size chunk_start_seqpos(0);
487 Size chunk_end_seqpos(0);
490 if (!ss_chunk_started) {
491 if (pose.
secstruct(ires) == extracted_ss_type) {
492 ss_chunk_started =
true;
493 chunk_start_seqpos = ires;
497 if (pose.
secstruct(ires) != extracted_ss_type) {
498 ss_chunk_started =
false;
499 chunk_end_seqpos = ires - 1;
500 secondary_structure_chunks.add_loop( chunk_start_seqpos, chunk_end_seqpos);
503 ss_chunk_started =
false;
504 chunk_end_seqpos = ires - 1;
505 secondary_structure_chunks.add_loop( chunk_start_seqpos, chunk_end_seqpos);
511 if (ss_chunk_started) {
513 secondary_structure_chunks.add_loop( chunk_start_seqpos, chunk_end_seqpos);
515 return secondary_structure_chunks;
535 bool chunk_started =
false;
539 if (!chunk_started) {
541 chunk_started =
true;
545 chunk_started =
false;
559 Loops::LoopList::const_iterator eit, it;
560 for ( it = input_chunks.
begin(), eit = input_chunks.
end();
565 for (
core::Size ires = it->start(); ires < it->stop(); ++ires) {
566 if ( pose.
pdb_info()->number(ires+1) - pose.
pdb_info()->number(ires) != 1 ||
586 Loops continuous_chunks;
588 Loops::LoopList::const_iterator eit, it;
589 for ( it = input_chunks.
begin(), eit = input_chunks.
end();
594 for (
core::Size ires = it->start(); ires < it->stop(); ++ires) {
598 if ( pose.
residue(ires).
xyz(
"CA").distance(pose.
residue(ires+1).
xyz(
"CA")) > CA_CA_distance_cutoff ) {
600 continuous_chunks.
add_loop(new_loop);
608 continuous_chunks.
add_loop(new_loop);
614 continuous_chunks.
add_loop( new_loop );
616 return continuous_chunks;
623 Loops secondary_structure_chunks;
627 while (i_chunk <= input_chunks.
num_loop()) {
628 Loop new_loop(input_chunks[i_chunk]);
629 while(i_chunk < input_chunks.
num_loop()) {
630 const core::Size gap_length = input_chunks[i_chunk+1].start() - input_chunks[i_chunk].stop() - 1;
631 if (gap_length <= gap_size) {
639 secondary_structure_chunks.
add_loop(new_loop);
642 return secondary_structure_chunks;
647 Loops secondary_structure_chunks;
650 Loops::LoopList::const_iterator eit, it;
651 for ( it = input_chunks.
begin(), eit = input_chunks.
end();
653 if (it->size() >= minimum_length_of_chunk) {
654 secondary_structure_chunks.
add_loop(*it);
657 return secondary_structure_chunks;
668 Loops secondary_structure_chunks;
670 for (
core::Size i_ss = 0; i_ss < extracted_ss_types.size(); ++i_ss) {
671 char ss = extracted_ss_types[i_ss];
672 Loops secondary_structure_chunks_this_ss;
676 secondary_structure_chunks_this_ss =
remove_small_gaps(secondary_structure_chunks_this_ss, gap_size);
677 secondary_structure_chunks_this_ss =
split_by_resSeq(pose, secondary_structure_chunks_this_ss);
678 secondary_structure_chunks_this_ss =
split_by_ca_ca_dist(pose, secondary_structure_chunks_this_ss, CA_CA_distance_cutoff);
680 secondary_structure_chunks_this_ss =
remove_short_chunks(secondary_structure_chunks_this_ss, minimum_length_of_chunk_helix);
683 secondary_structure_chunks_this_ss =
remove_short_chunks(secondary_structure_chunks_this_ss, minimum_length_of_chunk_strand);
686 Loops::LoopList::const_iterator eit, it;
687 for ( it = secondary_structure_chunks_this_ss.
begin(), eit = secondary_structure_chunks_this_ss.
end();
689 secondary_structure_chunks.
add_loop(*it);
702 return secondary_structure_chunks;