Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemodelConstraintGenerator.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/RemodelConstraintGenerator.cc
11 ///
12 /// @brief
13 /// @author Florian Richter, floric@u.washington.edu, april 2009
14 /// @modified Tom Linsky, tlinsky@uw.edu
15 
16 // AUTO-REMOVED #include <protocols/forge/components/VarLengthBuild.hh>
18 
19 #include <core/pose/Pose.hh>
22 
23 #include <utility/tag/Tag.hh>
24 #include <utility/vector1.hh>
25 #include <basic/Tracer.hh>
26 
27 static basic::Tracer TR( "protocols.forge.remodel.remodelconstraintgenerator" );
28 namespace protocols {
29 namespace forge {
30 namespace remodel {
31 
32 std::map<std::string,core::scoring::constraints::ConstraintCOPs> RemodelConstraintGenerator::cst_map_;
33 
34 /// @details Auto-generated virtual destructor
36 {}
37 
38 
40  : Mover("RemodelConstraintGenerator"),
41  id_( "" ),
42  seqmap_(NULL),
43  vlb_(NULL)
44 {}
45 
47  : Mover( rval ),
48  id_( rval.id_ ),
49  seqmap_( rval.seqmap_ ),
50  vlb_( rval.vlb_ )
51 {}
52 
53 /// @details When called, generates constraints for the pose, and adds them to the pose
54 void
56 {
57  init( pose );
59 }
60 
61 /// @brief This is called if this mover is instantiated from XML
62 void
67  core::pose::Pose const & )
68 {
69  // if there are any options that we might want, they will go here...
70  id_ = tag->getOption<std::string>( "name", id_ );
71  TR << "Setting id for type " << this->get_name() << " = " << id_ << std::endl;
72 }
73 
74 void
76  core::pose::Pose & pose )
77 {
78  //TR << "Clearing old constraints in RCG" << std::endl;
79  if ( csts_.size() > 0 ){
81  }
82 
83  //TR << "Generating remodel constraints in RCG" << std::endl;
85  //TR << "Done generating remodel csts in RCG" << std::endl;
86 
87  //safeguard against an RCG not generating anything
88  if( csts_.size() == 0 ) return;
89 
90  //TR << this->get_name() << " generated " << csts_.size() << " constraints." << std::endl;
91 
92  csts_ = pose.add_constraints( csts_ );
94 }
95 
96 void
98  core::pose::Pose & pose
99 ) const
100 {
102 
103  //safeguard against an RCG not generating anything
104  if( remodel_csts.size() == 0 ) return;
105 
106  //TR << this->get_name() << " is about to try to remove " << remodel_csts.size() << " constraints." << std::endl;
107 
108  if( ! pose.remove_constraints( remodel_csts, true ) ){
109  utility_exit_with_message("Remodel constraints somehow got lost among the way");
110  }
111 }
112 
113 void
115 {
116  csts_.push_back( cst );
117 }
118 
119 void
121 {
122  for( core::scoring::constraints::ConstraintCOPs::const_iterator cst_it = csts.begin();
123  cst_it != csts.end(); ++cst_it ){
124  add_constraint( (*cst_it) );
125  }
126 }
127 
128 void
130 {
131  csts_.clear();
133 }
134 
137  return vlb_;
138 }
139 
140 void
142  VarLengthBuildAP vlb )
143 {
144  vlb_ = vlb;
145 }
146 
149 {
150  return id_;
151 }
152 
153 void
155 {
156  id_ = id;
157 }
158 
159 void
162 {
163  seqmap_ = seqmap;
164 }
165 
168 {
169  return seqmap_;
170 }
171 
172 void
174 {
175  if ( id_ == "" ) return;
176  // find id for this class in the map
177  std::map< std::string, core::scoring::constraints::ConstraintCOPs >::iterator cst_it( cst_map_.find( id_ ) );
178  // if the constraints are found, warn the user and erase the old data
179  if ( cst_it != cst_map_.end() ) {
180  TR << "Overwriting constraints for " << this->get_name() << " named " << id_ << std::endl;
181  cst_map_.erase( cst_it );
182  }
183 }
184 
185 void
187 {
188  if ( id_ == "" ) {
189  //TR << "ID is not set for this " << this->get_name() << " object. Constraints will not be removable by XML." << std::endl;
190  return;
191  }
192  // clear any stored csts
194 
195  // store the csts
196  cst_map_.insert( std::pair< std::string, core::scoring::constraints::ConstraintCOPs >( id_, csts_ ) );
197 }
198 
201 {
202  if ( id == "" ) {
203  utility_exit_with_message( "ID is not set! The constraint set returned will be empty. Something is being mis-used." );
204  }
205  // find the constraint set in map
206  std::map< std::string, core::scoring::constraints::ConstraintCOPs >::const_iterator cst_it( cst_map_.find( id ) );
207  if ( cst_it == cst_map_.end() ) {
208  utility_exit_with_message( "Tried to remove constraints that aren't stored for ID=" + id );
209  }
210  return cst_it->second;
211 }
212 
213 } //namespace remodel
214 } //namespace forge
215 } //namespace protocols