7 #ifndef SEQUENCE_TRANSFORM_HPP_ 8 #define SEQUENCE_TRANSFORM_HPP_ 10 #include "boost/range.hpp" 11 #include "boost/range/as_literal.hpp" 21 template<
class Range>
inline std::string complement(Range
const& r) {
22 std::string rstr(boost::size(boost::as_literal(r)),
'X');
23 std::string::reverse_iterator i = rstr.rbegin();
24 typedef typename boost::range_iterator<const Range>::type iter;
25 iter j = boost::begin(boost::as_literal(r)), end = boost::end(boost::as_literal(r));
26 for(; j != end; ++i, ++j) {
27 *i = complement((
char)*j);
35 const boost::string_ref seq,
36 sequence_interval
const& si,
40 (std::size_t)si.lower() > seq.size() ||
41 (std::size_t)si.upper() > seq.size()
42 ) BOOST_THROW_EXCEPTION(
44 << base_exception::msg_t(
"sequence interval and length mismatch")
45 << base_exception::int1_t(std::max(si.lower(), si.upper()))
46 << base_exception::int2_t(seq.size())
50 complement(seq.substr(si.lower(), width(si))) :
51 seq.substr(si.lower(), width(si)).to_string()
Main namespace of vdj_pipe library.
Definition: sequence_file.hpp:14
Definition: exception.hpp:23
std::string transform(const boost::string_ref seq, sequence_interval const &si, const bool reverse)
Reverse-complement (optionally) a portion of a sequence.
Definition: sequence_transform.hpp:34