Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentFilePoseInputStream.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 src/core/import_pose/pose_stream/SilentFilePoseInputStream.hh
11 /// @brief
12 /// @author James Thompson
13 
14 // libRosetta headers
15 
16 #include <core/types.hh>
17 
19 
20 #include <core/pose/Pose.hh>
22 
25 #include <core/pose/util.hh>
26 
27 #include <utility/vector1.hh>
28 #include <utility/file/FileName.hh>
29 #include <utility/file/file_sys_util.hh>
30 
34 
35 #include <basic/Tracer.hh>
36 #include <basic/datacache/BasicDataCache.hh>
37 #include <basic/datacache/CacheableString.hh>
38 
39 #include <basic/options/option.hh>
40 #include <basic/options/keys/run.OptionKeys.gen.hh>
41 
42 // C++ headers
43 #include <string>
44 
45 namespace core {
46 namespace import_pose {
47 namespace pose_stream {
48 
49 static basic::Tracer tr( "core.io.pose_stream" );
50 
51 typedef std::string string;
53 
55  tags_ = tags;
56 }
57 
60 ) {
62  // read in SilentStruct objects from all of the filenames
64  current_position_ = sfd_->begin();
65 }
66 
68 {
69  current_position_ = sfd_->begin();
70 }
71 
72 /////////////////////////////////////////////////////
73 void
76 ) {
77  sfd_ = sfd;
78 
79  filenames_.clear();
80 
81  if ( renumber_decoys() ) {
82  tr.Debug << "renumbering decoys." << std::endl;
83  sfd_->renumber_all_decoys();
84  }
85 
86  if ( order_by_energy_ ) {
87  tr.Debug << "ordering by energy" << std::endl;
88  sfd_->order_by_energy();
89  }
90 
91  current_position_ = sfd_->begin();
92  tags_ = sfd_->tags();
93 }
94 
95 void SilentFilePoseInputStream::renumber_decoys( bool const setting ) {
96  renumber_decoys_ = setting;
97 }
98 
100  return filenames_;
101 }
102 
104  return tags_;
105 }
106 
108  return renumber_decoys_;
109 }
110 
112  return energy_cut_;
113 }
114 
116  if ( current_position_ != sfd_->end() ) {
117  return true;
118  } else {
119  return false;
120  }
121 }
122 
124  core::pose::Pose & pose,
125  core::chemical::ResidueTypeSet const & residue_set
126 ) {
127  // check to make sure that we have more poses!
128  if ( !has_another_pose() ) {
129  utility_exit_with_message(
130  "SilentFilePoseInputStream: called fill_pose, but I have no more Poses!"
131  );
132  }
133 
134  using namespace basic::options;
135  using namespace basic::options::OptionKeys;
136  if ( option[ run::debug ]() ) {
137  core::Real debug_rmsd = current_position_->get_debug_rmsd();
138  tr.Debug << "RMSD to original coordinates for tag "
139  << current_position_->decoy_tag() << " = " << debug_rmsd << std::endl;
140  }
141 
142  current_position_->fill_pose( pose, residue_set );
143  // set up a tag using decoy_tag from SilentStruct
144  pose.data().set(
146  new basic::datacache::CacheableString( current_position_->decoy_tag() )
147  );
148  tr.Debug << "decoy_tag() == " << current_position_->decoy_tag() << std::endl;
149 
150  core::pose::setPoseExtraScores( pose, "silent_score", current_position_->get_energy( "score" ) );
151 
152  preprocess_pose( pose );
153 
155 } // fill_pose
156 
158  core::pose::Pose & pose
159 ) {
160  // check to make sure that we have more poses!
161  if ( !has_another_pose() ) {
162  utility_exit_with_message(
163  "SilentFilePoseInputStream: called fill_pose, but I have no more Poses!"
164  );
165  }
166 
167  using namespace basic::options;
168  using namespace basic::options::OptionKeys;
169  if ( option[ run::debug ]() ) {
170  core::Real debug_rmsd = current_position_->get_debug_rmsd();
171  tr.Debug << "RMSD to original coordinates for tag "
172  << current_position_->decoy_tag() << " = " << debug_rmsd << std::endl;
173  }
174 
175  current_position_->fill_pose( pose );
176  // set up a tag using decoy_tag from SilentStruct
177  pose.data().set(
179  new basic::datacache::CacheableString( current_position_->decoy_tag() )
180  );
181  tr.Debug << "decoy_tag() == " << current_position_->decoy_tag() << std::endl;
182 
183  core::pose::setPoseExtraScores( pose, "silent_score", current_position_->get_energy( "score" ) );
184 
185  preprocess_pose( pose );
186 
188 } // fill_pose
189 
190 
191 
194 {
195  // check to make sure that we have more poses!
196  if ( !has_another_pose() ) {
197  utility_exit_with_message(
198  "SilentFilePoseInputStream: called next_struct, but I have no more structs!"
199  );
200  }
201 
204  return silent_struct;
205 } // fill_pose
206 
207 
209  static basic::Tracer tr("core.io.pose_stream.silent");
210  using utility::vector1;
211 
212  if (record_source_) sfd_->set_record_source( true );
213 
214  for ( vector1< FileName >::const_iterator current_fn_ = filenames_.begin();
215  current_fn_ != filenames_.end(); ++current_fn_
216  ) {
217 
218  if ( !file_exists( *current_fn_ ) ) {
219  tr.Error << "Hey! Could not find " + std::string(*current_fn_)
220  << std::endl;
221  continue;
222  }
223 
224  tr.Debug << "reading " << *current_fn_ << std::endl;
225  if ( tags_.size() > 0 ) {
226  sfd_->read_file( *current_fn_, tags_ );
227  } else {
228  sfd_->read_file( *current_fn_ );
229  }
230  }
231 
232  if ( renumber_decoys() ) {
233  tr.Debug << "renumbering decoys." << std::endl;
234  sfd_->renumber_all_decoys();
235  }
236 
237  if ( energy_cut() != 1.0 ) {
238  sfd_->score_filter( energy_cut() );
239  }
240 
241  if ( order_by_energy_ ) {
242  tr.Debug << "ordering by energy" << std::endl;
243  sfd_->order_by_energy();
244  }
245 }
246 
247 void
249  order_by_energy_ = setting;
250 }
251 
252 void
254  record_source_ = setting;
255 }
256 
257 } // pose_stream
258 } // import_pose
259 } // core