Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DofClaim.hh
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 TopologyBroker
11 /// @brief top-class (Organizer) of the TopologyBroker mechanism
12 /// @detailed responsibilities:
13 /// maintains list of ToplogyClaimers
14 /// maintains DofClaims -- exclusive or non-exclusively markedup dofs like BackboneClaim, IntraResClaim, JumpClaim
15 /// generates FoldTree, MoveMap, and collects samplers provided by TopologyClaimers
16 /// @author Oliver Lange
17 
18 
19 #ifndef INCLUDED_protocols_topology_broker_DofClaim_hh
20 #define INCLUDED_protocols_topology_broker_DofClaim_hh
21 
22 
23 // Unit Headers
25 
26 
27 // Package Headers
29 
30 
31 // Project Headers
32 #include <core/types.hh>
34 
35 // ObjexxFCL Headers
36 
37 // Utility headers
38 //#include <utility/io/izstream.hh>
39 //#include <utility/io/ozstream.hh>
40 //#include <utility/io/util.hh>
41 //#include <basic/Tracer.hh>
42 //#include <basic/options/option.hh>
43 #include <utility/exit.hh>
44 #include <utility/pointer/ReferenceCount.hh>
45 
46 //#include <basic/options/option_macros.hh>
47 
48 //// C++ headers
49 //#include <fstream>
50 #include <string>
51 
52 #include <utility/vector1.hh>
53 
54 
55 // option key includes
56 
57 
58 namespace protocols {
59 namespace topology_broker {
60 
61 /// A better DofClaims class would provide some extracting functions:
62 /// by owner
63 /// by type
64 
65 
66 
68 public:
69  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
70  virtual ~DofClaim();
71  typedef core::Size Size;
72  enum ClaimType {
73  BB,
74  // INTRA, //like side-chain doesn't propagate along FoldTree
76  CUT, //some way so that rigid-chunks can disallow cuts in their regions ?
77  SEQUENCE, //I want control over residue type,
78  ROOT //I want to set the Fold-Tree root
79  };
80  enum ClaimRight {
84  EXCLUSIVE, //MUST INIT
86  };
88  claim_source_( tc ),
89  right_( right ),
90  approved_( false )
91  {};
92 
93  virtual DofClaimOP clone() const = 0;
94  //virtual?
95  virtual Size size() const = 0;
96  virtual Size pos( Size i ) const = 0;
97  ClaimRight right() const { return right_; };
98 
99  TopologyClaimer const* owner() const { return claim_source_; }
101 
102  virtual void toggle( core::kinematics::MoveMap&, bool /*new_setting*/ ) const {};
103 
104  virtual ClaimType type() const = 0;
105 
106  bool exclusive() const {
107  return right() == DofClaim::EXCLUSIVE;
108  }
109 
110  virtual std::string str_type() const = 0;
111  virtual void show( std::ostream& os ) const;
112 
113  bool approved() const {
114  return approved_;
115  }
116 
117  void set_approved() { //this should only be called by the TopologyBroker ... make sure somehow? friend ?
118  approved_ = true;
119  }
120 private:
121  TopologyClaimer* claim_source_; //NEVER Make this OP --- circularity in smart-pointers (wanted this reference but there was some kind of problem ... what was it ?
123  bool approved_; //keep track of this ?
124 }; //class DofClaim
125 
126 //this is a bit different then the other claims.
127 //overlapping sequences don't make sense I think.
128 // this is merely used to arrange multiple patches so that everybody has a residue number.
129 // pos defines the starting residue of the patch.
130 // length the length.
131 // the initial claim goes out with pos=0 if you allow this sequence to move.
132 // length specifies the number of residues.
133 // pos=0 claims will be assigned a position from the broker.
134 class SequenceClaim : public DofClaim {
135  public:
137  TopologyClaimer* tc,
138  Size pos,
139  Size length,
140  std::string const& label,
142  ) : DofClaim( tc, right), pos_( pos ), length_( length ), label_( label ) {};
143 
144  virtual DofClaimOP clone() const { return new SequenceClaim( *this ); }
145 
146  virtual Size size() const { return 2; }
147 
148  virtual Size pos( Size i ) const {
149  runtime_assert( i <= 2 );
150  if ( i == 1 ) return pos_;
151  if ( i == 2 ) return length_;
152  return 0;
153  };
154 
155  std::string const& label() const {
156  return label_;
157  }
158 
159  ///@brief if you want to have a residue (eg., for a new ligand) you will be given a number...
160  void set_offset( Size pos ) {
161  pos_ = pos;
162  }
163 
164  Size offset() const {
165  return pos_;
166  }
167 
168  Size last_residue() const {
169  return pos_+length_-1;
170  }
171 
172  virtual ClaimType type() const {
173  return SEQUENCE;
174  }
175 
176  virtual std::string str_type() const {
177  return "SEQUENCE";
178  }
179 
180  virtual void show( std::ostream& os ) const {
181  os << " with label: " << label();
182  };
183 
184 protected:
185  Size pos_;
188 }; //class BBClaim
189 
190 class BBClaim : public DofClaim {
191 public:
193 
194  virtual DofClaimOP clone() const { return new BBClaim( *this ); }
195 
196  virtual Size size() const { return 1; }
197 
198  virtual Size pos( Size /* i */ ) const {
199  // runtime_assert( i == 1 ); warning in release build
200  return pos_;
201  };
202 
203  virtual void toggle( core::kinematics::MoveMap& mm, bool new_setting ) const {
204  mm.set_bb( pos_, new_setting );
205  }
206 
207  virtual ClaimType type() const {
208  return BB;
209  }
210 
211  virtual std::string str_type() const {
212  return "BB";
213  }
214 
215 protected:
217 }; //class BBClaim
218 
219 class JumpClaim : public DofClaim {
220  //this class could also specify which atoms to use for the jumps --- but I never used this so far.... might be necessary for Zn jumps.
221 public:
223  DofClaim( tc, right ),
224  permanent_( false ),
225  pos1_( pos1 ),
226  pos2_( pos2 ),
227  atom1_( "" ),
228  atom2_( "" )
229  {}
230 
232  DofClaim( tc, right ),
233  permanent_( false ),
234  pos1_( pos1 ),
235  pos2_( pos2 ),
236  atom1_( atom1 ),
237  atom2_( atom2 )
238  {}
239 
240  virtual DofClaimOP clone() const { return new JumpClaim( *this ); }
241 
242  virtual Size size() const { return 2; }
243 
244  virtual Size pos( Size i ) const {
245  runtime_assert( i <= 2 && i > 0);
246  if ( i==1 ) return pos1_;
247  if ( i==2 ) return pos2_;
248  return 0;
249  }
250 
251  virtual void toggle( core::kinematics::MoveMap& mm, bool new_setting ) const {
252  mm.set_jump( pos1_, pos2_, new_setting );
253  }
254 
255  virtual ClaimType type() const {
256  return JUMP;
257  }
258 
259  virtual bool remove() const {
260  return !permanent_;
261  }
262 
263  virtual std::string str_type() const {
264  return "JUMP";
265  }
266 
267  std::string const& jump_atom( Size i ) const {
268  runtime_assert( i <= 2 && i > 0 );
269  if ( i == 1 ) return atom1_;
270  if ( i == 2 ) return atom2_;
271  return atom1_; //happy compiler, never reached
272  }
273 
275  runtime_assert( i <= 2 && i > 0 );
276  if ( i == 1 ) atom1_ = str;
277  if ( i == 2 ) atom2_ = str;
278  }
279 
280 private:
281  bool permanent_; //true if this jump should still be present after loop-closing
286 }; //JumpClaim
287 
288 
289 class CutClaim : public DofClaim {
290  //this class could also specify which atoms to use for the jumps --- but I never used this so far.... might be necessary for Zn jumps.
291 public:
293  DofClaim( tc, right ),
294  pos1_( pos1 )
295  {}
296 
297  virtual DofClaimOP clone() const { return new CutClaim( *this ); }
298 
299  virtual Size size() const { return 1; }
300 
301  virtual Size pos( Size i ) const {
302  runtime_assert( i <= 1 && i > 0);
303  if ( i==1 ) return pos1_;
304  return 0;
305  }
306 
307  virtual ClaimType type() const {
308  return CUT;
309  }
310 
311  virtual bool remove() const {
312  return false; //so far all CutClaims will be physical --> permanent cuts ... !permanent_;
313  }
314 
315  virtual std::string str_type() const {
316  return "CUT";
317  }
318 
319 private:
320  // bool permanent_; //true if this cut should still be present after loop-closing
322 }; //CutClaim
323 
324 class RootClaim : public DofClaim {
325  //this class could also specify which atoms to use for the jumps --- but I never used this so far.... might be necessary for Zn jumps.
326 public:
328  DofClaim( tc, right ),
329  pos1_( pos1 )
330  {}
331 
332  virtual DofClaimOP clone() const { return new RootClaim( *this ); }
333 
334  virtual Size size() const { return 1; }
335 
336  virtual Size pos( Size i ) const {
337  runtime_assert( i <= 1 && i > 0);
338  if ( i==1 ) return pos1_;
339  return 0;
340  }
341 
342  virtual ClaimType type() const {
343  return ROOT;
344  }
345 
346  virtual bool remove() const {
347  return false; //so far all CutClaims will be physical --> permanent cuts ... !permanent_;
348  }
349 
350  virtual std::string str_type() const {
351  return "ROOT";
352  }
353 
354 private:
355  // bool permanent_; //true if this cut should still be present after loop-closing
357 }; //CutClaim
358 
359 
360 
361 extern std::ostream& operator<<( std::ostream& os, DofClaim const& );
362 extern std::ostream& operator<<( std::ostream& os, DofClaims const& );
363 
364 }
365 }
366 
367 #endif