Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResfileReader.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 core/pack/task/ResfileReader.hh
11 /// @brief header of classes for resfile options
12 /// @author Steven Lewis
13 /// @author Andrew Leaver-Fay
14 
15 #ifndef INCLUDED_core_pack_task_ResfileReader_hh
16 #define INCLUDED_core_pack_task_ResfileReader_hh
17 
18 // Unit Headers
20 
21 // Package Headers
24 #include <core/pose/Pose.fwd.hh>
25 
26 // Project Headers
27 #include <core/types.hh>
28 #include <core/chemical/AA.hh>
29 
30 // Utility Headers
31 #include <utility/vector1.hh>
32 #include <utility/pointer/ReferenceCount.hh>
33 
34 
35 // STL Headers
36 #include <iosfwd>
37 #include <list>
38 #include <map>
39 #include <string>
40 
41 
42 
43 namespace core {
44 namespace pack {
45 namespace task {
46 
47 
48 
50 {
51 
52 public:
53 
55  message_ = message;
56  }
57 
59  return message_;
60  }
61 
62 private:
64 };
65 
67 {
68 public:
69 
70  ResfileContents( pose::Pose const & pose, std::istream & istream );
71  virtual ~ResfileContents();
72 
73  std::list< ResfileCommandCOP > const &
74  default_commands() const;
75 
76  bool specialized_commands_exist_for_residue( Size resid ) const;
77 
78  std::list< ResfileCommandCOP > const &
79  commands_for_residue( Size resid ) const;
80 
81 private: // helper types and functions for parsing
82 
87  };
88 
89  void
91  utility::vector1< std::string > const & tokens,
92  std::map< std::string, ResfileCommandOP > const & command_map,
93  Size const lineno,
94  bool & have_read_start_token);
95 
96  void
98  pose::Pose const & pose,
99  utility::vector1< std::string > const & tokens,
100  std::map< std::string, ResfileCommandOP > const & command_map,
101  Size const lineno,
102  utility::vector1< std::list< ResfileCommandOP > > & residue_range_commands,
103  utility::vector1< std::list< ResfileCommandOP > > & residue_chain_commands);
104 
105  void
106  parse_resid(
107  Size & which_token,
108  utility::vector1< std::string > const & tokens,
109  Size const lineno,
110  int & PDBnum,
111  int & PDBnum_end, // only defined for RANGE id_type
112  char & icode,
113  char & icode_end, // only defined for RANGE id_type
114  char & chain,
115  residue_identifier_type & id_type) const;
116 
117  void
119  std::string const & token,
120  Size const lineno,
121  int & PDBnum,
122  char & icode) const;
123 
124  Size
125  locate_resid(
126  core::pose::Pose const & pose,
127  char const chain,
128  Size const PDBnum,
129  char const icode,
130  Size const lineno) const;
131 
134  Size const which_token,
135  utility::vector1< std::string > const & tokens,
136  std::map< std::string, ResfileCommandOP > const & command_map,
137  Size const lineno) const;
138 
139 private:
140  std::list< ResfileCommandCOP > default_commands_;
142 };
143 
144 ///@brief abstract/interface class for Resfile reader command objects
146 {
147 public:
148  ///@brief Automatically generated virtual destructor for class deriving directly from ReferenceCount
149  virtual ~ResfileCommand();
150  virtual ResfileCommandOP clone() const = 0;
151 
152  // @brief Read the contents of the Resfile and store the state
153  virtual
155  utility::vector1< std::string > const & tokens,
156  Size & which_token,
157  Size resid
158  ) = 0;
159 
160  ///@brief Modify the packer task with the command that was read in
161  virtual
162  void residue_action(
163  PackerTask &,
164  Size resid
165  ) const = 0;
166 
167 };
168 
169 ///////////////////////////////////////////////////////////////////////
170 //In this section, list mode-style options (NATAA, etc)
171 
172 ///@brief NATRO disables packing and designing at a position, the residue
173 ///will be totally unchanged
174 class NATRO : public ResfileCommand
175 {
176 public:
177  virtual ResfileCommandOP clone() const { return new NATRO; }
178 
179  virtual
181  utility::vector1< std::string > const & tokens,
182  Size & which_token,
183  Size resid
184  );
185 
186  virtual
187  void residue_action(
188  PackerTask &,
189  Size resid
190  ) const;
191 
192  static std::string name() {return "NATRO";}
193 };
194 
195 ///@brief NATAA allows repacking but no sequence changes (all rotamers are of the original residue)
196 class NATAA : public ResfileCommand
197 {
198 public:
199  virtual ResfileCommandOP clone() const { return new NATAA; }
200 
201  virtual
203  utility::vector1< std::string > const & tokens,
204  Size & which_token,
205  Size resid
206  );
207 
208  virtual
209  void residue_action(
210  PackerTask &,
211  Size resid
212  ) const;
213 
214  static std::string name() {return "NATAA";}
215 };
216 
217 ///@brief ALLAA is deprecated; allows repacking and designing to any canonical residue (default state of PackerTask)
218 class ALLAA : public ResfileCommand
219 {
220 public:
221  virtual ResfileCommandOP clone() const { return new ALLAA; }
222 
223  virtual
225  utility::vector1< std::string > const & tokens,
226  Size & which_token,
227  Size resid
228  );
229 
230  virtual
231  void residue_action(
232  PackerTask &,
233  Size resid
234  ) const;
235 
236  static std::string name() {return "ALLAA";}
237 };
238 
239 ///@brief ALLAAxc allows repacking and designing to any canonical noncysteine residue
240 class ALLAAxc : public ResfileCommand
241 {
242 public:
243  virtual ResfileCommandOP clone() const { return new ALLAAxc; }
244 
245  virtual
247  utility::vector1< std::string > const & tokens,
248  Size & which_token,
249  Size resid
250  );
251 
252  virtual
253  void residue_action(
254  PackerTask &,
255  Size resid
256  ) const;
257 
258  static std::string name() {return "ALLAAXC";}
259 };
260 
261 ///@brief allows repacking and designing to any canonical residue (default state of PackerTask)
262 class ALLAAwc : public ResfileCommand
263 {
264 public:
265  virtual ResfileCommandOP clone() const { return new ALLAAwc; }
266 
267  virtual
269  utility::vector1< std::string > const & tokens,
270  Size & which_token,
271  Size resid
272  );
273 
274  virtual
275  void residue_action(
276  PackerTask &,
277  Size resid
278  ) const;
279 
280  static std::string name() {return "ALLAAWC";}
281 };
282 
283 ///@brief PIKAA allows residues specifed in a following string and packing
284 class PIKAA : public ResfileCommand
285 {
286 public:
287  virtual ResfileCommandOP clone() const { return new PIKAA; }
288 
289  virtual
291  utility::vector1< std::string > const & tokens,
292  Size & which_token,
293  Size resid
294  );
295 
296  virtual
297  void residue_action(
298  PackerTask &,
299  Size resid
300  ) const;
301 
302  static std::string name() {return "PIKAA";}
303 private:
305  std::list< chemical::AA > na_allowed_; // nucleic acids which are allowed.
306 };
307 
308 ///@brief PIKNA allows nucleic acid residues specifed in a following string
309 class PIKNA : public ResfileCommand
310 {
311 public:
312  virtual ResfileCommandOP clone() const { return new PIKNA; }
313 
314  virtual
316  utility::vector1< std::string > const & tokens,
317  Size & which_token,
318  Size resid
319  );
320 
321  virtual
322  void residue_action(
323  PackerTask &,
324  Size resid
325  ) const;
326 
327  static std::string name() {return "PIKNA";}
328 private:
330 };
331 
332 ///@brief PIKRNA allows nucleic acid residues specifed in a following string
333 class PIKRNA : public ResfileCommand
334 {
335 public:
336  virtual ResfileCommandOP clone() const { return new PIKRNA; }
337 
338  virtual
340  utility::vector1< std::string > const & tokens,
341  Size & which_token,
342  Size resid
343  );
344 
345  virtual
346  void residue_action(
347  PackerTask &,
348  Size resid
349  ) const;
350 
351  static std::string name() {return "PIKRNA";}
352 private:
354 };
355 
356 ///@brief NOTAA disallows residues specified in a following string, and allows packing
357 class NOTAA : public ResfileCommand
358 {
359 public:
360  virtual ResfileCommandOP clone() const { return new NOTAA; }
361 
362  virtual
364  utility::vector1< std::string > const & tokens,
365  Size & which_token,
366  Size resid
367  );
368 
369  virtual
370  void residue_action(
371  PackerTask &,
372  Size resid
373  ) const;
374 
375  static std::string name() {return "NOTAA";}
376 private:
378 };
379 
380 ///@brief EMPTY disallows all canonical residues but leaves packing and designing unchanged (for noncanonicals)
381 class EMPTY : public ResfileCommand
382 {
383 public:
384  virtual ResfileCommandOP clone() const { return new EMPTY; }
385 
386  virtual
388  utility::vector1< std::string > const & tokens,
389  Size & which_token,
390  Size resid
391  );
392 
393  virtual
394  void residue_action(
395  PackerTask &,
396  Size resid
397  ) const;
398 
399  static std::string name() {return "EMPTY";}
400 };
401 
402 ///@brief POLAR allows polar residues and packing
403 class POLAR : public ResfileCommand
404 {
405 public:
406  virtual ResfileCommandOP clone() const { return new POLAR; }
407 
408  virtual
410  utility::vector1< std::string > const & tokens,
411  Size & which_token,
412  Size resid
413  );
414 
415  virtual
416  void residue_action(
417  PackerTask &,
418  Size resid
419  ) const;
420 
421  static std::string name() {return "POLAR";}
422 
423 };
424 
425 ///@brief APOLAR allows nonpolar residues and packing
426 class APOLAR : public ResfileCommand
427 {
428 public:
429  virtual ResfileCommandOP clone() const { return new APOLAR; }
430 
431  virtual
433  utility::vector1< std::string > const & tokens,
434  Size & which_token,
435  Size resid
436  );
437 
438  virtual
439  void residue_action(
440  PackerTask &,
441  Size resid
442  ) const;
443 
444  static std::string name() {return "APOLAR";}
445 };
446 
447 ///@brief APOLA is deprecated, it calls APOLAR to allow nonpolar residues and packing
448 class APOLA : public ResfileCommand
449 {
450 public:
451  virtual ResfileCommandOP clone() const { return new APOLA; }
452 
453  virtual
455  utility::vector1< std::string > const & tokens,
456  Size & which_token,
457  Size resid
458  );
459 
460  virtual
461  void residue_action(
462  PackerTask &,
463  Size resid
464  ) const;
465 
466  static std::string name() {return "APOLA";}
467 };
468 
469 ////////end of mode-style options////////////////////////
470 
471 ////////in this section list other options///////////////
472 
473 ///@brief EX handles the various extrachi options
474 class EX : public ResfileCommand
475 {
476 public:
477  virtual ResfileCommandOP clone() const { return new EX; }
478 
479  virtual
481  utility::vector1< std::string > const & tokens,
482  Size & which_token,
483  Size resid
484  );
485 
486  virtual
487  void residue_action(
488  PackerTask &,
489  Size resid
490  ) const;
491 
492  static std::string name() {return "EX";}
493 private:
497 };
498 
499 ///@brief NC handles explicit allowance of noncanonical residue types
500 class NC : public ResfileCommand
501 {
502 public:
503  virtual ResfileCommandOP clone() const { return new NC; }
504 
505  virtual
507  utility::vector1< std::string > const & tokens,
508  Size & which_token,
509  Size resid
510  );
511 
512  virtual
513  void residue_action(
514  PackerTask &,
515  Size resid
516  ) const;
517 
518  static std::string name() {return "NC";}
519 private:
521 };
522 
523 ///@brief EX_CUTOFF allows setting of the extrachi_cutoff (for determining burial for extra rotamers)
524 class EX_CUTOFF : public ResfileCommand
525 {
526 public:
527  virtual ResfileCommandOP clone() const { return new EX_CUTOFF; }
528 
529  virtual
531  utility::vector1< std::string > const & tokens,
532  Size & which_token,
533  Size resid
534  );
535 
536  virtual
537  void residue_action(
538  PackerTask &,
539  Size resid
540  ) const;
541 
542  static std::string name() {return "EX_CUTOFF";}
543 
544 private:
546 };
547 
548 ///@brief USE_INPUT_SC turns on inclusion of the current rotamer for the packer
550 {
551 public:
552  virtual ResfileCommandOP clone() const { return new USE_INPUT_SC; }
553 
554  virtual
556  utility::vector1< std::string > const & tokens,
557  Size & which_token,
558  Size resid
559  );
560 
561  virtual
562  void residue_action(
563  PackerTask &,
564  Size resid
565  ) const;
566 
567  static std::string name() {return "USE_INPUT_SC";}
568 };
569 
570 ///@brief AUTO suggests that a packer can/should reconsider the design setting at a/each residue
571 ///@details This is a protocol-level flag to be used in non-vanilla packers. For example, one may want an ALLAA tag to be effective only if the residue is in an automatically-determined region of interest, without knowing which residues qualify a-priori
572 ///@author ashworth
573 class AUTO : public ResfileCommand
574 {
575 public:
576  virtual ResfileCommandOP clone() const { return new AUTO; }
577 
578  virtual
580  utility::vector1< std::string > const & tokens,
581  Size & which_token,
582  Size resid
583  );
584 
585  virtual
586  void residue_action(
587  PackerTask &,
588  Size resid
589  ) const;
590 
591  static std::string name() {return "AUTO";}
592 };
593 
594 ///@brief SCAN suggests to some packing routines that if there are multiple type choices for this residue, then each of them should be considered explicitly in one way or another
595 ///@details This is a protocol-level flag to be used in non-vanilla packers
596 ///@author ashworth
597 class SCAN : public ResfileCommand
598 {
599 public:
600  virtual ResfileCommandOP clone() const { return new SCAN; }
601 
602  virtual
604  utility::vector1< std::string > const & tokens,
605  Size & which_token,
606  Size resid
607  );
608 
609  virtual
610  void residue_action(
611  PackerTask &,
612  Size resid
613  ) const;
614 
615  static std::string name() {return "SCAN";}
616 };
617 
618 ///@brief TARGET flags the position as "targeted", and can optionally specify a "targeted" type
619 ///@details This is a protocol-level flag to be used in non-vanilla packers--positions flagged as "targeted" may be treated in a special fashion
620 ///
621 /// The optional specification of a target type is be useful for multistate considerations:
622 /// multistate protocols need 1) rotamers and energies for all possible states, and 2) a target state
623 /// The target type must be a member of PackerTask's allowed_types_
624 ///
625 ///@author ashworth
626 class TARGET : public ResfileCommand
627 {
628 public:
629  virtual ResfileCommandOP clone() const { return new TARGET; }
630 
631  virtual
633  utility::vector1< std::string > const & tokens,
634  Size & which_token,
635  Size resid
636  );
637 
638  virtual
639  void residue_action(
640  PackerTask &,
641  Size resid
642  ) const;
643 
644  static std::string name() {return "TARGET";}
645 private:
647 };
648 
649 ///@brief NO_ADDUCTS will disable adducts, assuming they exist
650 ///@detailed This command exists because if adducts exist, then they are enabled by default for all residues.
651 ///@author ashworth
653 {
654 public:
655  virtual ResfileCommandOP clone() const { return new NO_ADDUCTS; }
656 
657  virtual
659  utility::vector1< std::string > const & tokens,
660  Size & which_token,
661  Size resid
662  );
663 
664  virtual
665  void residue_action(
666  PackerTask &,
667  Size resid
668  ) const;
669 
670  static std::string name() {return "NO_ADDUCTS";}
671 };
672 
673 ///@brief FIX_HIS_TAUTOMER: when a histidine is present when the PackerTask is initialized, this flag will fix its tautomer (whether its hydrogen is on ND1 or NE2. Does nothing if not histidine at initialization (meaning if it mutates to histidine later this flag will have no effect).
675 {
676 public:
677  virtual ResfileCommandOP clone() const { return new FIX_HIS_TAUTOMER; }
678 
679  virtual
681  utility::vector1< std::string > const & tokens,
682  Size & which_token,
683  Size resid
684  );
685 
686  virtual
687  void residue_action(
688  PackerTask &,
689  Size resid
690  ) const;
691 
692  static std::string name() {return "FIX_HIS_TAUTOMER";}
693 };
694 
695 ///////////end of other options//////////////////////////
696 ///////////utility functions for resfile reader//////////
697 
698 ///@brief utility function to increment next token to be parsed
700 get_token(
701  const Size which_token,
702  const utility::vector1<std::string> & tokens,
703  const bool make_upper_case = true);
704 
705 ///@brief utility function for resfile reader
707 tokenize_line( std::istream & inputstream );
708 
709 ///@brief utility for resfile reader, commands MUST be entered into this hard-coded map
710 std::map< std::string, ResfileCommandOP >
712 
713 ///@brief utility function for resfile reader (checks for a leading # signaling a comment)
714 bool
715 comment_begin( utility::vector1< std::string > const & tokens, Size which_token );
716 
717 ///@brief changes the state of the given PackerTask according to the commands in the resfile at read in from the -pack:resfile option system.
718 void
720  pose::Pose const & pose,
721  PackerTask & the_task);
722 
723 ///@brief changes the state of the given PackerTask according to the commands in the resfile at filename
724 void
726  pose::Pose const & pose,
727  PackerTask & the_task,
729 
730 ///@brief changes the state of the given PackerTask according to the commands in the resfile.
731 void
733  pose::Pose const & pose,
734  PackerTask & the_task,
735  std::string const & resfile_string ) throw(ResfileReaderException);
736 
737 void
738 onError( std::string message );
739 
740 
741 }//namespace task
742 }//namespace pack
743 }//namespace core
744 
745 #endif