Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
util.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/pose_stream/util.hh
11 /// @brief
12 /// @author James Thompson
13 
14 #ifndef INCLUDED_core_pose_stream_util_HH
15 #define INCLUDED_core_pose_stream_util_HH
16 
17 
25 
26 #include <core/sequence/util.hh>
28 
29 #include <basic/options/option.hh>
30 #include <basic/options/keys/in.OptionKeys.gen.hh>
31 
32 #include <string>
33 
34 #include <utility/io/izstream.hh>
35 
36 #include <utility/vector1.hh>
37 #include <boost/bind.hpp>
38 
39 
40 namespace core {
41 namespace import_pose {
42 namespace pose_stream {
43 
44 
47 ) {
48 
49  using std::string;
50  using utility::vector1;
52 
53  vector1< FileName > fns_to_return;
54 
55  for ( vector1< FileName >::const_iterator it = list_fns.begin(),
56  it_end = list_fns.end();
57  it != it_end; ++it
58  ) {
59  std::string filename( it->name() );
60  utility::io::izstream data( filename.c_str() );
61  if ( !data.good() )
62  utility_exit_with_message( "Unable to open file: " + filename + '\n' );
63 
64  std::string line;
65  while( getline(data, line) ) {
66  fns_to_return.push_back( utility::file::FileName(line) );
67  }
68  data.close();
69  }
70 
71  return fns_to_return;
72 }
73 
75  using namespace basic::options;
76  using namespace basic::options::OptionKeys;
77 
78  MetaPoseInputStream input;
79  if ( option[ in::file::s ].user() ) {
80  PDBPoseInputStreamOP pdb_input(
81  new PDBPoseInputStream( option[ in::file::s ]() )
82  );
83  input.add_pose_input_stream( pdb_input );
84  }
85  if ( option[ in::file::l ].user() ) {
86  PDBPoseInputStreamOP pdb_list_input(
87  new PDBPoseInputStream( filenames_from_list_file( option[ in::file::l ]() ) )
88  );
89  input.add_pose_input_stream( pdb_list_input );
90  }
91 
92  if ( option[ in::file::silent ].user() ) {
93  if ( option[ in::file::lazy_silent ]() ) {
95  new LazySilentFilePoseInputStream( option[ in::file::silent ]() )
96  );
97  input.add_pose_input_stream(silent_input);
98 
99  if ( option[ in::file::silent_list ].user() ) {
100  LazySilentFilePoseInputStreamOP silent_list_input(
102  option[ in::file::silent_list ]()
103  ) )
104  );
105  input.add_pose_input_stream(silent_list_input);
106  }
107  } else {
108  SilentFilePoseInputStreamOP silent_input;
109  if ( option[ in::file::tags ].user() ) {
110  silent_input =
112  option[ in::file::silent ](),
113  option[ in::file::tags ](),
114  option[ in::file::silent_energy_cut ]()
115  );
116  } else {
117  silent_input = new SilentFilePoseInputStream(
118  option[ in::file::silent ](), option[ in::file::silent_energy_cut ]()
119  );
120  }
121  silent_input->renumber_decoys( option[ in::file::silent_renumber ]() );
122  input.add_pose_input_stream( silent_input );
123  }
124  }
125 
126  if ( option[ in::file::extended_pose ].user() ) {
127  Size const ntimes = option[ in::file::extended_pose ]();
128 
129  using utility::vector1;
131 
132  vector1< FileName > fasta_files( option[ in::file::fasta ]() );
133  for ( vector1< FileName >::const_iterator it = fasta_files.begin(),
134  end = fasta_files.end(); it != end; ++it
135  ) {
136 
137  std::string sequence
138  = core::sequence::read_fasta_file( option[ in::file::fasta ]()[1] )[1]->sequence();
139 
140  PoseInputStreamOP extended_protein_input(
141  new ExtendedPoseInputStream( sequence, ntimes )
142  );
143  input.add_pose_input_stream( extended_protein_input );
144  }
145  }
146 
147  return input;
148 } // streams_from_cmd_line
149 
150 } // pose_stream
151 } // import_pose
152 } // core
153 
154 #endif