7 #ifndef SEQUENCE_MAP_PARSE_HPP_ 8 #define SEQUENCE_MAP_PARSE_HPP_ 16 #include "boost/assert.hpp" 17 #include "boost/foreach.hpp" 18 #include "boost/property_tree/ptree.hpp" 19 #include "boost/tokenizer.hpp" 20 namespace bpt = boost::property_tree;
33 std::string
const& seq = pt.data();
39 BOOST_FOREACH(bpt::ptree::value_type
const& vt, pt) {
51 std::string
const& fn = pt.data();
53 const std::string in_path = in.
path(fn);
54 std::ifstream ifs(in_path.c_str());
57 if( ! ifs.good() ) BOOST_THROW_EXCEPTION(
59 << Err::msg_t(
"cannot read")
64 for(
int line_n = 1; getline(ifs, line_str); ++line_n ) {
65 if( line_str.empty() || line_str[0] ==
'#' )
continue;
67 tokenizer tok(line_str);
70 BOOST_FOREACH(std::string
const& s, tok) {
73 if( sv.empty() )
continue;
74 if( n == 0 ) n = sv.size();
76 if( n != sv.size() ) BOOST_THROW_EXCEPTION(
78 << Err::msg_t(
"mismatched number of columns")
80 << Err::int1_t(sv.size())
82 << Err::line_t(line_n)
90 BOOST_FOREACH(bpt::ptree::value_type
const& vt, pt) {
102 std::string
const& fn = pt.data();
104 const std::string in_path = in.
path(fn);
112 BOOST_FOREACH(bpt::ptree::value_type
const& vt, pt) {
125 typedef std::map<std::string, std::size_t> map_t;
127 for( std::size_t
n = 0;
n != nsv.size(); ++
n) {
128 m.insert(std::make_pair(nsv[
n].first,
n));
133 BOOST_ASSERT(sv.size() > 2);
134 std::ostringstream os;
135 for( std::size_t
n = 1;
n != sv.size(); ++
n ) {
136 std::string
const& name = sv[
n];
137 map_t::const_iterator i = m.find(name);
138 if( i == m.end() ) BOOST_THROW_EXCEPTION(
140 << Err::msg_t(
"sequence name not found")
143 os << nsv[i->second].second;
145 sv2.push_back(std::make_pair(sv[0], os.str()));
bool has_next() const
Definition: parser_line.hpp:31
void parse_sequences(bpt::ptree const &pt, name_seq_vector &nsv)
Definition: sequence_map_parse.hpp:32
sequence seq_
Definition: sequence_record.hpp:32
void parse_seq_files(bpt::ptree const &pt, Input_manager const &in, name_seq_vector &nsv)
Definition: sequence_map_parse.hpp:97
name_seq_vector combine(name_seq_vector const &nsv, string_table const &st)
Definition: sequence_map_parse.hpp:119
std::vector< std::string > string_vector
Definition: sequence_map_types.hpp:16
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
Definition: sequence_record.hpp:28
std::vector< string_vector > string_table
Definition: sequence_map_types.hpp:17
boost::tokenizer< boost::char_separator< char > > tokenizer
Definition: me_factory.cpp:34
void parse_combinations(bpt::ptree const &pt, Input_manager const &in, string_table &st)
Definition: sequence_map_parse.hpp:46
Definition: parser_fasta.hpp:16
const std::size_t n
Definition: vector_set_test.cpp:26
Definition: exception.hpp:23
std::string sanitize(const char c)
Definition: sanitize_string.cpp:53
std::pair< std::string, std::string > match_seq
Definition: sequence_map_types.hpp:14
bpt::ptree ptree
Definition: processing_step_utils.hpp:19
std::vector< match_seq > name_seq_vector
Definition: sequence_map_types.hpp:15