26 #ifndef SHORE_GENOME_DNA_ITERATOR_HPP__
27 #define SHORE_GENOME_DNA_ITERATOR_HPP__
29 #include <boost/iterator/iterator_facade.hpp>
38 template<
typename Iter,
40 typename ConversionFunc=Converted (*)(
const typename std::iterator_traits<Iter>::value_type)>
44 boost::random_access_traversal_tag,
49 typedef Iter iterator_type;
50 typedef Converted converted_type;
51 typedef ConversionFunc conversion_func_type;
55 friend class boost::iterator_core_access;
60 conversion_func_type m_conv;
72 void advance(ptrdiff_t n)
77 ptrdiff_t distance_to(
const this_type &other)
const
79 return other.m_iter-m_iter;
82 bool equal(
const this_type &other)
const
84 return other.m_iter==m_iter;
87 converted_type dereference()
const
89 return m_conv(*m_iter);
98 conversion_proxy(iterator_type iter,conversion_func_type fun=conversion_func_type())
99 :m_iter(iter),m_conv(fun)
126 char operator()(
const char c)
const;
156 char operator()(
const uint64_t c)
const;
162 char operator()(
const uint64_t c)
const;
240 template<
typename Iter>
256 template<
typename Iter>
272 template<
typename Iter>
290 template<
typename Iter>
306 template<
typename Iter>
322 template<
typename Iter>
338 template<
typename Iter>
354 template<
typename Iter>
370 template<
typename Iter>
388 template<
typename Iter>
404 template<
typename Iter>
420 template<
typename Iter>
436 template<
typename Iter>
454 template<
typename Iter>
470 template<
typename Iter>
486 template<
typename Iter>
502 template<
typename Iter>
520 template<
typename Iter>
536 template<
typename Iter>
552 template<
typename Iter>
568 template<
typename Iter>
589 :
public boost::iterator_facade<
594 friend class boost::iterator_core_access;
618 void advance(difference_type n)
626 difference_type distance_to(
const dna_iterator& other)
const
629 return other.m_pt-m_pt;
630 return other.m_it-m_it;
636 return m_pt==other.m_pt;
637 return m_it==other.m_it;
640 reference dereference()
const
646 return shore::nuc::comp(shore::nuc::unpack(static_cast<shore::nuc::packed_base>(
647 static_cast<shore::intpack::int_type>(*m_it))));
651 return shore::nuc::unpack(static_cast<shore::nuc::packed_base>(
652 static_cast<shore::intpack::int_type>(*m_it)));
658 :m_pt(0),m_complement(
false)
662 :m_pt(pt),m_complement(
false)
666 :m_pt(0),m_it(it),m_complement(
false)
681 static dna_iterator
end(
const std::string& s)
683 return dna_iterator(s.data()+s.size());
691 :
public boost::iterator_facade<
692 packeddna_iterator,const shore::nuc::packed_base,boost::random_access_traversal_tag,const shore::nuc::packed_base>
696 friend class boost::iterator_core_access;
720 void advance(difference_type n)
731 return other.m_pt-m_pt;
732 return other.m_it-m_it;
738 return m_pt==other.m_pt;
739 return m_it==other.m_it;
742 reference dereference()
const
749 static_cast<shore::nuc::packed_base>(
750 static_cast<shore::intpack::int_type>(*m_it)))));
761 :m_pt(0),m_complement(
false)
765 :m_pt(pt),m_complement(
false)
769 :m_pt(0),m_it(it),m_complement(
false)
784 static packeddna_iterator
end(
const std::string& s)
786 return packeddna_iterator(s.data()+s.size());
794 :
public boost::iterator_facade<
795 chardna_iterator,const char,boost::random_access_traversal_tag,const char>
799 friend class boost::iterator_core_access;
823 void advance(difference_type n)
834 return other.m_pt-m_pt;
835 return other.m_it-m_it;
841 return m_pt==other.m_pt;
842 return m_it==other.m_it;
845 reference dereference()
const
852 static_cast<shore::nuc::packed_base>(
853 static_cast<shore::intpack::int_type>(*m_it)))));
858 static_cast<shore::nuc::packed_base>(
859 static_cast<shore::intpack::int_type>(*m_it))));
865 :m_pt(0),m_complement(
false)
869 :m_pt(pt),m_complement(
false)
873 :m_pt(0),m_it(it),m_complement(
false)
886 #endif // SHORE_GENOME_DNA_ITERATOR_HPP__