17 #include <boost/foreach.hpp>
20 #define foreach BOOST_FOREACH
22 #include <basic/Tracer.hh>
23 #include <utility/vector1.hh>
24 #include <utility/string_util.hh>
28 #include <utility/tag/Tag.hh>
36 #include <utility/vector0.hh>
37 #include <basic/options/keys/OptionKeys.hh>
41 namespace seeded_abinitio {
44 using namespace scoring::constraints;
45 using namespace protocols::moves;
47 static basic::Tracer
TR(
"protocols.seeded_abinitio.CAcstGenerator" );
63 return "CAcstGenerator";
90 for(
Size i = 1; i <= cut_points.size(); ++i ){
91 if ( cut_points[i] == residue)
113 using namespace scoring::constraints;
118 TR<<
"stddev for harmonic constraints: " << stddev <<std::endl;
120 if( cut_points.empty() )
121 TR<<
"there are no cut point registered" <<std::endl;
123 TR.Debug <<
"start_relevant_chain: " << start_relevant_chain << std::endl;
124 TR.Debug <<
"seeds: " << seeds << std::endl;
125 TR.Debug <<
"clear_area " << clear_area << std::endl;
127 for(
Size i=1;i<=cut_points.size(); i++) {
128 TR <<
"cutpoints: " << cut_points[i] << std::endl;
132 for(
Size i = 1 ; i <= cut_points.size(); ++i ){
133 TR.Debug <<
"rosetta numbering: cutpoint: "<< cut_points[i] <<std::endl;
134 cut_points[i] = cut_points[i] - (start_relevant_chain -1);
135 TR.Debug <<
"adjusted cutpoint: "<< cut_points[i] <<std::endl;
138 for(
Size i=1;i<=cut_points.size(); i++) {
139 TR <<
"cutpoints: " << cut_points[i] << std::endl;
143 for (
Size pos = 1; pos <= pose_of_int->total_residue(); pos++ ) {
144 for (
Size pos_2 = 1; pos_2 <=pose_of_int->total_residue(); pos_2++ ){
146 bool res_is_loop =
false;
147 bool res2_is_loop =
false;
149 if( !
is_part( seed_exceptions, pos) ){
154 if( !
is_part( seed_exceptions, pos_2 ) ){
158 bool cut_point_pos =
false;
159 bool cut_point_pos_2 =
false;
160 bool res_cst_free =
false;
165 res2_is_loop =
false;
169 if ( clear_area.
size() > 0 ){
176 if ( cut_points.size() > 1 ) {
177 cut_point_pos =
is_part(cut_points, pos );
178 cut_point_pos_2 =
is_part(cut_points, pos_2 );
185 seq_sep = pos - pos_2;
190 if ( seq_sep >= seq_separation ){
191 if ( !res_is_loop && !res2_is_loop ) {
192 if( !cut_point_pos && !cut_point_pos_2 ){
199 TR.Debug <<
"distance contraints for: " << pos_2 <<
" "<< pos <<
" "<<distance_ca <<std::endl;
200 TR.Debug <<
"updated: "<<pos_2 + start_relevant_chain -1 <<
" " << pos + start_relevant_chain - 1<<
" " <<distance_ca << std::endl;
202 if( distance_ca > distance_cutoff ){
220 using namespace core;
224 for(
Size i=1;i<=cutpoints.size(); i++) {
225 TR.Debug <<
"cutpoints: " << cutpoints[i] << std::endl;
228 TR.Debug <<
"foldtree: " << pose.
fold_tree();
231 Size start_recipient_chain;
235 if( from_chain_ == 0 ){
236 TR<<
"user did not specify for which chain constraints should be derrived, defaulting to all chains"<<std::endl;
237 if( template_presence_ ){
238 donor_poseOP = *template_pdb_ ;
239 TR<<
"derriving CA distance constraints from the template pdb, since a template was given"<<std::endl;
246 if( to_chain_ == 0 && template_presence_ ){
248 utility_exit_with_message(
"chain(s) to derrive constraints form and chain(s) to apply it to, do NOT have the same residue number. NOT supported." );
251 if( from_chain_ != 0 ){
252 if( template_presence_ ){
253 donor_poseOP =
new pose::Pose( template_pdb_->split_by_chain( from_chain_ ) );
254 TR<<
"derriving CA distance constraints from the template pdb"<<std::endl;
261 if( to_chain_ != 0 ){
263 TR<<
"adding constraints starting from index residue: " <<start_recipient_chain <<std::endl;
266 if( from_chain_ != 0 && to_chain_ != 0 ){
269 utility_exit_with_message(
"donor pose and recipient chain do not have the same residue numbers, check your template or input pdb");
273 add_dist_constraints( pose, donor_poseOP , start_recipient_chain , ca_cst_, all_seeds_ , clear_seeds_ , cutpoints, seed_exceptions_, add_cst_seed_ , stddev_, seq_separation_, distance_cutoff_);
276 TR<<
"replacing all constraints with newly generated constraint set" <<std::endl;
280 utility_exit_with_message(
"ADDing new constraints to pose, is currently not supported, try just replacing");
298 TR<<
"CAcstGenerator has been invoked"<<std::endl;
305 template_presence_ =
false;
307 stddev_ = tag->getOption<
core::Real>(
"stddev", 3.0);
309 TR<<
"setting constraint standard deviation to "<< stddev_<< std::endl;
311 if( tag->hasOption(
"template_pdb" ) ){
315 TR<<
"read in a template pdb with " <<template_pdb_->total_residue() <<
"residues"<<std::endl;
316 template_presence_ =
true;
319 add_cst_seed_ = tag->getOption<
bool >(
"add_cst_seed", 0 );
321 replace_ = tag->getOption<
bool >(
"replace", 1 );
323 seq_separation_ = tag->getOption<
core::Size >(
"seq_separation", 6 );
325 distance_cutoff_ = tag->getOption<
core::Real >(
"distance", 6.0 );
327 if( tag->hasOption(
"add_seed_residues" ) ){
331 Size const res( utility::string2int( key ) );
332 TR <<
"add constraints to residues within seed, residue: "<< key <<std::endl;
333 seed_exceptions_.push_back( res );
340 foreach(
TagPtr const btag, branch_tags ){
342 if( template_presence_ )
343 curr_pose_ = template_pdb_;
345 if( btag->getName() ==
"Seeds" ) {
352 TR.Debug <<
"parsing seeds: \n"<< begin <<
" and " << end <<std::endl;
353 TR.Debug <<
"seeds: "<< all_seeds_ <<std::endl;
355 all_seeds_.add_loop( begin , end , 0, 0,
false );
359 if( btag->getName() ==
"Clear_cst_segment" ) {
365 clear_seeds_.add_loop( begin , end , 0, 0,
false );
373 if( tag->hasOption(
"from_chain" ) ){
374 from_chain_ = tag->getOption<
core::Size >(
"from_chain", 1 );
375 TR<<
"chain to derrive constraints from: "<< from_chain_ <<std::endl;
378 if( tag->hasOption(
"to_chain" ) ){
379 to_chain_ = tag->getOption<
core::Size >(
"to_chain", 1 );
380 TR<<
"chain to apply constraints to: "<< to_chain_ <<std::endl;