Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JobOutputter.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/jd2/JobOutputter.cc
12 /// @brief August 2008 job distributor as planned at RosettaCon08 - Base class JobOutputter
13 /// @author Steven Lewis smlewi@gmail.com
14 
15 // Unit headers
17 
18 // package headers
19 #include <protocols/jd2/Job.hh>
22 #include <protocols/jd2/util.hh>
23 
24 // Project headers
27 
28 // Utility headers
29 #include <utility/file/FileName.hh>
30 #include <utility/file/file_sys_util.hh>
31 #include <utility/string_util.hh>
32 
33 
34 #include <basic/options/option.hh>
35 #include <basic/MemTracer.hh>
36 
37 
38 // option key includes
39 
40 #include <basic/options/keys/out.OptionKeys.gen.hh>
41 
42 #include <utility/vector1.hh>
43 
44 
45 ///C++ headers
46 //#include <string> //in the .hh anyway
47 
48 namespace protocols {
49 namespace jd2 {
50 
51 JobOutputter::JobOutputter() : evaluators_(new protocols::evaluation::PoseEvaluators()) {
53  basic::mem_tr << "JobOutputter CSTOR" << std::endl;
54 }
55 
57 
58 ///base implementation does nothing
60 
61 ///@details this is copied from protocols/jobdist/Jobs.cc, r24761
62 /// Checks the current JobInputter input source from the singleton instance of
63 /// JobDistributor. If a PDB_FILE, it will deliberately discard any path
64 /// information in the input tag as well as any file name extension (since
65 /// input tags are usually file names). Otherwise, it will keep the entire input
66 /// tag as-is.
68  using basic::options::option;
69  using namespace basic::options::OptionKeys;
70 
71  // Use at least 4 digits in number to match Rosetta++
72  core::Size nstruct_width = 0;
73  core::Size const nstruct = job->nstruct_max();
74  for ( core::Size i = 1; i <= nstruct || nstruct_width < 4; i *= 10 ) {
75  nstruct_width += 1;
76  }
77 
78  // Construct the base name. For pdb files we need to hack away the paths
79  // and extensions. For all other types of input sources, assume that the
80  // string that comes in is exactly the tag we want. This is important
81  // for silent file <-> BOINC usage to avoid problems with duplicate tags
82  // caused by path/ext removal.
83  std::string base_name = job->input_tag();
84  switch ( JobDistributor::get_instance()->job_inputter_input_source() ) {
85  case JobInputterInputSource::PDB_FILE : { // remove paths and ext.
86 
87  // Treat tags as file names so that we put the number before the extension.
89  utility::file::FileName out_name = utility::file::combine_names( temp_out_names );
90  base_name = out_name.base();
91 
92  break;
93  }
94 
95  default : { // do nothing
96  break;
97  }
98  }
99 
100  // now construct the full name
101  std::ostringstream oss;
102  std::string prefix( option[ out::prefix ].value() );
103  if ( job->status_prefix().size() ) {
104  prefix = job->status_prefix()+"_";
105  }
106  oss << prefix << base_name << option[ out::suffix ].value();
107  if ( ! option[ out::no_nstruct_label ] || job->nstruct_index() != 1 ) {
108  oss << '_' << std::setfill('0') << std::setw(nstruct_width) << job->nstruct_index();
109  }
110  return oss.str();
111 }
112 
113 
114 ///@details run the PoseEvaluators on the pose
115 /// evaluation creates string value pairs which end up in the SilentStruct energy object
116 /// instead of filling things into a SilentStruct we could provide a different interface...
117 /// wait until Steven has finished his string/value pair output
119  core::pose::Pose & pose,
120  std::string tag,
122 ) const {
123  if ( evaluators()->size() ) {
124  evaluators()->apply( pose, tag, pss );
125  }
126 }
127 
128 ///@brief optionally pass a starting (reference) pose to a JobOutputter for comparison purposes and/or as interface for initializing evaluators. (Currently does nothing in this base class.)
130 
131 ///@details add another PoseEvaluator to the list of evaluations
133  evaluators_->add_evaluation( ev_in );
134 }
135 
136 ///@details set a list of Evaluations
137 /// ( the list will be copied, the evaluations are OPs )
138 ///
141 }
142 
143 /// @brief clear the list of evaluators
145  evaluators_->clear();
146 }
147 
148 /// @details return the list of PoseEvaluators
150  return evaluators_;
151 }
152 
153 
154 } // jd2
155 } // protocols