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