Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemodelEnzdesCstModule.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 protocols/forge/remodel/RemodelEnzdesCstModule.hh
11 ///
12 /// @brief this file handles merging constraint defined by enzdes type cstfile
13 /// @brief and blueprint definition of positions and add them to the pose
14 /// @author Possu Huang, possu@u.washington.edu, Jan 2010
15 
19 #include <basic/Tracer.hh>
20 // AUTO-REMOVED #include <basic/options/keys/constraints.OptionKeys.gen.hh>
21 #include <basic/options/option.hh>
22 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
23 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
24 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
25 // AUTO-REMOVED #include <core/conformation/Residue.hh>
28 #include <utility/vector1.hh>
36 // AUTO-REMOVED #include <protocols/forge/build/BuildInstruction.hh> // REQUIRED FOR WINDOWS
37 
40 
41 
42 
43 namespace protocols{
44 namespace forge{
45 namespace remodel{
46 
47 static basic::Tracer TR("protocols.forge.remodel.RemodelEnzdesCstModule");
48 
49 RemodelEnzdesCstModule::RemodelEnzdesCstModule(RemodelData external_data) : protocols::toolbox::match_enzdes_util::EnzConstraintIO(core::chemical::ChemicalManager::get_instance()->residue_type_set( core::chemical::FA_STANDARD )){
50  read_enzyme_cstfile( basic::options::option[basic::options::OptionKeys::enzdes::cstfile]);
52  remodel_data_ = external_data;
53 
54 }
55 
57 
58 void
60 {
61  using namespace protocols::toolbox::match_enzdes_util;
62 
63  //set up constraints (read cstfile, do mapping, etc, then add to pose)
64  if( basic::options::option[basic::options::OptionKeys::enzdes::cstfile].user() ){
66 
67  //tmp hack -- from florian for cstcashe observer initialization
69  if( !cst_cache ) {
70  TR << "cst_cache nonexistant; make new instance." << std::endl;
71  toolbox::match_enzdes_util::get_enzdes_observer( pose )->set_cst_cache( new EnzdesCstCache( this, cst_pairs_.size() ) );
72  cst_cache = toolbox::match_enzdes_util::get_enzdes_observer( pose )->cst_cache();
73  }
74  //tmp hack over
75 
77 
78 bool not_packed = true;
79  for (core::Size block = 1 ; block <= cstblocksize_; ++block){
80  //initialize block internals
81  cst_pairs_[ block ]->set_mcfi( this->mcfi_list( block )->mcfi( 1 ) );
82 
83 
84  if (!backbone_only_ && (!cst_pairs_[block]->resA()->is_backbone() || !cst_pairs_[block]->resB()->is_backbone())) { //s-b, s-s don't apply if not after design
85 
86  TR << "replace sidechain" << std::endl;
87 
88  WorkingRemodelSet working_model;
89  working_model.workingSetGen(pose, remodel_data_);
90 
91 if (not_packed){
92  //unfortunately needed this to make the sidechains for fullatom cst
93  RemodelDesignMover designMover(remodel_data_, working_model, scorefxn_);
94  designMover.set_state("stage");
95  designMover.apply(pose);
96  not_packed= false;
97  }
98 
99  TR << "applying sidechain constraints" << std::endl;
101  }
102  else if ((cst_pairs_[block]->resA()->is_backbone() && cst_pairs_[block]->resB()->is_backbone())){ //bb to bb always apply
103  TR << "applying backbone constraints" << std::endl;
105  }
106  else {
107  TR << "no constraint applied (only sidechain cst was defined in bb stage?) EnzdesCstModule Apply" << std::endl;
108  }
109  }
110  // (*scorefxn_)( pose );
111  }
112 
113 }
114 
115 void
117  TR << "turning on constraint weights" << std::endl;
118  scorefxn->set_weight(core::scoring::coordinate_constraint, 1.0 );
119  scorefxn->set_weight(core::scoring::atom_pair_constraint, 1.0 );
120  scorefxn->set_weight(core::scoring::angle_constraint, 1.0 );
121  scorefxn->set_weight(core::scoring::dihedral_constraint, 1.0 );
122  scorefxn->set_weight(core::scoring::res_type_constraint, 1.0);
123 
124 }
125 
126 
127 void
129 
133 
134 
135  for (core::Size i = 0, ie = remodel_data_.blueprint.size(); i < ie ; i++){
136  if (remodel_data_.blueprint[i].has_constraints){
137  for (std::vector<std::string>::iterator it = remodel_data_.blueprint[i].constraint_definition.begin(), end = remodel_data_.blueprint[i].constraint_definition.end(); it != end; it++){
138  //casting, sort of....
139  core::Size found_start = (*it).find_first_of("0123456789");
140  core::Size found_end = (*it).find_last_of("0123456789");
141  std::string buffer((*it).substr(found_start,found_end-found_start+1));
142  //TR << "buffer number: " << buffer << std::endl;
143  std::istringstream bufferstream(buffer);
144  core::Size temp;
145  bufferstream >> temp;
146  cstblock.push_back(temp);
147 
148  core::Size bufferLength = (*it).length();
149 
150  role.push_back((*it).substr(bufferLength-1,1));
151  position.push_back(remodel_data_.blueprint[i].index);
152  }
153  }
154  }
155 TR<< "cstblock.size = " << cstblock.size() << std::endl;
156 TR<< "cst_pair_.size = " << cst_pairs_.size() << std::endl;
157 
158  runtime_assert ( cstblock.size()/2 == cst_pairs_.size());
159  cstblocksize_ = cstblock.size()/2;
160 
161 
162  for (core::Size i = 1; i <= cstblock.size(); ++i){
163  if (role[i] == "A"){
164  TR<< "adding constraint to " << position[i] << " in " << cstblock[i] << " residue: " << pose.residue_type(position[i]).name3() << std::endl;
165  cst_pairs_[cstblock[i]]->nonconst_resA()->set_external_position(position[i]);
166  cst_pairs_[cstblock[i]]->nonconst_resA()->find_in_pose_if_missing_from_header( pose );
167  // cst_cache->param_cache( cstblock[i] )->template_res_cache( 1 )->add_position_in_pose( position[i] );//new
168  // if (!backbone_only_ && !cst_pairs_[cstblock[i]]->resA()->is_backbone()){
169  // TR << "replace Sidechain to " << remodel_data_.blueprint[position[i]-1].aminoAcidList[0] << std::endl;//-1 on position array for 0 based switch
170  // core::chemical::ResidueTypeSetCAP residue_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( "fa_standard" );
171  // pose.replace_residue( position[i], *core::conformation::ResidueFactory::create_residue(residue_set->name_map(name_from_aa(remodel_data_.blueprint[position[i]-1].aminoAcidList[0]))),true) ;
172  // }
173  } else if (role[i] == "B"){
174  TR<< "adding constraint to " << position[i] << " in " << cstblock[i] << " residue: " << pose.residue_type(position[i]).name3() << std::endl;
175  cst_pairs_[cstblock[i]]->nonconst_resB()->set_external_position(position[i]);
176  cst_pairs_[cstblock[i]]->nonconst_resB()->find_in_pose_if_missing_from_header( pose );
177  // cst_cache->param_cache( cstblock[i] )->template_res_cache( 2 )->add_position_in_pose( position[i] );//new
178  // if (!backbone_only_ && !cst_pairs_[cstblock[i]]->resB()->is_backbone()){
179  // TR << "replace Sidechain to " << remodel_data_.blueprint[position[i]-1].aminoAcidList[0] << std::endl;
180  // core::chemical::ResidueTypeSetCAP residue_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( "fa_standard" );
181  // pose.replace_residue( position[i], *core::conformation::ResidueFactory::create_residue(residue_set->name_map(name_from_aa(remodel_data_.blueprint[position[i]-1].aminoAcidList[0]))),true) ;
182  // }
183  } else {
184  TR << "mistake in merging blueprint cst and cst_pairs data" << std::endl;
185  }
186  }
187 }
188 
189 void
191  backbone_only_ = true;
192 }
193 
194 void
196  backbone_only_ = false;
197 }
198 
199 
200 
201 } //namespace protocols
202 } //namespace forge
203 } //namespace remodel
204 
205