vdj_pipe
pipeline for processing DNA sequence data
parser_fasta.hpp
Go to the documentation of this file.
1 
7 #ifndef PARSER_FASTA_HPP_
8 #define PARSER_FASTA_HPP_
11 
12 namespace vdj_pipe{
13 
17 public:
18  typedef Seq_record record;
19  typedef record::sequence sequence;
20 
21  explicit Parser_fasta(File_input const& fi)
23  {
24  if( fi.format() != format::Fasta ) BOOST_THROW_EXCEPTION(
25  Err()
26  << Err::msg_t("wrong file format for FASTA parser")
27  << Err::str1_t(sanitize(fi.path()))
28  << Err::int1_t(fi.format())
29  );
30  next_record();
31  }
32 
33  explicit Parser_fasta(
34  std::istream& is,
35  const compression::Compression compr = compression::none
36  )
37  : detail::Parser_line(is, compr)
38  {
39  next_record();
40  }
41 
42  const boost::string_ref get_id() {return Parser_line::get_id('>');}
43  void next_record() {Parser_line::seek_line('>');}
44  const boost::string_ref get_defstr() {return Parser_line::get_defstr('>');}
45  sequence get_sequence() {return Parser_line::get_sequence('>');}
46 
47  record get_record() {
48  record sr;
49  Parser_line::set_meta(sr, '>');
50  sr.seq_ = get_sequence();
51  return sr;
52  }
53 };
54 
55 }//namespace vdj_pipe
56 #endif /* PARSER_FASTA_HPP_ */
Compression
File compression types.
Definition: file_properties.hpp:19
sequence seq_
Definition: sequence_record.hpp:32
Definition: parser_line.hpp:26
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
File target is supposed to exist at construction time.
Definition: file.hpp:93
Definition: sequence_record.hpp:28
Definition: parser_fasta.hpp:16
Basic line-based parser; use to derive other parsers.
Definition: parser_line.hpp:23