Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentFileInputter.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/inputter/SilentFileInputter.cc
11 /// @brief An inputter that takes a list of silent files
12 /// @author Ken Jung
13 
14 // Unit Headers
17 #include <core/pose/Pose.hh>
18 #include <utility/lua/LuaIterator.hh>
19 
20 #include <core/pose/util.hh>
21 #include <utility/string_util.hh>
22 // tracer
23 #include <basic/Tracer.hh>
24 
25 namespace protocols {
26 namespace inputter {
27 
28 static basic::Tracer TR("protocols.inputter.SilentFileInputter");
29 
30 #ifdef USELUA
31 void lregister_SilentFileInputter( lua_State * lstate ) {
32  lregister_Inputter( lstate );
33  luabind::module(lstate, "protocols")
34  [
35  luabind::namespace_("inputter")
36  [
37  luabind::class_<SilentFileInputter, Inputter>("SilentFileInputter")
38  ]
39  ];
40 }
41 #endif
42 
44 
46  offset_ = true;
48  core::pose::PoseSP tmppose(new core::pose::Pose());
49  if( multiply_over_all_ ) {
50  // we go through all the filenames once, then more times according to multiplier
51  for( int i = 1; i<n; i++){
52  tags_[curr_idx_].first++;
53  if( tags_[curr_idx_].first >= multiplier_ ) {
54  // this only can happen when curr_idx_ == 0
55  tags_.pop_front();
56  } else {
57  curr_idx_++;
58  curr_idx_ = curr_idx_ == tags_.size() ? 0 : curr_idx_;
59  }
60  }
61  sfd_[ tags_[curr_idx_].second ]->fill_pose( *tmppose, *residue_set );
62  tags_[curr_idx_].first++;
63  core::pose::add_comment( *tmppose, "inputfile", tags_[curr_idx_].second );
64  core::pose::add_comment( *tmppose, "filemultiplier", utility::to_string(tags_[curr_idx_].first) );
65  if( tags_[curr_idx_].first >= multiplier_ ) {
66  // this only can happen when curr_idx_ == 0
67  tags_.pop_front();
68  } else {
69  curr_idx_++;
70  curr_idx_ = curr_idx_ == tags_.size() ? 0 : curr_idx_;
71  }
72  return tmppose;
73  } else {
74  // we go through each file name MULTIPLIER times, then pop it
75  for( int i = 1; i<n; i++){
76  tags_.front().first++;
77  if( tags_.front().first >= multiplier_ )
78  tags_.pop_front();
79  }
80  sfd_[ tags_.front().second ]->fill_pose( *tmppose, *residue_set );
81  tags_.front().first++;
82  core::pose::add_comment( *tmppose, "inputfile", tags_.front().second );
83  core::pose::add_comment( *tmppose, "file_multiplier", utility::to_string(tags_.front().first) );
84  if( tags_.front().first >= multiplier_ )
85  tags_.pop_front();
86  return tmppose;
87  }
88 }
89 
91  int sum = 0;
92  for( core::Size i = 0; i < tags_.size(); i++ ) {
93  sum += (multiplier_ - tags_[i].first );
94  if (sum >= n )
95  return true;
96  }
97  return false;
98 }
99 
101  return InputterSP( new SilentFileInputter() );
102 }
103 
104 #ifdef USELUA
105 void SilentFileInputter::parse_def( utility::lua::LuaObject const & def,
106  utility::lua::LuaObject const & tasks,
107  utility::lua::LuaObject & inputters ) {
108  if( def["multiplier"] ) multiplier_ = def["multiplier"].to<int>();
109  if( def["multiply_over_all"] ) multiply_over_all_ = def["multiply_over_all"].to<bool>();
110  for (utility::lua::LuaIterator i=def["filelist"].begin(), end; i != end; ++i) {
111  sfd_.read_file( (*i).to<std::string>() );
112  }
114  for( utility::vector1< std::string >::iterator itr = tags.begin(); itr != tags.end(); itr++ ) {
115  tags_.push_back( std::pair<int, std::string> ( 0, *itr) );
116  }
117 }
118 
119 void SilentFileInputter::lregister( lua_State * lstate ) {
120  lregister_SilentFileInputter( lstate );
121 }
122 #endif
123 
124 } // inputter
125 } // protocols