Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HybridizeProtocol.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file
11 /// @author Yifan Song
12 
22 
25 
30 
32 #include <core/pose/selection.hh>
33 
35 #include <protocols/relax/util.hh>
36 
37 #include <protocols/loops/util.hh>
39 
41 
42 // dynamic fragpick
45 
48 
51 
52 #include <core/pose/Pose.hh>
53 #include <core/pose/util.hh>
54 #include <core/pose/PDBInfo.hh>
56 
60 
62 #include <core/fragment/FragSet.hh>
66 #include <core/fragment/Frame.hh>
68 #include <core/fragment/util.hh>
69 
70 #include <core/sequence/util.hh>
71 
74 
77 
83 
87 
89 
91 #include <basic/datacache/BasicDataCache.hh>
92 
93 // task operation
103 #include <core/pose/selection.hh>
104 
106 
107 // symmetry
113 
114 // utility
115 #include <utility/excn/Exceptions.hh>
116 #include <utility/io/izstream.hh>
117 #include <utility/tag/Tag.hh>
118 #include <utility/string_util.hh>
119 #include <basic/Tracer.hh>
120 #include <numeric/random/WeightedSampler.hh>
121 #include <ObjexxFCL/format.hh>
122 #include <boost/foreach.hpp>
123 
124 // evaluation
125 #include <core/scoring/rms_util.hh>
127 
128 // option
129 #include <basic/options/option.hh>
130 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
131 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
132 #include <basic/options/keys/cm.OptionKeys.gen.hh>
133 #include <basic/options/keys/in.OptionKeys.gen.hh>
134 #include <basic/options/keys/score.OptionKeys.gen.hh>
135 #include <basic/options/keys/relax.OptionKeys.gen.hh>
136 #include <basic/options/keys/jumps.OptionKeys.gen.hh> // strand pairings
137 #include <basic/options/keys/evaluation.OptionKeys.gen.hh>
138 
139 #include <string>
140 
141 #define foreach BOOST_FOREACH
142 
143 static basic::Tracer TR( "protocols.hybridization.HybridizeProtocol" );
144 static numeric::random::RandomGenerator RG(541938);
145 
146 namespace protocols {
147 namespace hybridization {
148 
149 //
150 using namespace core;
151 using namespace kinematics;
152 using namespace sequence;
153 using namespace pack;
154 using namespace task;
155 using namespace operation;
156 using namespace scoring;
157 using namespace constraints;
158 
159 
160 /////////////
161 // creator
165 }
166 
169  return new HybridizeProtocol;
170 }
171 
174  return "Hybridize";
175 }
176 
177 
178 
179 /////////////
180 // mover
182  template_weights_sum_(0)
183 {
184  using namespace basic::options;
185  using namespace basic::options::OptionKeys;
186 
187  init();
188 
189  // initialization may come from command line or from RS
190  if (option[cm::hybridize::template_list].user()) {
191  read_template_structures( option[cm::hybridize::template_list]() );
192  }
193 }
194 
195 /*
196 HybridizeProtocol::HybridizeProtocol(std::string template_list_file) :
197  template_weights_sum_(0),
198 {
199  init();
200  read_template_structures(template_list_file);
201 }
202 */
203 // sets default options
204 void
206  using namespace basic::options;
207  using namespace basic::options::OptionKeys;
208 
209  stage1_probability_ = option[cm::hybridize::stage1_probability]();
210  stage1_increase_cycles_ = option[cm::hybridize::stage1_increase_cycles]();
211  stage1_1_cycles_ = option[cm::hybridize::stage1_1_cycles]();
212  stage1_2_cycles_ = option[cm::hybridize::stage1_2_cycles]();
213  stage1_3_cycles_ = option[cm::hybridize::stage1_3_cycles]();
214  stage1_4_cycles_ = option[cm::hybridize::stage1_4_cycles]();
215  domain_assembly_ = false;
216  add_hetatm_ = false;
217  realign_domains_ = option[cm::hybridize::realign_domains]();
218  realign_domains_stage2_ = option[cm::hybridize::realign_domains_stage2]();
219  add_non_init_chunks_ = option[cm::hybridize::add_non_init_chunks]();
220  frag_weight_aligned_ = option[cm::hybridize::frag_weight_aligned]();
221  auto_frag_insertion_weight_ = option[cm::hybridize::auto_frag_insertion_weight]();
222  max_registry_shift_ = option[cm::hybridize::max_registry_shift]();
223  frag_1mer_insertion_weight_ = option[cm::hybridize::frag_1mer_insertion_weight]();
224  small_frag_insertion_weight_ = option[cm::hybridize::small_frag_insertion_weight]();
225  big_frag_insertion_weight_ = option[cm::hybridize::big_frag_insertion_weight]();
226  hetatm_cst_weight_ = 10.;
227  cartfrag_overlap_ = 1;
228 
229  if (option[cm::hybridize::starting_template].user()) {
230  starting_templates_ = option[cm::hybridize::starting_template]();
231  }
232 
233  stage2_increase_cycles_ = option[cm::hybridize::stage2_increase_cycles]();
234  no_global_frame_ = option[cm::hybridize::no_global_frame]();
235  linmin_only_ = option[cm::hybridize::linmin_only]();
236 
237  // default scorefunction
239  option[cm::hybridize::stage1_weights](), option[cm::hybridize::stage1_patch]() );
241  option[cm::hybridize::stage2_weights](), option[cm::hybridize::stage2_patch]() );
242 
245 
246  if ( option[ OptionKeys::constraints::cst_fa_file ].user() ) {
247  utility::vector1< std::string > cst_files = option[ OptionKeys::constraints::cst_fa_file ]();
248  core::Size choice = core::Size( RG.random_range( 1, cst_files.size() ) );
249  fa_cst_fn_ = cst_files[choice];
250  TR.Info << "Fullatom Constraint choice: " << fa_cst_fn_ << std::endl;
251  }
252 
253  batch_relax_ = option[ cm::hybridize::relax ]();
254  relax_repeats_ = option[ basic::options::OptionKeys::relax::default_repeats ]();
255 
256  // disulfide file
257  if (option[ in::fix_disulf ].user()) {
258  disulf_file_ = option[ in::fix_disulf ]();
259  }
260 
261  // read fragments
262  if ( option[ in::file::frag9 ].user() ) {
263  using namespace core::fragment;
264  FragSetOP frags = FragmentIO().read_data( option[ in::file::frag9 ]() );
265  fragments_big_.push_back(frags);
266  }
267  if ( option[ in::file::frag3 ].user() ) {
268  using namespace core::fragment;
269  FragSetOP frags = FragmentIO().read_data( option[ in::file::frag3 ]() );
270  fragments_small_.push_back(frags);
271  }
272 
273  // native
274  if ( option[ in::file::native ].user() ) {
276  core::import_pose::pose_from_pdb( *native_, option[ in::file::native ]() );
277  } else if ( option[ evaluation::align_rmsd_target ].user() ) {
279  utility::vector1< std::string > const & align_rmsd_target( option[ evaluation::align_rmsd_target ]() );
280  core::import_pose::pose_from_pdb( *native_, align_rmsd_target[1] ); // just use the first one for now
281  }
282 
283  // strand pairings
284  pairings_file_ = option[jumps::pairing_file]();
285  if ( option[jumps::sheets].user() ) {
286  sheets_ = option[jumps::sheets]();
287  } else {
288  random_sheets_ = option[jumps::random_sheets]();
289  }
290  filter_templates_ = option[jumps::filter_templates]();
291 }
292 
293 void
295  if (fragments_big_.size() > 0 && fragments_small_.size() > 0) return;
296 
297  if (!fragments_big_.size()) {
299 
300  // number of residues
301  core::Size nres_tgt = pose.total_residue();
305  dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
306  symm_info = SymmConf.Symmetry_Info();
307  nres_tgt = symm_info->num_independent_residues();
308  }
309  if (pose.residue(nres_tgt).aa() == core::chemical::aa_vrt) nres_tgt--;
310  while (!pose.residue(nres_tgt).is_protein()) nres_tgt--;
311 
312  // sequence
313  std::string tgt_seq = pose.sequence();
314  std::string tgt_ss(nres_tgt, '0');
315 
316  using namespace basic::options;
317  using namespace basic::options::OptionKeys;
318  if (option[ OptionKeys::in::file::psipred_ss2 ].user()) {
320  for ( core::Size j=1; j<=nres_tgt; ++j ) {
321  tgt_ss[j-1] = psipred[j];
322  }
323  }
324  else {
325  // templates vote on secstruct
326  for (core::Size i=1; i<=templates_.size(); ++i) {
327  for (core::Size j=1; j<=templates_[i]->total_residue(); ++j ) {
328  if (!templates_[i]->residue(j).is_protein()) continue;
329  core::Size tgt_pos = templates_[i]->pdb_info()->number(j);
330 
331  runtime_assert( tgt_pos<=nres_tgt );
332  char tgt_ss_j = templates_[i]->secstruct(j);
333 
334  if (tgt_ss[tgt_pos-1] == '0') {
335  tgt_ss[tgt_pos-1] = tgt_ss_j;
336  } else if (tgt_ss[tgt_pos-1] != tgt_ss_j) {
337  tgt_ss[tgt_pos-1] = 'D'; // templates disagree
338  }
339  }
340  }
341  for ( core::Size j=1; j<=nres_tgt; ++j ) {
342  if (tgt_ss[j-1] == '0') tgt_ss[j-1] = 'D';
343  }
344  }
345 
346  // pick from vall based on template SS + target sequence
347  for ( core::Size j=1; j<=nres_tgt-8; ++j ) {
349  frame->add_fragment(
350  core::fragment::picking_old::vall::pick_fragments_by_ss_plus_aa( tgt_ss.substr( j-1, 9 ), tgt_seq.substr( j-1, 9 ), 25, true, core::fragment::IndependentBBTorsionSRFD() ) );
351  frags->add( frame );
352  }
353  fragments_big_.push_back( frags );
354  }
355  if (!fragments_small_.size()) {
357 
358  // make them from big fragments
360  fragments_small_.push_back( frags );
361  }
362 }
363 
364 
365 void
367  core::pose::Pose &pose,
368  core::pose::PoseOP chosen_templ,
369  protocols::loops::Loops template_contigs_icluster,
371 {
372  using namespace basic::options;
373  using namespace basic::options::OptionKeys;
374 
375  // xyz copy starting model
376  for (Size i=1; i<=chosen_templ->total_residue(); ++i)
377  for (Size j=1; j<=chosen_templ->residue(i).natoms(); ++j) {
378  core::id::AtomID src(j,i), tgt(j, chosen_templ->pdb_info()->number(i));
379  pose.set_xyz( tgt, chosen_templ->xyz( src ) );
380  }
381 
382  // make loops as inverse of template_contigs_icluster
383  TR << "CONTIGS" << std::endl << template_contigs_icluster << std::endl;
384  //core::Size ncontigs = template_contigs_icluster.size();
385  core::Size nres_tgt = pose.total_residue();
386 
387  //symmetry
391  dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
392  symm_info = SymmConf.Symmetry_Info();
393  nres_tgt = symm_info->num_independent_residues();
394  }
395 
396  if (pose.residue(nres_tgt).aa() == core::chemical::aa_vrt) nres_tgt--;
397 
399  utility::vector1< bool > templ_coverage(nres_tgt, false);
400 
401  for (Size i=1; i<=chosen_templ->total_residue(); ++i) {
402  core::Size cres = chosen_templ->pdb_info()->number(i);
403  templ_coverage[cres] = true;
404  }
405 
406  // remove 1-3 residue "segments"
407  for (Size i=1; i<=nres_tgt-2; ++i) {
408  if (!templ_coverage[i] && templ_coverage[i+1] && !templ_coverage[i+2]) {
409  templ_coverage[i+1]=false;
410  } else if(i<=nres_tgt-3 && !templ_coverage[i] && templ_coverage[i+1] && templ_coverage[i+2] && !templ_coverage[i+3]) {
411  templ_coverage[i+1]=false;
412  templ_coverage[i+2]=false;
413  } else if(i<=nres_tgt-4 &&
414  !templ_coverage[i] && templ_coverage[i+1] && templ_coverage[i+2] && templ_coverage[i+3] && !templ_coverage[i+4]) {
415  templ_coverage[i+1]=false;
416  templ_coverage[i+2]=false;
417  templ_coverage[i+3]=false;
418  }
419  }
420  // make loopfile
421  bool inloop=!templ_coverage[1];
422  core::Size loopstart=1, loopstop;
423  for (Size i=2; i<=nres_tgt; ++i) {
424  if (templ_coverage[i] && inloop) {
425  // end loop
426  inloop = false;
427  loopstop = i;
428  if (loopstop < loopstart + 2) {
429  if (loopstart>1) loopstart--;
430  if (loopstop<nres_tgt) loopstop++;
431  }
432  loops->add_loop( loopstart,loopstop );
433  } else if (!templ_coverage[i] && !inloop) {
434  // start loop
435  inloop = true;
436  loopstart = i-1;
437  }
438  }
439  if (inloop) {
440  // end loop
441  loopstop = nres_tgt;
442  while (loopstop < loopstart + 2) { loopstart--; }
443  loops->add_loop( loopstart,loopstop );
444  }
445  TR << "LOOPS" << std::endl << *loops << std::endl;
446 
447  // now do insertions
448  if (loops->size() != 0) {
449  // set foldtree + variants
450  loops->auto_choose_cutpoints(pose);
451  core::kinematics::FoldTree f_in=pose.fold_tree(), f_new;
452  protocols::loops::fold_tree_from_loops( pose, *loops, f_new);
453  pose.fold_tree( f_new );
455 
456  // set movemap
458  for( protocols::loops::Loops::const_iterator it=loops->begin(), it_end=loops->end(); it!=it_end; ++it ) {
459  for( Size i=it->start(); i<=it->stop(); ++i ) {
460  mm_loop->set_bb(i, true);
461  mm_loop->set_chi(i, true); // chi of loop residues
462  }
463  }
464 
465  // setup fragment movers
467  core::fragment::FragSetOP frags_small = fragments_small_[RG.random_range(1,fragments_small_.size())];
468  core::fragment::FragSetOP frags_big = fragments_big_[RG.random_range(1,fragments_big_.size())];
469  TR.Info << "FRAGMENTS small max length: " << frags_small->max_frag_length() << std::endl;
470  TR.Info << "FRAGMENTS big max length: " << frags_big->max_frag_length() << std::endl;
471  frag3mover = new protocols::simple_moves::ClassicFragmentMover( frags_small, mm_loop );
472  frag3mover->set_check_ss( false ); frag3mover->enable_end_bias_check( false );
473  frag9mover = new protocols::simple_moves::ClassicFragmentMover( frags_big, mm_loop );
474  frag9mover->set_check_ss( false ); frag9mover->enable_end_bias_check( false );
475 
476  // extend + idealize loops
477  for( protocols::loops::Loops::const_iterator it=loops->begin(), it_end=loops->end(); it!=it_end; ++it ) {
478  protocols::loops::Loop to_idealize( *it );
480  }
481 
482  // setup MC
483  scorefxn->set_weight( core::scoring::linear_chainbreak, 0.5 );
484  (*scorefxn)(pose);
485  protocols::moves::MonteCarloOP mc1 = new protocols::moves::MonteCarlo( pose, *scorefxn, 2.0 );
486 
487  core::Size neffcycles = (core::Size)(1000*option[cm::hybridize::stage1_increase_cycles]());
488  for (Size n=1; n<=neffcycles; ++n) {
489  frag9mover->apply( pose ); (*scorefxn)(pose); mc1->boltzmann( pose , "frag9" );
490  frag3mover->apply( pose ); (*scorefxn)(pose); mc1->boltzmann( pose , "frag3" );
491 
492  if (n%100 == 0) {
493  mc1->show_scores();
494  mc1->show_counters();
495  }
496  }
497  mc1->recover_low( pose );
498 
499  scorefxn->set_weight( core::scoring::linear_chainbreak, 2.0 );
500  (*scorefxn)(pose);
501  protocols::moves::MonteCarloOP mc2 = new protocols::moves::MonteCarlo( pose, *scorefxn, 2.0 );
502  for (Size n=1; n<=neffcycles; ++n) {
503  frag9mover->apply( pose ); (*scorefxn)(pose); mc2->boltzmann( pose , "frag9" );
504  frag3mover->apply( pose ); (*scorefxn)(pose); mc2->boltzmann( pose , "frag3" );
505 
506  if (n%100 == 0) {
507  mc2->show_scores();
508  mc2->show_counters();
509  }
510  }
511 
512  // restore input ft
513  mc2->recover_low( pose );
515  pose.fold_tree( f_in );
516  }
517 }
518 
519 
520 
522  std::string template_fn,
523  std::string cst_fn,
524  std::string symm_file,
525  core::Real weight,
526  core::Real domain_assembly_weight,
527  core::Size cluster_id,
529 {
531  core::pose::PoseOP template_pose = new core::pose::Pose();
532  core::import_pose::pose_from_pdb( *template_pose, *residue_set, template_fn );
533 
534  // add secondary structure information to the template pose
535  core::scoring::dssp::Dssp dssp_obj( *template_pose );
536  dssp_obj.insert_ss_into_pose( *template_pose );
537 
538  // find ss chunks in template
539  //protocols::loops::Loops chunks = protocols::loops::extract_secondary_structure_chunks(*template_pose);
541  protocols::loops::Loops chunks = protocols::loops::extract_secondary_structure_chunks(*template_pose, "HE", 3, 6, 3, 4);
542 
543  if (chunks.num_loop() == 0)
544  chunks = contigs;
545 
546  TR.Debug << "Chunks from template\n" << chunks << std::endl;
547  TR.Debug << "Contigs from template\n" << contigs << std::endl;
548 
549  template_fn_.push_back(template_fn);
550  templates_.push_back(template_pose);
551  template_cst_fn_.push_back(cst_fn);
552  symmdef_files_.push_back(symm_file);
553  template_weights_.push_back(weight);
554  domain_assembly_weights_.push_back(domain_assembly_weight);
555  template_clusterID_.push_back(cluster_id);
556  template_chunks_.push_back(chunks);
557  template_contigs_.push_back(contigs);
558  template_cst_reses_.push_back(cst_reses);
559 }
560 
561 
562 ///@brief Old way of parsing hybrid config files; RosettaScripts is now preferred.
564 {
565  utility::io::izstream f_stream( template_list );
566  std::string line;
567  while (!f_stream.eof()) {
568  getline(f_stream, line);
569 
570  if (line.size() == 0) continue;
571 
572  std::istringstream str_stream(line);
573  std::string template_fn;
574  std::string cst_fn;
575  core::Size cluster_id(0);
576  core::Real weight(1.);
577  core::Real domain_assembly_weight(0.);
578  if (!str_stream.eof()) {
579  str_stream >> template_fn;
580  if (template_fn.empty()) continue;
581  if (template_fn[0] == '#') continue;
582 
583  if (!str_stream.eof()) str_stream >> cst_fn;
584  if (!str_stream.eof()) str_stream >> cluster_id;
585  if (!str_stream.eof()) str_stream >> weight;
586 
587  TR << template_fn << " " << cst_fn << " " << cluster_id << " " << weight << std::endl;
588 
589  std::string cst_reses_str;
591  if ( str_stream >> cst_reses_str ) {
592  utility::vector1<std::string> cst_reses_parsed = utility::string_split( cst_reses_str , ',' ) ;
593  for (Size i=1; i<= cst_reses_parsed.size(); ++i ) {
594  cst_reses.push_back( (core::Size) std::atoi( cst_reses_parsed[i].c_str() ) );
595  }
596  }
597  add_template(template_fn, cst_fn, "", weight,domain_assembly_weight, cluster_id, cst_reses);
598  }
599  }
600  f_stream.close();
601 }
602 
604 {
605  templates_.clear();
606  templates_.resize(template_filenames.size());
607 
608  //core::chemical::ResidueTypeSetCAP residue_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( "centroid" );
609 
610  //fpd remember sidechains from input structure
612 
613  for (core::Size i_ref=1; i_ref<= template_filenames.size(); ++i_ref) {
614  templates_[i_ref] = new core::pose::Pose();
615  core::import_pose::pose_from_pdb( *(templates_[i_ref]), *residue_set, template_filenames[i_ref].name() );
616  core::scoring::dssp::Dssp dssp_obj( *templates_[i_ref] );
617  dssp_obj.insert_ss_into_pose( *templates_[i_ref] );
618  }
619 }
620 
622  core::Size & initial_template_index_icluster,
623  utility::vector1 < core::Size > & template_index_icluster,
624  utility::vector1 < core::pose::PoseOP > & templates_icluster,
625  utility::vector1 < core::Real > & weights_icluster,
626  utility::vector1 < protocols::loops::Loops > & template_chunks_icluster,
627  utility::vector1 < protocols::loops::Loops > & template_contigs_icluster )
628 {
629  using namespace basic::options;
630  using namespace basic::options::OptionKeys;
631 
632  template_index_icluster.clear();
633  templates_icluster.clear();
634  weights_icluster.clear();
635  template_chunks_icluster.clear();
636  template_contigs_icluster.clear();
637 
638  if (starting_templates_.size() > 0) {
639  numeric::random::WeightedSampler weighted_sampler;
640  for (Size i=1; i<=starting_templates_.size(); ++i) {
641  weighted_sampler.add_weight(template_weights_[starting_templates_[i]]);
642  }
643  Size k = weighted_sampler.random_sample(RG);
644  initial_template_index = starting_templates_[k];
645  }
646  else {
647  numeric::random::WeightedSampler weighted_sampler;
648  weighted_sampler.weights(template_weights_);
649  initial_template_index = weighted_sampler.random_sample(RG);
650  }
651  Size cluster_id = template_clusterID_[initial_template_index];
652 
653  for (Size i_template = 1; i_template <= template_clusterID_.size(); ++i_template) {
654  if ( cluster_id == template_clusterID_[i_template] ) {
655  // add templates from the same cluster
656  template_index_icluster.push_back(i_template);
657  templates_icluster.push_back(templates_[i_template]);
658  weights_icluster.push_back(template_weights_[i_template]);
659  template_chunks_icluster.push_back(template_chunks_[i_template]);
660  template_contigs_icluster.push_back(template_contigs_[i_template]);
661 
662  if (i_template == initial_template_index) {
663  initial_template_index_icluster = template_index_icluster.size();
664  }
665  }
666  }
667 }
668 
670 {
671  using namespace protocols::moves;
672  using namespace basic::options;
673  using namespace basic::options::OptionKeys;
674  using namespace core::pose::datacache;
675  using namespace core::io::silent;
676  using namespace ObjexxFCL::fmt;
677 
678  // make fragments if we don't have them at this point
680  // select random fragments if given variable lengths
681  core::fragment::FragSetOP frags_small = fragments_small_[RG.random_range(1,fragments_small_.size())];
682  core::fragment::FragSetOP frags_big = fragments_big_[RG.random_range(1,fragments_big_.size())];
683  TR.Info << "FRAGMENTS small max length: " << frags_small->max_frag_length() << std::endl;
684  TR.Info << "FRAGMENTS big max length: " << frags_big->max_frag_length() << std::endl;
685 
686  // starting structure pool
687  std::vector < SilentStructOP > post_centroid_structs;
688  bool need_more_samples = true;
689 
690  // number of residues in asu without VRTs
691  core::Size nres_tgt = pose.total_residue();
692  core::Size nres_protein_tgt = pose.total_residue();
696  dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
697  symm_info = SymmConf.Symmetry_Info();
698  nres_tgt = symm_info->num_independent_residues();
699  }
700  if (pose.residue(nres_tgt).aa() == core::chemical::aa_vrt) nres_tgt--;
701  while (!pose.residue(nres_protein_tgt).is_protein()) nres_protein_tgt--;
702 
703  core::Real gdtmm = 0.0;
705  while(need_more_samples) {
706  need_more_samples = false;
707 
708  // pick starting template
709  core::Size initial_template_index;
710  core::Size initial_template_index_icluster; // index in the cluster
711  utility::vector1 < core::Size > template_index_icluster; // index look back
712  utility::vector1 < core::pose::PoseOP > templates_icluster;
713  utility::vector1 < core::Real > weights_icluster;
714  utility::vector1 < protocols::loops::Loops > template_chunks_icluster;
715  utility::vector1 < protocols::loops::Loops > template_contigs_icluster;
717  initial_template_index, initial_template_index_icluster,
718  template_index_icluster, templates_icluster, weights_icluster,
719  template_chunks_icluster, template_contigs_icluster );
720  TR << "Using initial template: " << I(4,initial_template_index) << " " << template_fn_[initial_template_index] << std::endl;
721 
722  // Three options to rearrange the input alignments, adding hetero residues, domain assembly, or realign local domains. Currently they are mutually exclusive.
723  if (add_hetatm_) {
724  for ( Size ires=1; ires <= templates_[initial_template_index]->total_residue(); ++ires ) {
725  if (templates_[initial_template_index]->pdb_info()->number(ires) > (int)nres_tgt) {
726  if ( templates_[initial_template_index]->residue(ires).is_polymer() && !templates_[initial_template_index]->residue(ires).is_lower_terminus() ) {
727  pose.append_residue_by_bond(templates_[initial_template_index]->residue(ires));
728  }
729  else {
730  pose.append_residue_by_jump(templates_[initial_template_index]->residue(ires), 1);
731  }
732  }
733  }
734  }
735  else if (domain_assembly_) {
737  domain_assembly.run();
738  /*
739  for (Size i_pose=1; i_pose <= templates_.size(); ++i_pose) {
740  std::string out_fn = template_fn_[i_pose] + "_assembly.pdb";
741  templates_[i_pose]->dump_pdb(out_fn);
742  }
743  */
744  }
745  // realign each template to the starting template by domain
746  // does not to domain realignment if in domain assembly mode
748  // domain parsing
751  domains_all_templ.resize( templates_.size() );
752  for (Size i_template=1; i_template<=templates_.size(); ++i_template) {
753  if (template_clusterID_[i_template] != template_clusterID_[initial_template_index]) continue;
754  domains_all_templ[i_template] = ddom.split( *templates_[i_template], nres_protein_tgt );
755 
756  //protocols::loops::Loops my_chunks(template_chunks_[initial_template_index_]);
757  // convert domain numbering to target pose numbering
758  for (Size iloops=1; iloops<=domains_all_templ[i_template].size(); ++iloops) {
759  for (Size iloop=1; iloop<=domains_all_templ[i_template][iloops].num_loop(); ++iloop) {
760  Size seqpos_start_pose = templates_[i_template]->pdb_info()->number(domains_all_templ[i_template][iloops][iloop].start());
761  domains_all_templ[i_template][iloops][iloop].set_start( seqpos_start_pose );
762 
763  Size seqpos_stop_pose = templates_[i_template]->pdb_info()->number(domains_all_templ[i_template][iloops][iloop].stop());
764  domains_all_templ[i_template][iloops][iloop].set_stop( seqpos_stop_pose );
765  }
766  }
767 
768  TR << "Found " << domains_all_templ[i_template].size() << " domains for template " << template_fn_[i_template] << std::endl;
769  for (Size i=1; i<=domains_all_templ[i_template].size(); ++i) {
770  TR << "domain " << i << ": " << domains_all_templ[i_template][i] << std::endl;
771  }
772  }
773 
774  // combine domains that are not in the initial template
775  domains_ = expand_domains_to_full_length(domains_all_templ, initial_template_index, nres_tgt);
776  TR << "Final decision: " << domains_.size() << " domains" << std::endl;
777  for (Size i=1; i<= domains_.size(); ++i) {
778  TR << "domain " << i << ": " << domains_[i] << std::endl;
779  }
780 
781  // local align
782  align_by_domain(templates_, domains_, templates_[initial_template_index]);
783 
784  // update chunk, contig informations
785  for (Size i_template=1; i_template<=templates_.size(); ++i_template) {
786  // default minimum length is 3 and CA distance is 4
787  template_contigs_[i_template] = protocols::loops::extract_continuous_chunks(*templates_[i_template]); // for chunk insertions
788  template_chunks_[i_template] = protocols::loops::extract_secondary_structure_chunks(*templates_[i_template], "HE", 3, 6, 3, 4); // for fold tree setup
789  if (template_chunks_[i_template].num_loop() == 0)
790  template_chunks_[i_template] = template_contigs_[i_template];
791  }
792  }
793 
794  // symmetrize
795  std::string symmdef_file = symmdef_files_[initial_template_index];
796  if (!symmdef_file.empty() && symmdef_file != "NULL") {
798  makeSymm.apply(pose);
799  //fpd to get the right rotamer set we need to do this
800  basic::options::option[basic::options::OptionKeys::symmetry::symmetry_definition].value( "dummy" );
801  }
802 
803  // set pose for density scoring if a map was input
804  //keep this after symmetry
805  if ( option[ OptionKeys::edensity::mapfile ].user() ) {
807  dens->apply( pose );
808  }
809 
810 
811  // initialize template history
812  //fpd this must be done after symmetrization!
813  TemplateHistoryOP history = new TemplateHistory(pose);
814  history->setall( initial_template_index_icluster );
815  pose.data().set( CacheableDataType::TEMPLATE_HYBRIDIZATION_HISTORY, history );
816 
817 
818  // STAGE 1
819 
820 
821  //fpd constraints are handled a little bit weird
822  // * foldtree hybridize sets chainbreak variants then applies constraints (so c-beta csts are treated properly)
823  // * after chainbreak variants are removed, csts are removed and reapplied in this function
824  // * finally after switch to fullatom CSTs are reapplied again (optionally using a different CST file)
825  // If "AUTO" is specified for cen_csts automatic centroid csts are generated
826  // If "AUTO" is specified for fa_csts automatic fa csts are generated
827  // If "NONE" is specified for fa_csts, cen csts are used (AUTO or otherwise)
828  // An empty string is treated as equivalent to "NONE"
829 
830  // fold tree hybridize
831  if (RG.uniform() < stage1_probability_) {
832  std::string cst_fn = template_cst_fn_[initial_template_index];
833 
834  FoldTreeHybridizeOP ft_hybridize(
835  new FoldTreeHybridize(
836  initial_template_index_icluster, templates_icluster, weights_icluster,
837  template_chunks_icluster, template_contigs_icluster, frags_small, frags_big) ) ;
838  ft_hybridize->set_constraint_file( cst_fn );
839  ft_hybridize->set_scorefunction( stage1_scorefxn_ );
840  ft_hybridize->set_increase_cycles( stage1_increase_cycles_ );
841  ft_hybridize->set_stage1_1_cycles( stage1_1_cycles_ );
842  ft_hybridize->set_stage1_2_cycles( stage1_2_cycles_ );
843  ft_hybridize->set_stage1_3_cycles( stage1_3_cycles_ );
844  ft_hybridize->set_stage1_4_cycles( stage1_4_cycles_ );
845  ft_hybridize->set_add_non_init_chunks( add_non_init_chunks_ );
846  ft_hybridize->set_domain_assembly( domain_assembly_ );
847  ft_hybridize->set_add_hetatm( add_hetatm_, hetatm_cst_weight_ );
848  ft_hybridize->set_frag_1mer_insertion_weight( frag_1mer_insertion_weight_ );
849  ft_hybridize->set_small_frag_insertion_weight( small_frag_insertion_weight_ );
850  ft_hybridize->set_big_frag_insertion_weight( big_frag_insertion_weight_ );
851  ft_hybridize->set_frag_weight_aligned( frag_weight_aligned_ );
852  ft_hybridize->set_auto_frag_insertion_weight( auto_frag_insertion_weight_ );
853  ft_hybridize->set_max_registry_shift( max_registry_shift_ );
854 
855  // strand pairings
856  ft_hybridize->set_pairings_file( pairings_file_ );
857  ft_hybridize->set_sheets( sheets_ );
858  ft_hybridize->set_random_sheets( random_sheets_ );
859  ft_hybridize->set_filter_templates( filter_templates_ );
860 
861  ft_hybridize->apply(pose);
862 
863  // get strand pairings if they exist for constraints in later stages
864  strand_pairs_ = ft_hybridize->get_strand_pairs();
865 
866  } else {
867  // just do frag insertion in unaligned regions
868  core::pose::PoseOP chosen_templ = templates_icluster[initial_template_index_icluster];
869  protocols::loops::Loops chosen_contigs = template_contigs_icluster[initial_template_index_icluster];
870  initialize_and_sample_loops(pose, chosen_templ, chosen_contigs, stage1_scorefxn_);
871  }
872 
873  //write gdtmm to output
874  if (native_ && native_->total_residue()) {
875  gdtmm = get_gdtmm(*native_, pose, native_aln);
876  core::pose::setPoseExtraScores( pose, "GDTMM_after_stage1", gdtmm);
877  TR << "GDTMM_after_stage1" << F(8,3,gdtmm) << std::endl;
878  }
879 
881  // realign domains to the output of stage 1
882  TR << "Realigning template domains to stage1 pose." << std::endl;
883  core::pose::PoseOP stage1pose = new core::pose::Pose( pose );
884  align_by_domain(templates_, domains_, stage1pose);
885  }
886 
887  // apply constraints
888  std::string cst_fn = template_cst_fn_[initial_template_index];
890  if (add_hetatm_) {
892  }
893  if (strand_pairs_.size()) {
895  }
896 
897  // STAGE 2
898  if (!option[cm::hybridize::skip_stage2]()) {
899  CartesianHybridizeOP cart_hybridize (
900  new CartesianHybridize(
901  templates_icluster, weights_icluster,
902  template_chunks_icluster,template_contigs_icluster, frags_big ) );
903  cart_hybridize->set_scorefunction( stage2_scorefxn_);
904  cart_hybridize->set_increase_cycles( stage2_increase_cycles_ );
905  cart_hybridize->set_no_global_frame( no_global_frame_ );
906  cart_hybridize->set_linmin_only( linmin_only_ );
907  cart_hybridize->set_cartfrag_overlap( cartfrag_overlap_ );
908  bool linbonded_old = option[ score::linear_bonded_potential ]();
909  option[ score::linear_bonded_potential ].value( true ); //fpd hack
910  cart_hybridize->apply(pose);
911  option[ score::linear_bonded_potential ].value( linbonded_old ); //fpd hack
912  }
913 
914  //write gdtmm to output
915  if (native_ && native_->total_residue()) {
916  gdtmm = get_gdtmm(*native_, pose, native_aln);
917  core::pose::setPoseExtraScores( pose, "GDTMM_after_stage2", gdtmm);
918  TR << "GDTMM_after_stage2" << ObjexxFCL::fmt::F(8,3,gdtmm) << std::endl;
919  }
920  // get fragment history
921  runtime_assert( pose.data().has( CacheableDataType::TEMPLATE_HYBRIDIZATION_HISTORY ) );
922  history = *( static_cast< TemplateHistory* >( pose.data().get_ptr( CacheableDataType::TEMPLATE_HYBRIDIZATION_HISTORY )() ));
923 
924  TR << "History :";
925  for (Size i=1; i<= history->size(); ++i ) { TR << I(4,i); }
926  TR << std::endl;
927  TR << "History :";
928  for (Size i=1; i<= history->size(); ++i ) { TR << I(4, history->get(i)); }
929  TR << std::endl;
930 
931  // stage "2.5" .. minimize with centroid energy + full-strength cart bonded
932  if (!option[cm::hybridize::skip_stage2]()) {
933  core::optimization::MinimizerOptions options_lbfgs( "lbfgs_armijo_nonmonotone", 0.01, true, false, false );
935  core::scoring::ScoreFunctionOP stage2_scorefxn_copy = stage2_scorefxn_->clone();
936  core::Real fa_cart_bonded_wt = fa_scorefxn_->get_weight(core::scoring::cart_bonded);
937  if (fa_cart_bonded_wt == 0) fa_cart_bonded_wt = 0.5;
938  stage2_scorefxn_copy->set_weight( core::scoring::cart_bonded, fa_cart_bonded_wt );
940  mm.set_bb( true ); mm.set_chi( true ); mm.set_jump( true );
943  options_lbfgs.max_iter(200);
944  (*stage2_scorefxn_copy)(pose); minimizer.run( pose, mm, *stage2_scorefxn_copy, options_lbfgs );
945  }
946 
947 
948  // STAGE RELAX
949 
950 
951  // optional relax
952  if (batch_relax_ > 0) {
954  tofa->apply(pose);
955 
956  // disulfide
957  if (disulf_file_.length() > 0) {
958  basic::options::option[ basic::options::OptionKeys::in::fix_disulf ].value(disulf_file_);
960  // must to this to avoid possible errors since initialize_disulfide_bonds is used in pose io.
961  basic::options::option[ basic::options::OptionKeys::in::fix_disulf ].deactivate();
962  basic::options::option[ basic::options::OptionKeys::in::fix_disulf ].to_default(); // reset to the default value
963  }
964 
965  // apply fa constraints
966  std::string cst_fn = template_cst_fn_[initial_template_index];
968  if (add_hetatm_) {
970  }
971  if (strand_pairs_.size()) {
973  }
974 
975  if (batch_relax_ == 1) {
976  // add additional _CALPHA_ constraints
977  //fpd generally this is unused
979  core::Size rootres = pose.fold_tree().root();
980  Real const coord_sdev( 1 ); // this should be an option perhaps
981  for ( core::Size i=1; i<pose.total_residue(); ++i ) {
982  // skip non-protein residues and templates which may have been added (strand pairings) and placed the history in stage1
983  if ( !pose.residue(i).is_protein() ||
984  history->get(i) > (int)template_index_icluster.size() // strand pairings
985  ) continue;
986  utility::vector1<core::Size> const &source_list = template_cst_reses_[ template_index_icluster[ history->get(i) ] ];
987  if ( std::find( source_list.begin(), source_list.end(), i ) != source_list.end() ) {
988  TR << "Constrain residue " << i << std::endl;
989  core::Size ii = pose.residue(i).atom_index(" CA ");
990  pose.add_constraint(
992  core::id::AtomID(ii,i), core::id::AtomID(1,rootres), pose.xyz( core::id::AtomID(ii,i) ), new HarmonicFunc( 0.0, coord_sdev ) ) );
993  }
994  }
995 
996  // standard relax
997  // do relax _without_ ramping down coordinate constraints
998  protocols::relax::FastRelax relax_prot( fa_scorefxn_, relax_repeats_ ,"NO CST RAMPING" );
999  relax_prot.set_min_type("lbfgs_armijo_nonmonotone");
1000  relax_prot.apply(pose);
1001  } else {
1002  // batch relax
1003  // add stucture to queue
1005  new_struct->fill_struct( pose );
1006  new_struct->energies_from_pose( pose );
1007  post_centroid_structs.push_back( new_struct );
1008 
1009  if (post_centroid_structs.size() == batch_relax_) {
1011  relax_prot.set_min_type("lbfgs_armijo_nonmonotone");
1012  relax_prot.set_force_nonideal(true);
1014 
1015  // need to use a packer task factory to handle poses with different disulfide patterning
1018  tf->push_back( new core::pack::task::operation::IncludeCurrent );
1020  //tf->push_back( new core::pack::task::operation::NoRepackDisulfides );
1021  relax_prot.set_task_factory( tf );
1022 
1023  // notice! this assumes all poses in a set have the same constraints!
1024  relax_prot.batch_apply(post_centroid_structs, pose.constraint_set()->clone());
1025 
1026  // reinflate pose
1027  post_centroid_structs[0]->fill_pose( pose );
1028  } else {
1030  tocen->apply(pose);
1031  need_more_samples = true;
1032  }
1033  }
1034  } else {
1035  // no fullatom sampling
1036  (*stage2_scorefxn_)(pose);
1037  }
1038  }
1039  if (native_ && native_->total_residue()) {
1040  gdtmm = get_gdtmm(*native_, pose, native_aln);
1041  core::pose::setPoseExtraScores( pose, "GDTMM_final", gdtmm);
1042  TR << "GDTMM_final" << ObjexxFCL::fmt::F(8,3,gdtmm) << std::endl;
1043  }
1044 }
1045 
1048 {
1049  utility::vector1 < Loops > domains = all_domains[ref_domains_index];
1050  if (all_domains[ref_domains_index].size() == 0) return domains;
1051 
1052  utility::vector1 < bool > residue_mask(n_residues, false);
1053  residue_mask.resize(n_residues);
1054 
1055  //mask residues from all domains not to be cut
1056  for (Size i_pose=1; i_pose <= all_domains.size(); ++i_pose) {
1057  for (Size idomain=1; idomain <= all_domains[i_pose].size(); ++idomain) {
1058  for (core::Size iloop=1; iloop<=all_domains[i_pose][idomain].num_loop(); ++iloop) {
1059  for (core::Size ires=all_domains[i_pose][idomain][iloop].start()+1; ires<=all_domains[i_pose][idomain][iloop].stop(); ++ires) {
1060  residue_mask[ires] = true;
1061  }
1062  }
1063  }
1064  }
1065 
1066  // assuming loops in domains are sequential
1067  for (Size idomain=1; idomain <= all_domains[ref_domains_index].size(); ++idomain) {
1068  for (core::Size iloop=1; iloop<=all_domains[ref_domains_index][idomain].num_loop(); ++iloop) {
1069  if (idomain == 1 && iloop == 1) {
1070  domains[idomain][iloop].set_start(1);
1071  }
1072  if (idomain == all_domains[ref_domains_index].size() && iloop == all_domains[ref_domains_index][idomain].num_loop()) {
1073  domains[idomain][iloop].set_stop(n_residues);
1074  }
1075 
1076  // the next loop
1077  Size jdomain = idomain;
1078  Size jloop = iloop+1;
1079  if (jloop > all_domains[ref_domains_index][idomain].num_loop()) {
1080  ++jdomain;
1081  jloop = 1;
1082  if (jdomain > all_domains[ref_domains_index].size()) continue;
1083 
1084  Size gap_start = all_domains[ref_domains_index][idomain][iloop].stop()+1;
1085  Size gap_stop = all_domains[ref_domains_index][jdomain][jloop].start();
1086  utility::vector1<Size> cut_options;
1087  for (Size ires=gap_start; ires<=gap_stop; ++ires) {
1088  if (residue_mask[ires]) continue;
1089  cut_options.push_back(ires);
1090  }
1091  if (cut_options.size() == 0) {
1092  for (Size ires=gap_start; ires<=gap_stop; ++ires) {
1093  cut_options.push_back(ires);
1094  }
1095  }
1096  Size cut = cut_options[RG.random_range(1,cut_options.size())];
1097 
1098  domains[idomain][iloop].set_stop(cut-1);
1099  domains[jdomain][jloop].set_start(cut);
1100  }
1101  }
1102  }
1103  return domains;
1104 }
1105 
1106 void
1108 {
1109  for (Size i_pose=1; i_pose <= poses.size(); ++i_pose) {
1110  if (poses[i_pose] == ref_pose) continue;
1111  align_by_domain(*poses[i_pose], *ref_pose, domains);
1112 
1113  //std::string out_fn = template_fn_[i_pose] + "_realigned.pdb";
1114  //poses[i_pose]->dump_pdb(out_fn);
1115  }
1116 }
1117 
1118 
1119 void
1121 {
1122  for (Size i_domain = 1; i_domain <= domains.size() ; ++i_domain) {
1125  std::list <Size> residue_list;
1126  core::Size n_mapped_residues=0;
1127  for (core::Size ires=1; ires<=pose.total_residue(); ++ires) {
1128  if (!pose.residue_type(ires).is_protein()) continue;
1129  int pose_res = (pose.pdb_info()) ? pose.pdb_info()->number(ires) : ires;
1130  for (core::Size iloop=1; iloop<=domains[i_domain].num_loop(); ++iloop) {
1131  if ( pose_res < (int)domains[i_domain][iloop].start() || pose_res > (int)domains[i_domain][iloop].stop() ) continue;
1132  residue_list.push_back(ires);
1133  }
1134  }
1135  std::list <Size> ref_residue_list;
1136  for (core::Size jres=1; jres<=ref_pose.total_residue(); ++jres) {
1137  if (!ref_pose.residue_type(jres).is_protein()) continue;
1138  int ref_pose_res = (ref_pose.pdb_info()) ? ref_pose.pdb_info()->number(jres) : jres;
1139  for (core::Size iloop=1; iloop<=domains[i_domain].num_loop(); ++iloop) {
1140  if ( ref_pose_res < (int)domains[i_domain][iloop].start() || ref_pose_res > (int)domains[i_domain][iloop].stop() ) continue;
1141  ref_residue_list.push_back(jres);
1142  }
1143  }
1144 
1145  TMalign tm_align;
1146  string seq_pose, seq_ref, aligned;
1147  int reval = tm_align.apply(pose, ref_pose, residue_list, ref_residue_list);
1148  if (reval == 0) {
1149  tm_align.alignment2AtomMap(pose, ref_pose, residue_list, ref_residue_list, n_mapped_residues, atom_map);
1150  tm_align.alignment2strings(seq_pose, seq_ref, aligned);
1151 
1152  using namespace ObjexxFCL::fmt;
1153  Size norm_length = residue_list.size() < ref_residue_list.size() ? residue_list.size():ref_residue_list.size();
1154  TR << "Align domain with TMscore of " << F(8,3,tm_align.TMscore(norm_length)) << std::endl;
1155  TR << seq_pose << std::endl;
1156  TR << aligned << std::endl;
1157  TR << seq_ref << std::endl;
1158 
1159  if (n_mapped_residues >= 6) {
1160  utility::vector1< core::Real > aln_cutoffs;
1161  aln_cutoffs.push_back(6);
1162  aln_cutoffs.push_back(4);
1163  aln_cutoffs.push_back(3);
1164  aln_cutoffs.push_back(2);
1165  aln_cutoffs.push_back(1.5);
1166  aln_cutoffs.push_back(1);
1167  core::Real min_coverage = 0.2;
1168  partial_align(pose, ref_pose, atom_map, residue_list, true, aln_cutoffs, min_coverage); // iterate_convergence = true
1169  }
1170  }
1171  //else {
1172  // TR << "This domain cannot be aligned: " << n_mapped_residues<< std::endl;
1173  // TR << domains[i_domain];
1174  //}
1175  }
1176 }
1177 
1180 
1183  return "HybridizeProtocol";
1184 }
1185 
1186 void
1188  utility::tag::TagPtr const tag, moves::DataMap & data, filters::Filters_map const & , moves::Movers_map const & , core::pose::Pose const & pose )
1189 {
1190  // config file
1191  if( tag->hasOption( "config_file" ) )
1192  read_template_structures( tag->getOption< std::string >( "config_file" ) );
1193 
1194  // basic options
1195  stage1_increase_cycles_ = tag->getOption< core::Real >( "stage1_increase_cycles", 1. );
1196  stage2_increase_cycles_ = tag->getOption< core::Real >( "stage2_increase_cycles", 1. );
1197  fa_cst_fn_ = tag->getOption< std::string >( "fa_cst_file", "" );
1198  batch_relax_ = tag->getOption< core::Size >( "batch" , 1 );
1199 
1200  if( tag->hasOption( "starting_template" ) ) {
1201  utility::vector1<std::string> buff = utility::string_split( tag->getOption<std::string>( "starting_template" ), ',' );
1202  foreach(std::string field, buff){
1203  Size const value = std::atoi( field.c_str() ); // convert to C string, then convert to integer, then set a Size (phew!)
1204  starting_templates_.push_back(value);
1205  }
1206  }
1207 
1208  if( tag->hasOption( "stage1_1_cycles" ) )
1209  stage1_1_cycles_ = tag->getOption< core::Size >( "stage1_1_cycles" );
1210  if( tag->hasOption( "stage1_2_cycles" ) )
1211  stage1_2_cycles_ = tag->getOption< core::Size >( "stage1_2_cycles" );
1212  if( tag->hasOption( "stage1_3_cycles" ) )
1213  stage1_3_cycles_ = tag->getOption< core::Size >( "stage1_3_cycles" );
1214  if( tag->hasOption( "stage1_4_cycles" ) )
1215  stage1_4_cycles_ = tag->getOption< core::Size >( "stage1_4_cycles" );
1216  if( tag->hasOption( "stage1_probability" ) )
1217  stage1_probability_ = tag->getOption< core::Real >( "stage1_probability" );
1218  if( tag->hasOption( "add_hetatm" ) )
1219  add_hetatm_ = tag->getOption< bool >( "add_hetatm" );
1220  if( tag->hasOption( "hetatm_cst_weight" ) )
1221  hetatm_cst_weight_ = tag->getOption< core::Real >( "hetatm_cst_weight" );
1222  if( tag->hasOption( "domain_assembly" ) )
1223  domain_assembly_ = tag->getOption< bool >( "domain_assembly" );
1224  if( tag->hasOption( "realign_domains" ) )
1225  realign_domains_ = tag->getOption< bool >( "realign_domains" );
1226  if( tag->hasOption( "realign_domains_stage2" ) )
1227  realign_domains_stage2_ = tag->getOption< bool >( "realign_domains_stage2" );
1228  if( tag->hasOption( "add_non_init_chunks" ) )
1229  add_non_init_chunks_ = tag->getOption< bool >( "add_non_init_chunks" );
1230  if( tag->hasOption( "frag_1mer_insertion_weight" ) )
1231  frag_1mer_insertion_weight_ = tag->getOption< core::Real >( "frag_1mer_insertion_weight" );
1232  if( tag->hasOption( "small_frag_insertion_weight" ) )
1233  small_frag_insertion_weight_ = tag->getOption< core::Real >( "small_frag_insertion_weight" );
1234  if( tag->hasOption( "big_frag_insertion_weight" ) )
1235  big_frag_insertion_weight_ = tag->getOption< core::Real >( "big_frag_insertion_weight" );
1236  if( tag->hasOption( "frag_weight_aligned" ) )
1237  frag_weight_aligned_ = tag->getOption< core::Real >( "frag_weight_aligned" );
1238  if( tag->hasOption( "auto_frag_insertion_weight" ) )
1239  auto_frag_insertion_weight_ = tag->getOption< bool >( "auto_frag_insertion_weight" );
1240  if( tag->hasOption( "max_registry_shift" ) )
1241  max_registry_shift_ = tag->getOption< core::Size >( "max_registry_shift" );
1242  if( tag->hasOption( "no_global_frame" ) )
1243  no_global_frame_ = tag->getOption< bool >( "no_global_frame" );
1244  if( tag->hasOption( "linmin_only" ) )
1245  linmin_only_ = tag->getOption< bool >( "linmin_only" );
1246  if( tag->hasOption( "repeats" ) )
1247  relax_repeats_ = tag->getOption< core::Size >( "repeats" );
1248  if( tag->hasOption( "cartfrag_overlap" ) )
1249  cartfrag_overlap_ = tag->getOption< core::Size >( "cartfrag_overlap" );
1250  if( tag->hasOption( "disulf_file" ) )
1251  disulf_file_ = tag->getOption< std::string >( "disulf_file" );
1252 
1253  // scorfxns
1254  if( tag->hasOption( "stage1_scorefxn" ) ) {
1255  std::string const scorefxn_name( tag->getOption<std::string>( "stage1_scorefxn" ) );
1256  stage1_scorefxn_ = (data.get< ScoreFunction * >( "scorefxns", scorefxn_name ))->clone();
1257  }
1258  if( tag->hasOption( "stage2_scorefxn" ) ) {
1259  std::string const scorefxn_name( tag->getOption<std::string>( "stage2_scorefxn" ) );
1260  stage2_scorefxn_ = (data.get< ScoreFunction * >( "scorefxns", scorefxn_name ))->clone();
1261  }
1262  if( tag->hasOption( "fa_scorefxn" ) ) {
1263  std::string const scorefxn_name( tag->getOption<std::string>( "fa_scorefxn" ) );
1264  fa_scorefxn_ = (data.get< ScoreFunction * >( "scorefxns", scorefxn_name ))->clone();
1265  }
1266 
1267  //ddomain
1268  hcut_ = tag->getOption< core::Real >( "domain_hcut" , 0.18);
1269  pcut_ = tag->getOption< core::Real >( "domain_pcut" , 0.81);
1270  length_ = tag->getOption< core::Size >( "domain_length" , 38);
1271 
1272  // fragments
1273  utility::vector1< utility::tag::TagPtr > const branch_tags( tag->getTags() );
1275  for (tag_it = branch_tags.begin(); tag_it != branch_tags.end(); ++tag_it) {
1276  if ( (*tag_it)->getName() == "Fragments" ) {
1277  using namespace core::fragment;
1278  if ( (*tag_it)->hasOption( "3mers" ) ) {
1279  core::fragment::FragSetOP frags = core::fragment::FragmentIO().read_data( (*tag_it)->getOption<std::string>( "3mers" ) );
1280  fragments_small_.push_back(frags);
1281  } else if ( (*tag_it)->hasOption( "small" ) ) {
1282  utility::vector1<std::string> frag_files = utility::string_split((*tag_it)->getOption<std::string>( "small" ), ',');
1283  for (core::Size i=1; i<= frag_files.size(); ++i )
1284  fragments_small_.push_back(core::fragment::FragmentIO().read_data( frag_files[i] ));
1285  }
1286  if ( (*tag_it)->hasOption( "9mers" ) ) {
1287  core::fragment::FragSetOP frags = core::fragment::FragmentIO().read_data( (*tag_it)->getOption<std::string>( "9mers" ) );
1288  fragments_big_.push_back(frags);
1289  } else if ( (*tag_it)->hasOption( "big" ) ) {
1290  utility::vector1<std::string> frag_files = utility::string_split((*tag_it)->getOption<std::string>( "big" ), ',');
1291  for (core::Size i=1; i<= frag_files.size(); ++i )
1292  fragments_big_.push_back(core::fragment::FragmentIO().read_data( frag_files[i] ));
1293  }
1294  }
1295 
1296  if ( (*tag_it)->getName() == "Template" ) {
1297  std::string template_fn = (*tag_it)->getOption<std::string>( "pdb" );
1298  std::string cst_fn = (*tag_it)->getOption<std::string>( "cst_file", "AUTO" );
1299  core::Real weight = (*tag_it)->getOption<core::Real>( "weight", 1 );
1300  core::Real domain_assembly_weight = (*tag_it)->getOption<core::Real>( "domain_assembly_weight", 0. );
1301  core::Size cluster_id = (*tag_it)->getOption<core::Size>( "cluster_id", 1 );
1302  utility::vector1<core::Size> cst_reses;
1303  if ((*tag_it)->hasOption( "constrain_res" ))
1304  cst_reses = core::pose::get_resnum_list_ordered( (*tag_it)->getOption<std::string>("constrain_res"), pose );
1305 
1306  std::string symm_file = (*tag_it)->getOption<std::string>( "symmdef", "" );
1307 
1308  add_template(template_fn, cst_fn, symm_file, weight, domain_assembly_weight, cluster_id, cst_reses);
1309  }
1310 
1311  // strand pairings
1312  if ( (*tag_it)->getName() == "Pairings" ) {
1313  pairings_file_ = (*tag_it)->getOption< std::string >( "file", "" );
1314  if ( (*tag_it)->hasOption("sheets") ) {
1315  core::Size sheets = (*tag_it)->getOption< core::Size >( "sheets" );
1316  sheets_.clear();
1317  random_sheets_.clear();
1318  sheets_.push_back(sheets);
1319  } else if ( (*tag_it)->hasOption("random_sheets") ) {
1320  core::Size random_sheets = (*tag_it)->getOption< core::Size >( "random_sheets" );
1321  sheets_.clear();
1322  random_sheets_.clear();
1323  random_sheets_.push_back(random_sheets);
1324  }
1325  filter_templates_ = (*tag_it)->getOption<bool>( "filter_templates" , 0 );
1326  }
1327 
1328  }
1329 }
1330 
1331 } // hybridization
1332 } // protocols
1333