Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentFileJobInputter.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/jd2/SilentFileJobInputter.cc
11 /// @brief
12 /// @author James Thompson
13 
14 ///Unit headers
17 #include <protocols/jd2/Job.hh>
19 
20 ///Project headers
21 #include <core/pose/Pose.hh>
22 #include <core/pose/util.hh>
23 
24 ///Utility headers
25 #include <basic/Tracer.hh>
26 #include <basic/options/option.hh>
27 #include <utility/vector1.hh>
28 #include <utility/file/FileName.hh>
29 
30 ///C++ headers
31 #include <string>
32 
33 // External headers
34 #include <boost/algorithm/string/predicate.hpp>
35 
36 // option key includes
37 #include <basic/options/keys/in.OptionKeys.gen.hh>
39 
40 static basic::Tracer tr("protocols.jd2.SilentFileJobInputter");
41 
42 namespace protocols {
43 namespace jd2 {
44 
46  // silent_files_( option[ in::file::silent ]() ) {
47 {
48  tr.Debug << "Instantiate SilentFileJobInputter" << std::endl;
49 }
50 
52 
53 
54  /// @brief this function returns the SilentStruct that belongs to the given job
57  if ( !sfd_.has_tag( job->inner_job()->input_tag() ) ) {
58  utility_exit_with_message(" job with input tag " + job->inner_job()->input_tag() +" can't find his input structure ");
59  }
60  return sfd_.get_structure( job->inner_job()->input_tag() );
61 }
62 
63 
64 /// @details This function will first see if the pose already exists in the Job.
65 /// If not, it will read it into the pose reference, and hand a COP cloned from
66 /// that pose to the Job. If the pose pre-exists it just copies the COP's pose
67 /// into it.
69  core::pose::Pose & pose,
70  JobOP job
71 ) {
72  tr.Debug << "SilentFileJobInputter::pose_from_job" << std::endl;
73 
74  if ( !job->inner_job()->get_pose() ) {
75  //core::import_pose::pose_from_pdb( pose, job->inner_job()->input_tag() );
76  // core::io::silent::SilentStructOP ss = sfd_[ job->inner_job()->input_tag() ];
77  tr.Debug << "filling pose from SilentFile (tag = " << job->inner_job()->input_tag()
78  << ")" << std::endl;
79  pose.clear();
80 
81  // kinda hacky fix for symmetry ... this should probably be added to Pose::clear()
82  if ( core::pose::symmetry::is_symmetric( pose ) ) {
84  }
85 
86  struct_from_job( job ).fill_pose( pose );
87  tag_into_pose( pose, job->inner_job()->input_tag() );
88 // if ( !sfd_.has_tag( job->inner_job()->input_tag() ) ) {
89 // utility_exit_with_message(" job with input tag " + job->inner_job()->input_tag() +" can't find his input structure ");
90 // }
91 // sfd_.get_structure( job->inner_job()->input_tag() ).fill_pose( pose );
92  // ss->fill_pose( pose );//, ChemicalManager::get_instance()->residue_type_set( FA_STANDARD ) );
93  // load_pose_into_job( pose, job ); //this is a HUGE memory leak... not really useful
94  // making structure from silent-structs doesn't take that long...
95  } else {
96  pose.clear();
97 
98  // kinda hacky fix for symmetry ... this should probably be added to Pose::clear()
99  // this will likely be overwritten in next assignment.... I move it further down OL 11/21/09
100  // if ( core::pose::symmetry::is_symmetric( pose ) ) {
101  // core::conformation::symmetry::make_asymmetric_pose( pose );
102  // }
103 
104  pose = *(job->inner_job()->get_pose());
105 
106  /// should this really be here? If there is a pose in the job-object it should have the right properties already, no?
107  if ( core::pose::symmetry::is_symmetric( pose ) ) {
109  }
110 
111  tr.Debug << "filling pose from saved copy (tag = " << job->input_tag()
112  << ")" << std::endl;
113  }
114 }
115 
116 /// @details this function determines what jobs exist from -in::file::silent and
117 /// -in::file::tags
119  tr.Debug << "SilentFileJobInputter::fill_jobs" << std::endl;
120 
121  jobs.clear(); //should already be empty anyway
122 
123  using std::string;
125  using utility::vector1;
126  using namespace basic::options;
127  using namespace basic::options::OptionKeys;
128 
129  utility::vector1< FileName > const silent_files( option[ in::file::silent ]() );
130 
131  for ( vector1< FileName >::const_iterator current_fn_ = silent_files.begin();
132  current_fn_ != silent_files.end(); ++current_fn_
133  ) {
134  tr.Debug << "reading " << *current_fn_ << std::endl;
135  if ( option[ in::file::tags ].user() ) {
136  utility::vector1< string > const& tags( option[ in::file::tags ]() );
137  sfd_.read_file( *current_fn_, tags );
138  } else {
139  sfd_.read_file( *current_fn_ );
140  }
141  }
142 
143  core::Size const nstruct( get_nstruct() );
144 
145  using namespace core::io::silent;
147 
148  //save list of all inner_jobs first... this allows better sampling of jobs in case of unfinished runs:
149  // input1_0001
150  // input2_0001
151  // ...
152  // inputn_0001
153  // input1_0002
154  // input2_0002
155  // ....
156  tr.Debug << "reserve memory for InnerJob List " << sfd_.size() << std::endl;
157  inner_jobs.reserve( sfd_.size() );
158  tr.Debug << "fill list with " << sfd_.size() << " InnerJob Objects" << std::endl;
159  for ( SilentFileData::iterator iter = sfd_.begin(), end = sfd_.end();
160  iter != end; ++iter
161  ) {
162  const std::string tag = iter->decoy_tag();
163 
164  // Optionally ignore failed simulations. Supporting protocols are not consistent
165  // in their support of this option. Abrelax, for example, writes models from
166  // failed simulations in centroid residue type set, despite the fact that
167  // fullatom was requested. This can lead to issues during clustering, rescoring,
168  // etc.
169  bool failed_simulation = boost::starts_with(tag, "W_");
170  if (failed_simulation && option[OptionKeys::in::file::skip_failed_simulations]()) {
171  continue;
172  }
173 
174  InnerJobOP ijob( new InnerJob( tag, nstruct ) );
175  inner_jobs.push_back( ijob );
176  }
177 
178  tr.Debug << "reserve list for " << inner_jobs.size() * nstruct << " Job Objects" << std::endl;
179  jobs.reserve( nstruct * inner_jobs.size() );
180 
181  tr.Debug << "fill job list with... " << std::endl;
182  for ( core::Size index = 1; index <= nstruct; ++index ) {
183  for ( utility::vector1< InnerJobOP >::const_iterator ijob = inner_jobs.begin(); ijob != inner_jobs.end(); ijob ++ ) {
184  jobs.push_back( JobOP( new Job( *ijob, index ) ) );
185  tr.Trace << "pushing " << (*ijob)->input_tag() << " nstruct index " << index << std::endl;
186  } // loop over nstruct
187  } // loop over inputs
188 } // fill_jobs
189 
190 /// @brief Return the type of input source that the SilentFileJobInputter is currently
191 /// using.
192 /// @return Always <em>SILENT_FILE</em>.
195 }
196 
197 //CREATOR SECTION
200 {
201  return "SilentFileJobInputter";
202 }
203 
206  return new SilentFileJobInputter;
207 }
208 
209 } // jd2
210 } // protocols