20 #include <basic/Tracer.hh>
24 #include <utility/exit.hh>
28 #include <utility/vector1.hh>
29 #include <numeric/random/random.fwd.hh>
39 using namespace chemical;
45 static basic::Tracer
TR(
"protocols.loops.make_loops", t_info );
54 if ( seg_begin >= seg_end || pose.
chain( seg_begin ) != pose.
chain( seg_end ) ) {
55 TR(t_info) <<
"WARNING: skipping segment with illegal beginning/ending: ";
58 TR(t_info) << pdb.chain(seg_begin) <<
"." << pdb.number(seg_begin) <<
"."
60 << pdb.chain(seg_end) <<
"." << pdb.number(seg_end) <<
"."
63 TR(t_info) << pose.
chain(seg_begin) <<
"." << seg_begin <<
"."
65 << pose.
chain(seg_end) <<
"." << seg_end <<
"."
70 Size const length( seg_end - seg_begin );
72 Size cut(0), safety(0);
75 cut = seg_begin +
static_cast< Size >( numeric::random::uniform() * ( length ) );
82 TR(t_info) <<
"adding segment: " << pdb.number( seg_begin ) <<
"-(" << pdb.number( cut ) <<
")-"
83 << pdb.number( seg_end ) <<
" Chain " << pdb.chain( seg_end ) << std::endl;
85 TR(t_info) <<
"adding segment: " << seg_begin <<
"-(" << cut <<
")-" << seg_end <<
86 " Chain " << pose.
chain( seg_end ) << std::endl;
89 loops.
add_loop( seg_begin, seg_end, cut, 0,
false );
103 if ( residue_indices.empty() ) {
104 TR(t_info) <<
"WARNING: no residues provided--can not define any loops" << std::endl;
108 runtime_assert( loops.
num_loop() == 0 );
110 runtime_assert( extend >= 1 );
112 Size seg_begin( residue_indices.front() ), seg_end( residue_indices.front() );
113 int last_chain( pose.
chain( residue_indices.front() ) );
116 index != residue_indices.end(); ++index ) {
117 runtime_assert( *index > 0 );
118 runtime_assert( *index <= nres );
119 int const chain( pose.
chain(*index) );
120 Size const chain_begin( chain > 0 ? conf.chain_begin( chain ) : 1 ),
121 chain_end( chain > 0 ? conf.chain_end( chain ) : nres );
125 if ( begin == chain_begin )
break;
128 Size const end( std::min( chain_end, *index + extend ) );
129 TR(t_trace) << *index <<
" ch " << chain <<
" chbgn " << chain_begin <<
" chend " << chain_end <<
" bgn " << begin <<
" end " << end << std::endl;
131 if ( index == residue_indices.begin() ) {
134 }
else if ( begin > seg_end + gapsize || chain != last_chain ) {
136 add_loop( seg_begin, seg_end, pose, loops );
142 if ( index + 1 == residue_indices.end() )
add_loop( seg_begin, seg_end, pose, loops );