src/c++/lib/common/ReadPileup.cpp
/**
 * Pile up reads at pos
 * @param pos position to calculuate pileup for
 * @param processor function that is called successively for every read that overlaps pos
 */
Pile up reads at pos
@param pos position to calculuate pileup for
@param processor function that is called successively for every read that overlaps pos
Pile up reads at pos @param pos position to calculuate pileup for @param processor function that is called successively for every read that overlaps pos
void ReadPileup::pileup(int64_t pos, std::function<void(ReadPileupInfo*)>&& processor) const
{
    SinglePosition location{ pos };
    ReadPileupOrderByPos order;
    auto last
        = std::upper_bound(_impl->reads.begin(), _impl->reads.end(), static_cast<ReadPileupInfo*>(&location), order);
    if (last == _impl->reads.end() && !_impl->reads.empty())
    {
        last = std::prev(last);
    }
    while (last != _impl->reads.end())
    {
        if ((*last)->pos() <= pos && (*last)->end() >= pos)
        {
            processor((*last));
        }
        else if ((*last)->end() < pos - _impl->max_distance)
        {
            break;
        }
        if (last != _impl->reads.begin())
        {
            --last;
        }
        else
        {
            break;
        }
    }
}
void ReadPileup :: pileup ( int64_t pos , std :: function < void ( ReadPileupInfo * ) > && processor ) const { SinglePosition location { pos } ; ReadPileupOrderByPos order ; auto last = std :: upper_bound ( _impl -> reads . begin ( ) , _impl -> reads . end ( ) , static_cast < ReadPileupInfo * > ( & location ) , order ) ; if ( last == _impl -> reads . end ( ) && ! _impl -> reads . empty ( ) ) { last = std :: prev ( last ) ; } while ( last != _impl -> reads . end ( ) ) { if ( ( * last ) -> pos ( ) <= pos && ( * last ) -> end ( ) >= pos ) { processor ( ( * last ) ) ; } else if ( ( * last ) -> end ( ) < pos - _impl -> max_distance ) { break ; } if ( last != _impl -> reads . begin ( ) ) { -- last ; } else { break ; } } }
Pile up reads at pos
 @param pos position to calculuate pileup for
 @param processor function that is called successively for every read that overlaps pos
Pile up reads at pos @param pos position to calculuate pileup for @param processor function that is called successively for every read that overlaps pos