Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AddorRemoveCsts.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/enzdes/movers/AddorRemoveCsts.cc
11 /// @brief
12 /// @author Florian Richter (floric@u.washington.edu)
13 
14 //unit headers
17 
18 //package headers
20 
21 //project headers
22 #include <basic/Tracer.hh>
23 #include <utility/tag/Tag.hh>
25 #include <basic/options/keys/enzdes.OptionKeys.gen.hh>
26 #include <basic/options/option.hh>
27 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
28 
30 
31 #include <utility/vector0.hh>
32 #include <utility/excn/Exceptions.hh>
33 #include <utility/vector1.hh>
34 
35 
36 
37 namespace protocols {
38 namespace enzdes {
39 
40 
41 //initializing static member variable
42 std::map< std::string, toolbox::match_enzdes_util::EnzConstraintIOOP > AddOrRemoveMatchCsts::cstfile_map_;
43 
44 static basic::Tracer tr("protocols.enzdes.AddorRemoveCsts");
45 
48 {
50 }
51 
54  return new AddOrRemoveMatchCsts;
55 }
56 
59 {
60  return "AddOrRemoveMatchCsts";
61 }
62 
64  : Mover("AddOrRemoveMatchCsts"),
65  option_cstfile_(""), cstfile_(""),
66  cst_action_(VOID), keep_covalent_(false),
67  accept_blocks_missing_header_(false), fail_on_constraints_missing_(true)
68 {
69  if( basic::options::option[basic::options::OptionKeys::enzdes::cstfile].user() ){
70  option_cstfile_ = basic::options::option[basic::options::OptionKeys::enzdes::cstfile].value();
71  }
73 
74  //this might change in the future to a scorefunction that's fully definable
75  //through a weights file, but atm it's probably safe to simply set the constraint
76  //weights to non zero values
77  sfxn_->set_weight( core::scoring::coordinate_constraint, 1.0 );
78  sfxn_->set_weight( core::scoring::atom_pair_constraint, 1.0 );
79  sfxn_->set_weight( core::scoring::angle_constraint, 1.0 );
80  sfxn_->set_weight( core::scoring::dihedral_constraint, 1.0 );
81 }
82 
84  Mover( other ),
85  option_cstfile_(other.option_cstfile_), cstfile_(other.cstfile_),
86  cst_action_(other.cst_action_), keep_covalent_(other.keep_covalent_),
87  accept_blocks_missing_header_(other.accept_blocks_missing_header_),
88  fail_on_constraints_missing_(other.fail_on_constraints_missing_),
89  sfxn_(other.sfxn_)
90 {}
91 
93 
96 {
97  return new AddOrRemoveMatchCsts( *this );
98 }
99 
102 {
103  return new AddOrRemoveMatchCsts();
104 }
105 
106 void
108 {
110  //safety check for this function being called without a cstfile having been specified
111  if( (cstfile == "") && (cstfile_map_.size() == 0) ){
112  tr.Warning << "Warning: apply function of enzdes constraints mover called even though no cstfile has been specified on the commandline, in the tag, or programmatically. This function will have no effect." << std::endl;
113  return;
114  }
115 
117 
118  switch (cst_action_) {
119  case ADD_NEW:
120  cst_io->add_constraints_to_pose( pose, sfxn_, accept_blocks_missing_header_ );
121  break;
122  case ADD_PREGENERATED:
123  cst_io->add_pregenerated_constraints_to_pose( pose, sfxn_ );
124  break;
125  case REMOVE:
126  cst_io->remove_constraints_from_pose( pose, keep_covalent_, fail_on_constraints_missing_ );
127  break;
128  case VOID:
129  utility_exit_with_message("Illegal action for AddOrRemoveMatchCsts mover specified.");
130  break;
131  }
132 }
133 
137 }
138 
139 void
141 {
142  cstfile_ = tag->getOption<std::string>( "cstfile", "" );
143  if( (cstfile_ == "") && ( option_cstfile_ == "" ) ){
144  tr.Warning << "WARNING: No name for the enzdes .cst file was specified in either the options, the xml tag, or programatically. AddOrRemoveMatchCsts will turn into a null operation." << std::endl;
145  }
146 
147  std::string cst_instruction = tag->getOption<std::string>( "cst_instruction", "void" );
148  if( cst_instruction == "add_new" ) cst_action_ = ADD_NEW;
149  else if( cst_instruction == "add_pregenerated") cst_action_ = ADD_PREGENERATED;
150  else if( cst_instruction == "remove" ) cst_action_ = REMOVE;
151  else{
152  throw utility::excn::EXCN_RosettaScriptsOption("Illegal or no value for cst_instruction in xml tag given. Has to be either 'add_new', 'add_pregenerated', or 'remove'.");
153  }
154 
155  keep_covalent_ = tag->getOption<bool>( "keep_covalent", 0 );
156  accept_blocks_missing_header_ = tag->getOption<bool>( "accept_blocks_missing_header", 0 );
157  fail_on_constraints_missing_ = tag->getOption<bool>( "fail_on_constraints_missing", 1 );
158 }
159 
160 void AddOrRemoveMatchCsts::parse_def( utility::lua::LuaObject const & def,
161  utility::lua::LuaObject const & ,
162  utility::lua::LuaObject const & ,
164 
165  cstfile_ = def["cstfile"] ? def[ "cstfile" ].to<std::string>() : "";
166  if( (cstfile_ == "") && ( option_cstfile_ == "" ) ){
167  tr.Warning << "WARNING: No name for the enzdes .cst file was specified in either the options, the xml tag, or programatically. AddOrRemoveMatchCsts will turn into a null operation." << std::endl;
168  }
169 
170  std::string cst_instruction = def["cst_instruction"] ? def[ "cst_instruction" ].to<std::string>() : "void";
171  if( cst_instruction == "add_new" ) cst_action_ = ADD_NEW;
172  else if( cst_instruction == "add_pregenerated") cst_action_ = ADD_PREGENERATED;
173  else if( cst_instruction == "remove" ) cst_action_ = REMOVE;
174  else{
175  utility_exit_with_message("Illegal or no value for cst_instruction in xml tag given. Has to be either 'add_new', 'add_pregenerated', or 'remove'.");
176  }
177 
178  keep_covalent_ = def["keep_covalent"] ? def[ "keep_covalent" ].to<bool>() : false;
179  accept_blocks_missing_header_ = def["accept_blocks_missing_header"] ? def[ "accept_blocks_missing_header" ].to<bool>() : false;
180  fail_on_constraints_missing_ = def["fail_on_constraints_missing"] ? def[ "fail_on_constraints_missing" ].to<bool>() : true;
181 }
182 
183 void
185 {
186  cstfile_ = setting;
187 }
188 
189 
190 
193 {
194 
195  if( cstfile == "" ){
196  if( cstfile_map_.size() == 1 ) return cstfile_map_.begin()->second;
197  }
198  std::map< std::string, toolbox::match_enzdes_util::EnzConstraintIOOP>::const_iterator enzio_it = cstfile_map_.find( cstfile );
199  if( enzio_it == cstfile_map_.end() ){
200  tr.Warning << "WARNING: trying to get an EnzConstraintIOOP object for cstfile " << cstfile << " that hasn't been instantiated yet. Returning NULL pointer." << std::endl;
201  return NULL;
202  }
203  return enzio_it->second;
204 
205 }
206 
209  std::string const cstfile )
210 {
211  std::map< std::string, toolbox::match_enzdes_util::EnzConstraintIOOP >::iterator cstio_it = cstfile_map_.find( cstfile );
212 
213  if( cstio_it == cstfile_map_.end() ){
215  new_cst_io->read_enzyme_cstfile( cstfile );
216  cstfile_map_.insert( std::pair< std::string, toolbox::match_enzdes_util::EnzConstraintIOOP >( cstfile, new_cst_io ) );
217  return new_cst_io;
218  }
219  return cstio_it->second;
220 }
221 
222 } //enzdes
223 } //protocols