1 #ifndef theplu_yat_omic_algorithm
2 #define theplu_yat_omic_algorithm
26 #include "GenomicPosition.h"
28 #include <boost/concept/assert.hpp>
29 #include <boost/iterator/iterator_concepts.hpp>
59 template<
class Iterator,
class Visitor>
62 BOOST_CONCEPT_ASSERT((boost::InputIterator<Iterator>));
64 using boost::Convertible;
65 typedef typename std::iterator_traits<Iterator>::reference reference_type;
66 BOOST_CONCEPT_ASSERT((Convertible<reference_type, BamRead>));
69 typedef std::multimap<GenomicPosition, BamRead> Map;
71 std::map<std::string, BamRead> siam_reads;
73 for (; first!=last; ++first) {
77 if (position != siam_position) {
78 siam_position = position;
83 if (mate_position > position)
84 reads.insert(std::make_pair(mate_position, *first));
85 else if (mate_position < position) {
88 Map::iterator lower = reads.lower_bound(position);
89 reads.erase(reads.begin(), lower);
91 lower = reads.begin();
93 for (; lower!=reads.end() && lower->first == position; ++lower) {
94 if (same_query_name(lower->second, *first)) {
95 visitor(lower->second, *first);
102 std::map<std::string, BamRead>::iterator
103 mate = siam_reads.lower_bound(first->name());
104 if (mate!=siam_reads.end() && same_query_name(mate->second, *first)) {
105 visitor(mate->second, *first);
109 siam_reads.insert(mate, std::make_pair(first->name(), *first));