Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LazySilentFileJobInputter.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/LazySilentFileJobInputter.cc
11 /// @brief
12 /// @author
13 
16 #include <protocols/jd2/Job.hh>
18 
19 #include <core/pose/Pose.hh>
20 #include <core/pose/util.hh>
21 
22 #include <basic/Tracer.hh>
23 #include <basic/options/option.hh>
24 #include <utility/file/FileName.hh>
25 #include <utility/vector1.hh>
26 #include <utility/exit.hh>
27 
28 ///C++ headers
29 #include <string>
30 
31 
32 #include <basic/options/keys/in.OptionKeys.gen.hh>
33 
34 //Auto Headers
35 
36 
37 static basic::Tracer tr("protocols.jd2.LazySilentFileJobInputter");
38 
39 namespace protocols {
40 namespace jd2 {
41 
43  {
44  tr.Debug << "instantiating LazySilentFileJobInputter" << std::endl;
45  }
46 
48 
49 
50  void
52  using namespace utility;
53  using namespace core;
54  using namespace basic::options;
55 
56  tr.Debug << "LazySilentFileJobInputter::fill_jobs" << std::endl;
57 
58  utility::vector1< file::FileName > const silent_files( option[ OptionKeys::in::file::silent ]() );
60 
61  // This code appears to suggest that it will work for multiple files - alas
62  // it doesnt. It only saves the tag names not the file names so ALL the tags
63  // will be attempted to be read from the first file.
64  // I added this assert here to so that the user doesnt accidentally try
65  // feedign through multiple files.
66  runtime_assert( silent_files.size() <= 1 );
67 
68  for ( vector1< file::FileName >::const_iterator current_fn_ = silent_files.begin();
69  current_fn_ != silent_files.end(); ++current_fn_
70  ) {
72  //core::Size startindex = tags.size();
73  sfd_.read_tags_fast( *current_fn_, filetags );
74 
75  for( core::Size jj = 1; jj <= filetags.size(); jj++ ) {
76  tags.push_back( filetags[jj] );
77  }
78  }
79 
80  core::Size const nstruct( get_nstruct() );
81 
82  using namespace core::io::silent;
84 
85  tr.Debug << "reserve memory for InnerJob List " << tags.size() << std::endl;
86  inner_jobs.reserve( tags.size() );
87  tr.Debug << "fill list with " << tags.size() << " InnerJob Objects" << std::endl;
88  for ( core::Size iter = 1; iter <= tags.size(); iter++ ) {
89  protocols::jd2::InnerJobOP ijob( new InnerJob( tags[iter], nstruct ));
90  inner_jobs.push_back( ijob );
91  }
92 
93  tr.Debug << "reserve list for " << inner_jobs.size() * nstruct << " Job Objects" << std::endl;
94  jobs.reserve( nstruct * inner_jobs.size() );
95 
96  tr.Debug << "fill job list with... " << std::endl;
97  for ( core::Size index = 1; index <= nstruct; ++index ) {
98  for ( utility::vector1< InnerJobOP >::const_iterator ijob = inner_jobs.begin(); ijob != inner_jobs.end(); ijob ++ ) {
99  jobs.push_back( protocols::jd2::JobOP( new Job( *ijob, index ) ) );
100  tr.Trace << "pushing " << (*ijob)->input_tag() << " nstruct index " << index << std::endl;
101  } // loop over nstruct
102  } // loop over inputs
103  } // fill_jobs
104 
105 
106 
107 
110  using namespace basic::options;
111  utility::vector1<std::string> tag_to_read;
112  tag_to_read.push_back( job->inner_job()->input_tag());
113 
114  if ( !sfd_.read_file( (option[ OptionKeys::in::file::silent ]()[1]).name(), tag_to_read ) ) {
115  utility_exit_with_message(" job with input tag " + job->inner_job()->input_tag() +" can't find his input structure ");
116  }
117  return sfd_.get_structure( job->inner_job()->input_tag() );
118  }
119 
120 
121  void
123  JobOP job
124  ) {
125  tr.Debug << "LazySilentFileJobInputter::pose_from_job" << std::endl;
126 
127  if ( !job->inner_job()->get_pose() ) {
128  tr.Debug << "filling pose from SilentFile (tag = " << job->inner_job()->input_tag()
129  << ")" << std::endl;
130  pose.clear();
131  struct_from_job( job ).fill_pose( pose );
132  tag_into_pose( pose, job->inner_job()->input_tag() );
133  } else {
134  pose.clear();
135  pose = *(job->inner_job()->get_pose());
136  tr.Debug << "filling pose from saved copy (tag = " << job->input_tag()
137  << ")" << std::endl;
138  }
139  }
140 
143  }
144 
145 //CREATOR SECTION
148 {
149  return "LazySilentFileJobInputter";
150 }
151 
154  return new LazySilentFileJobInputter;
155 }
156 
157 } //jd2
158 } ///protocols