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;
20 
21  explicit Parser_fasta(File_input const& fi)
22  : detail::Parser_line(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,
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_ */
Seq_record record
Definition: parser_fasta.hpp:18
Parser_fasta(File_input const &fi)
Definition: parser_fasta.hpp:21
format::Format format() const
Definition: file.hpp:75
sequence seq_
Definition: sequence_record.hpp:32
Compression
File compression types.
Definition: file_properties.hpp:19
Definition: file_properties.hpp:43
boost::error_info< struct errinfo_int1_, int > int1_t
Definition: exception.hpp:28
void next_record()
Definition: parser_fasta.hpp:43
Definition: parser_line.hpp:26
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
File target is supposed to exist at construction time.
Definition: file.hpp:93
Parser_line(File_input const &fi)
Definition: parser_line.hpp:34
std::string const & path() const
Definition: file.hpp:74
Definition: sequence_record.hpp:28
record::sequence sequence
Definition: parser_fasta.hpp:19
record get_record()
Definition: parser_fasta.hpp:47
boost::error_info< struct errinfo_str1_, std::string > str1_t
Definition: exception.hpp:25
Definition: parser_fasta.hpp:16
const boost::string_ref get_defstr()
Definition: parser_fasta.hpp:44
std::string sequence
Definition: sequence_record.hpp:29
boost::error_info< struct errinfo_message_, std::string > msg_t
Definition: exception.hpp:24
std::string sanitize(const char c)
Definition: sanitize_string.cpp:53
sequence get_sequence()
Definition: parser_fasta.hpp:45
Basic line-based parser; use to derive other parsers.
Definition: parser_line.hpp:23
const boost::string_ref get_id()
Definition: parser_fasta.hpp:42
Parser_fasta(std::istream &is, const compression::Compression compr=compression::none)
Definition: parser_fasta.hpp:33
Definition: file_properties.hpp:20