Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Job.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 protocols/jd2/Job.hh
11 /// @brief header file for Job classes, part of August 2008 job distributor as planned at RosettaCon08. This file is responsible for three ideas: "inner" jobs, "outer" jobs (with which the job distributor works) and job container (currently just typdefed in the .fwd.hh)
12 /// @author Steven Lewis smlewi@gmail.com
13 
14 #ifndef INCLUDED_protocols_jd2_Job_hh
15 #define INCLUDED_protocols_jd2_Job_hh
16 
17 //unit headers
18 #include <protocols/jd2/Job.fwd.hh>
19 // AUTO-REMOVED #include <protocols/jd2/InnerJob.fwd.hh>
20 
21 //project headers
22 #include <core/pose/Pose.fwd.hh>
23 
24 //utility headers
25 #include <utility/pointer/ReferenceCount.hh>
26 #include <core/types.hh>
27 
28 //C++ headers
29 #include <string>
30 #include <list>
31 #include <map>
32 
33 #include <utility/vector1.hh>
34 
35 
36 namespace protocols {
37 namespace jd2 {
38 
39 /// @details The Job class is directly used by the job distributor. It contains
40 /// an index into nstruct and a lightweight pointer to an InnerJob (to share
41 /// those heavier classes). It also directly contains job-associated output
42 /// data. The idea here is that your scores, etc are associated with the job,
43 /// not with a particular pose within that running job. Thus, the Job object is
44 /// a better place to store them than the pose.
46 {
47 public:
48 
49  /// TODO these should be maps rather than lists.
50  typedef std::list< std::string > Strings;
51  typedef std::list< std::pair< std::string, std::string > > StringStringPairs;
52  typedef std::map< std::string, core::Real > StringRealPairs;
53 
55 
56  /// @brief returns a copy of this object whose "output fields" are zeroed
57  /// out. Used by the JobDistributor in cases where the job fails and must be
58  /// retried to prevent accumulation of Job state after a failure. This
59  /// implementation was chosen over a clear_all_output function to prevent
60  /// mover A from deleting mover B's hard work! You probably should not be
61  /// trying to call this function. The exception: If you want an
62  /// intermediate-output pose (not the final pose) to not have the aggregated
63  /// accessory data in the "real" Job object.
64  JobOP copy_without_output() const;
65 
66  virtual ~Job();
67 
68  ///@brief Note: only compare if the pointers to the poses are to the
69  ///same location
70  friend
71  bool
72  operator==(Job const & a, Job const & b);
73 
74  friend
75  bool
76  operator!=(Job const & a, Job const & b);
77 
78 
79  virtual
80  void
81  show( std::ostream & out ) const;
82 
83  friend
84  std::ostream &
85  operator<< ( std::ostream & out, const Job & job );
86 
87 
88  ///@brief access to inner-job ... use is discouraged - use sparingly!
89  /// --- DO NOT use my_job->inner_job()->get_pose()
90  /// INSTEAD use my_job->get_pose()
91  InnerJobCOP inner_job() const;
92 
93  ///@brief return the input tag (a short string, generally)
94  std::string const & input_tag() const;
95 
96  ///@brief nonconst access is intended only for the JobInputter to load poses into the InnerJob, and the Parser to add constraints, and the JobDistributor to delete completed inputs (recycle memory)
98 
99  ///get_pose : will return
100  // 1) a pose saved in Job-Object ... if available
101  // 2) re-route the call to the JobInputter::pose_from_job
102 
103  ///@brief return a COP to the input pose
105 
106  ///@brief in-place copy of input pose
107  void get_pose( core::pose::Pose& ) const;
108 
109  core::Size nstruct_index() const;
110 
111  ///@brief
112  core::Size nstruct_max() const;
113 
114  ///////////////////////////THIS SECTION OF FUNCTIONS IS MEANT TO BE USED BY MOVERS/////////////////////////////
115  //It is safe to call these functions even in the absence of a job distributor - it will store the data in a dummy object. You are not making your protocol dependent on JD2 by using these functions (although this extra output might get "lost" if you do not emit it by another method like the Tracers.) -- SML 10/20/11
116  //functions for loading output info into the job
117  ///@brief add an output string
118  void add_string( std::string const & string_in );
119 
120  ///@brief add output strings
121  void add_strings( Strings const & );
122 
123  ///@brief add a string/string pair
124  void add_string_string_pair( std::string const & string1, std::string const & string2 );
125 
126  ///@brief add a string/real pair
127  void add_string_real_pair( std::string const & string_in, core::Real const real_in );
128 
129 
130  ////////////////////THIS SECTION OF FUNCTIONS IS FORBIDDEN FOR USE BY MOVERS//////////////////////////////////
131  //If Movers try to use these functions, those Movers become tied to JD2 and may fail if JD2 is not present (because there will be no data in these strings). To prevent this, DO NOT CALL these functions from within Movers. SML 10/20/11
132 
133  //functions for returning output info from the job. You get iterators so that this interface can stay constant as the underlying implementation changes
134  Strings::const_iterator output_strings_begin() const;
135  Strings::const_iterator output_strings_end() const;
136 
137  StringStringPairs::const_iterator output_string_string_pairs_begin() const;
138  StringStringPairs::const_iterator output_string_string_pairs_end() const;
139 
140  StringRealPairs::const_iterator output_string_real_pairs_begin() const;
141  StringRealPairs::const_iterator output_string_real_pairs_end() const;
142 
143  ////////////////////////END SECTION//////////////////////////////////////////////////////////////////
144 
145  //there are no functions for deleting output info. This is on purpose - use copy_without_output instead
146 
148  status_prefix_ = prefix;
149  }
150 
151  std::string const& status_prefix() const {
152  return status_prefix_;
153  }
154 
155  bool completed() const {
156  return completed_;
157  }
158 
159  bool to_do() const {
160  return !completed_ && !bad();
161  }
162 
163  bool bad() const;
164 
165  void set_completed(bool value = true) {
166  completed_ = value;
167  }
168 
169  void set_bad(bool value = true);
170 
171 private:
172  //InnerJobCOP inner_job() const;
173  //bookkeeping data
174  ///@brief a pointer to the "heavy" InnerJob which maintains the starting pose for the job (shared across nstruct)
176  ///@brief which nstruct is this?
178 
180 
181  /// the following block of data makes the Job class pretty heavy. If we create thousands of Jobs this can be a problem...
182  // put these into an extra class and store a pointer ... NULL if nothing has been stored yet?
183  // cleanup after job is written to output... OL 6/2/09
184  //Storage units for output data
185  ///@brief used for arbitrary string data (stuff you've preformatted). Intended to be appended to the end of a PDB or dumped to a tracer if not in a PDB output mode.
187  ///@brief string-string pairs. Inserted into SCORE: lines in scorefiles/silentfiles.
189  ///@brief string-real pairs (scoretype/score pairs). Inserted into SCORE: lines in scorefiles/silentfiles
191 
192  ///@brief container of evaluators
193  //Oliver??
194 
196 
197 }; // Job
198 
199 extern JobOP const JD2_BOGUS_JOB;
200 
201 } // namespace jd2
202 } // namespace protocols
203 
204 
205 
206 #endif //INCLUDED_protocols_jd2_Job_HH