vdj_pipe
pipeline for processing DNA sequence data
file_stream.hpp
Go to the documentation of this file.
1 
7 #ifndef FILE_STREAM_HPP_
8 #define FILE_STREAM_HPP_
9 #include <string>
10 #include <fstream>
11 #include "boost/iostreams/filtering_streambuf.hpp"
12 #include "boost/scoped_ptr.hpp"
13 #include "boost/utility/string_ref.hpp"
14 #include "vdj_pipe/config.hpp"
15 #include "vdj_pipe/exception.hpp"
16 #include "vdj_pipe/file.hpp"
18 
19 namespace vdj_pipe{
20 class File_output;
21 
25  typedef boost::scoped_ptr<std::ofstream> ofs_ptr;
26  typedef boost::scoped_ptr<std::ostream> os_ptr;
27  typedef boost::iostreams::filtering_ostreambuf fosb_t;
28  typedef boost::scoped_ptr<fosb_t> fosb_ptr;
29 
30  static fosb_t* make_fosb(
31  std::ostream& os,
32  const compression::Compression compr
33  );
34 
35  static std::ios_base::openmode guess_mode(
36  const std::ios_base::openmode mode,
37  const compression::Compression compr
38  );
39 
40 public:
41  struct Err : public base_exception {};
42 
43  File_ostream(const format::Format fmt);
44 
45  explicit File_ostream(
46  File_output const& fout,
47  const std::ios_base::openmode mode = (std::ios_base::openmode)0
48  );
49 
50  std::ostream& ostream() {return os_;}
51 
52  void write(
53  std::string const& descr,
54  Seq_record::sequence const& seq
55  );
56 
57  void write(
58  std::string const& descr,
59  const boost::string_ref seq
60  );
61 
62  void write(
63  std::string const& descr,
65  );
66 
67  void write(
68  std::string const& descr,
69  Seq_record::sequence const& seq,
70  Qual_record::quality const& qual
71  );
72 
73 private:
74  ofs_ptr ofs_;
75  fosb_ptr fosb_;
76  os_ptr fosb_os_;
77  std::ostream& os_;
78 };
79 
83  typedef boost::scoped_ptr<std::istream> is_ptr;
84  typedef boost::scoped_ptr<std::ifstream> ifs_ptr;
85  typedef boost::iostreams::filtering_istreambuf fisb_t;
86  typedef boost::scoped_ptr<fisb_t> fisb_ptr;
87 
88  static fisb_t* make_fisb(
89  std::istream& is,
90  const compression::Compression compr
91  );
92 
93 public:
94  struct Err : public base_exception {};
95  explicit File_istream(File_input const& fin);
96 
97  explicit File_istream(
98  std::istream& is,
100  );
101 
102  std::istream& istream() {return is_;}
103  bool good() const {return is_;}
104 
105 private:
106  ifs_ptr ifs_;
107  fisb_ptr fisb_;
108  is_ptr fisb_is_;
109  std::istream& is_;
110 };
111 
112 }//namespace vdj_pipe
113 #endif /* FILE_STREAM_HPP_ */
boost::scoped_ptr< std::ostream > os_ptr
Definition: file_stream.hpp:26
ofs_ptr ofs_
Definition: file_stream.hpp:74
Definition: file_stream.hpp:82
Definition: sequence_record.hpp:35
Definition: file_stream.hpp:94
boost::scoped_ptr< std::istream > is_ptr
Definition: file_stream.hpp:83
fosb_ptr fosb_
Definition: file_stream.hpp:75
boost::scoped_ptr< std::ofstream > ofs_ptr
Definition: file_stream.hpp:25
Compression
File compression types.
Definition: file_properties.hpp:19
boost::scoped_ptr< fisb_t > fisb_ptr
Definition: file_stream.hpp:86
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
File target is supposed to exist at construction time.
Definition: file.hpp:93
Qual_record::quality qual
Definition: match_element_run.cpp:26
std::ostream & ostream()
Definition: file_stream.hpp:50
Definition: file_stream.hpp:41
#define VDJ_PIPE_DECL
Definition: config.hpp:23
std::ostream & os_
Definition: file_stream.hpp:77
is_ptr fisb_is_
Definition: file_stream.hpp:108
std::istream & is_
Definition: file_stream.hpp:109
Format
File format types.
Definition: file_properties.hpp:42
fisb_ptr fisb_
Definition: file_stream.hpp:107
bool good() const
Definition: file_stream.hpp:103
boost::scoped_ptr< fosb_t > fosb_ptr
Definition: file_stream.hpp:28
std::string sequence
Definition: sequence_record.hpp:29
Definition: exception.hpp:23
boost::iostreams::filtering_istreambuf fisb_t
Definition: file_stream.hpp:85
Definition: file_stream.hpp:24
std::istream & istream()
Definition: file_stream.hpp:102
boost::scoped_ptr< std::ifstream > ifs_ptr
Definition: file_stream.hpp:84
os_ptr fosb_os_
Definition: file_stream.hpp:76
Definition: file_properties.hpp:20
File target is created if needed at construction time.
Definition: file.hpp:105
ifs_ptr ifs_
Definition: file_stream.hpp:106
boost::iostreams::filtering_ostreambuf fosb_t
Definition: file_stream.hpp:27