Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDBPoseInputStream.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/PDBPoseInputStream.cc
11 /// @brief
12 /// @author James Thompson
13 
14 // libRosetta headers
15 
16 #include <core/types.hh>
18 #include <core/pose/Pose.hh>
20 
24 
25 #include <basic/datacache/BasicDataCache.hh>
26 
27 #include <utility/file/FileName.hh>
28 #include <utility/io/izstream.hh>
29 
30 #include <basic/datacache/CacheableString.hh>
31 
32 // C++ headers
33 #include <string>
34 #include <utility/exit.hh>
35 
36 // Boost Headers
37 #include <boost/foreach.hpp>
38 
39 #include <utility/vector1.hh>
40 
41 #define foreach BOOST_FOREACH
42 
43 namespace core {
44 namespace import_pose {
45 namespace pose_stream {
46 
47 
50 ) {
51  filenames_ = filenames;
52  current_position_ = filenames_.begin();
53 }
54 
56  return filenames_;
57 }
58 
60  return ( current_position_ != filenames_.end() );
61 }
62 
64  current_position_ = filenames_.begin();
65 }
66 
68  core::pose::Pose & pose,
69  core::chemical::ResidueTypeSet const & residue_set
70 ) {
71  // check to make sure that we have more poses!
72  if ( !has_another_pose() ) {
73  utility_exit_with_message(
74  "PDBPoseInputStream: called fill_pose, but I have no more Poses!"
75  );
76  }
77 
79  // set up a tag using input filename.
80  pose.data().set(
82  new basic::datacache::CacheableString( *current_position_ )
83  );
85  preprocess_pose( pose );
86 }
87 
89  core::pose::Pose & pose
90 ) {
91  // check to make sure that we have more poses!
92  if ( !has_another_pose() ) {
93  utility_exit_with_message(
94  "PDBPoseInputStream: called fill_pose, but I have no more Poses!"
95  );
96  }
97 
99  // set up a tag using input filename.
100  pose.data().set(
102  new basic::datacache::CacheableString( *current_position_ )
103  );
105  preprocess_pose( pose );
106 }
107 
109  core::chemical::ResidueTypeSet const & residue_set
110 ) {
112  pose_list.resize( filenames_.size() );
113 
114  while( has_another_pose() ) {
115  core::pose::Pose pose;
116  fill_pose( pose, residue_set );
117  pose_list.push_back( pose );
118  }
119 
120  return pose_list;
121 }
122 
123 /// @brief adds a list of files each containing lists of PDBs
126 ) {
127  using utility::vector1;
128  bool init_current_position( filenames_.size() == 0 );
129 
130  foreach(utility::file::FileName filename_obj, list_fns){
131  std::string filename( filename_obj.name() );
132  utility::io::izstream data( filename.c_str() );
133  if ( !data.good() )
134  utility_exit_with_message( "Unable to open file: " + filename + '\n' );
135 
136  std::string line;
137  while( getline(data, line) ) {
138  filenames_.push_back( utility::file::FileName(line) );
139  }
140  data.close();
141  }
142 
143  if ( init_current_position ) {
144  current_position_ = filenames_.begin();
145  }
146 } // add_list_files
147 
148 } // pose_stream
149 } // import_pose
150 } // core