7 #ifndef INPUT_MANAGER_IMPL_HPP_ 8 #define INPUT_MANAGER_IMPL_HPP_ 12 #include "boost/foreach.hpp" 13 #include "boost/lexical_cast.hpp" 14 #include "boost/property_tree/ptree.hpp" 15 #include "boost/range.hpp" 16 namespace bpt = boost::property_tree;
45 std::set<std::string> name_set;
46 bpt::ptree::value_type
const* sequence = 0;
47 bpt::ptree::value_type
const* quality = 0;
48 bpt::ptree::value_type
const* reverse = 0;
49 bpt::ptree::value_type
const* forward_seq = 0;
50 bpt::ptree::value_type
const* reverse_seq = 0;
51 bpt::ptree::value_type
const* forward_mid = 0;
52 bpt::ptree::value_type
const* reverse_mid = 0;
53 bpt::ptree::value_type
const* forward_qual = 0;
54 bpt::ptree::value_type
const* reverse_qual = 0;
56 BOOST_FOREACH(bpt::ptree::value_type
const& vt, pt) {
58 if( ! name_set.insert(vt.first).second ) BOOST_THROW_EXCEPTION(
60 << Err::msg_t(
"duplicate value name")
61 << Err::str1_t(vt.first)
64 if( vt.first == kwds::Single::sequence() ) {
67 }
else if( vt.first == kwds::Single::quality() ) {
70 }
else if( vt.first == kwds::Single::is_reverse() ) {
73 }
else if( vt.first == input_kwds::forward_seq() ) {
76 }
else if( vt.first == input_kwds::reverse_seq() ) {
79 }
else if( vt.first == input_kwds::forward_mid() ) {
82 }
else if( vt.first == input_kwds::reverse_mid() ) {
85 }
else if( vt.first == input_kwds::forward_qual() ) {
88 }
else if( vt.first == input_kwds::reverse_qual() ) {
91 }
else if( vt.first.size() ) {
97 BOOST_THROW_EXCEPTION( Err() << Err::msg_t(
"empty value name") );
105 forward_seq || reverse_seq || forward_mid ||
106 reverse_mid || forward_qual || reverse_qual
108 BOOST_THROW_EXCEPTION(
111 "\"forward_\" and \"reverse_\" cannot be used with " 116 const Val_id vid1 = vm.
value_id(kwds::Single::seq_file_path());
117 m.insert(
val_pair_t(vid1, sequence->second.get_value<std::string>()));
120 const Val_id vid = vm.
value_id(kwds::Single::qual_file_path());
121 m.insert(
val_pair_t(vid, quality->second.get_value<std::string>()));
124 const Val_id vid2 = vm.
value_id(kwds::Single::is_reverse());
126 m.insert(
val_pair_t(vid2, reverse->second.get_value<
bool>()));
134 if( quality || reverse ) BOOST_THROW_EXCEPTION(
137 "\"quality\" and \"reverse\" should be used with " 138 "\"sequence\" keyword" 142 if( forward_seq && reverse_seq ) {
144 if( (
bool)forward_qual != (
bool)reverse_qual ) BOOST_THROW_EXCEPTION(
147 "both forward and reverse quality scores should be " 152 if( (
bool)forward_mid != (
bool)reverse_mid ) BOOST_THROW_EXCEPTION(
155 "both forward and reverse eMID files should be provided" 159 const Val_id vid1 = vm.
value_id(kwds::Forward::seq_file_path_fwd());
160 m.insert(
val_pair_t(vid1, forward_seq->second.get_value<std::string>()));
161 const Val_id vid2 = vm.
value_id(kwds::Reverse::seq_file_path_rev());
162 m.insert(
val_pair_t(vid2, reverse_seq->second.get_value<std::string>()));
165 const Val_id vid1 = vm.
value_id(kwds::Forward::qual_file_path_fwd());
166 m.insert(
val_pair_t(vid1, forward_qual->second.get_value<std::string>()));
167 const Val_id vid2 = vm.
value_id(kwds::Reverse::qual_file_path_rev());
168 m.insert(
val_pair_t(vid2, reverse_qual->second.get_value<std::string>()));
172 const Val_id vid1 = vm.
value_id(kwds::Emid::emid_file_path_fwd());
173 m.insert(
val_pair_t(vid1, forward_mid->second.get_value<std::string>()));
174 const Val_id vid2 = vm.
value_id(kwds::Emid::emid_file_path_rev());
175 m.insert(
val_pair_t(vid2, reverse_mid->second.get_value<std::string>()));
182 const Val_id vid1 = vm.
value_id(kwds::Single::seq_file_path());
183 m.insert(
val_pair_t(vid1, forward_seq->second.get_value<std::string>()));
185 const Val_id vid2 = vm.
value_id(kwds::Single::is_reverse());
189 const Val_id vid1 = vm.
value_id(kwds::Single::qual_file_path());
190 m.insert(
val_pair_t(vid1, forward_qual->second.get_value<std::string>()));
197 const Val_id vid1 = vm.
value_id(kwds::Single::seq_file_path());
198 m.insert(
val_pair_t(vid1, reverse_seq->second.get_value<std::string>()));
200 const Val_id vid2 = vm.
value_id(kwds::Single::is_reverse());
204 const Val_id vid1 = vm.
value_id(kwds::Single::qual_file_path());
205 m.insert(
val_pair_t(vid1, reverse_qual->second.get_value<std::string>()));
211 BOOST_THROW_EXCEPTION(
213 << Err::msg_t(
"no sequence information found")
226 val_map_t& entry_vars,
227 type_map_t& curr_types,
228 type_map_t& change_to,
229 std::set<Val_id>
const& ign,
233 BOOST_FOREACH(type_map_t::value_type& vp, curr_types) {
234 BOOST_ASSERT(vp.first);
236 if( ign.find(vp.first) != ign.end() )
continue;
238 if( entry_vars.find(vp.first) == entry_vars.end() ) BOOST_THROW_EXCEPTION(
240 << Err::msg_t(
"value not present in all input entries")
241 << Err::str1_t(vm.
name(vp.first))
245 if( vv.which() == vp.second )
continue;
262 vv = (double)boost::get<long>(vv);
268 vv = boost::lexical_cast<std::string>(vv);
274 vv = boost::lexical_cast<std::string>(vv);
284 val_map_t& entry_vars,
285 type_map_t
const& change_to,
289 BOOST_FOREACH(type_map_t::value_type
const& vp, change_to) {
291 if( vv.which() == vp.second )
continue;
298 vv = (double)boost::get<long>(vv);
304 vv = boost::lexical_cast<std::string>(vv);
308 BOOST_THROW_EXCEPTION(
310 << Err::msg_t(
"value type conversion error")
311 << Err::str1_t(vm.
name(vp.first))
327 if( vvm.empty() )
return;
329 type_map_t curr_types;
331 val_map_t& entry_vars,
332 boost::make_iterator_range(++vvm.begin(), vvm.end())
334 typedef type_map_t::value_type pair_t;
335 BOOST_FOREACH(val_pair_t
const& vp, entry_vars) {
336 curr_types.insert(pair_t(vp.first, vp.second.which()));
341 std::set<Val_id> ign;
343 if( Val_id
const*
id = vm.
find_id(kwds::Single::qual_file_path()) ) {
347 if( Val_id
const*
id = vm.
find_id(kwds::Forward::qual_file_path_fwd()) ) {
351 if( Val_id
const*
id = vm.
find_id(kwds::Reverse::qual_file_path_rev()) ) {
355 type_map_t change_to;
357 val_map_t& entry_vars,
358 boost::make_iterator_range(++vvm.begin(), vvm.end())
364 val_map_t& entry_vars,
365 boost::make_iterator_range(++vvm.begin(), vvm.end())
value_variant parse_variant(std::string const &s)
Definition: value_variant.cpp:19
Definition: value_variant.hpp:69
std::string const & variable_type_str(const int which)
Definition: value_variant.hpp:54
Val_id value_id(std::string const &name) const
Definition: value_map.hpp:87
std::map< Val_id, value_variant > map_t
Definition: sequence_file_entry.hpp:29
std::string const & name(const Val_id vid) const
Definition: value_map.hpp:71
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
Val_id insert_name(std::string const &name)
Definition: value_map.hpp:75
boost::variant< Blank, bool, long, double, std::string, sequence_interval, Qual_record::quality > value_variant
Definition: value_variant.hpp:50
Definition: sequence_file_entry.hpp:34
Val_id const * find_id(std::string const &name) const
Definition: value_map.hpp:83
Store values mapped against name strings and value IDs.
Definition: value_map.hpp:23
bpt::ptree ptree
Definition: processing_step_utils.hpp:19