source: branches/0.12-stable/yat/omic/algorithm.h @ 3234

Last change on this file since 3234 was 3234, checked in by Peter, 9 years ago

fixes #797

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef theplu_yat_omic_algorithm
2#define theplu_yat_omic_algorithm
3
4// $Id: algorithm.h 3234 2014-05-23 10:08:48Z peter $
5
6/*
7  Copyright (C) 2012, 2013, 2014 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "BamPairIterator.h"
26#include "BamRead.h"
27#include "GenomicPosition.h"
28
29#include <boost/concept/assert.hpp>
30#include <boost/iterator/iterator_concepts.hpp>
31
32#include <iterator>
33#include <map>
34#include <string>
35#include <utility>
36
37namespace theplu {
38namespace yat {
39namespace omic {
40
41  /**
42     \c bam_pair_analyse performs an operation on bam read pairs as
43     defined by \a visitor. The function iterates over sorted input
44     range of reads; if read is first read, it is cached for later
45     use; if read is second read and mate is present in cache, \a
46     visitor operates on pair, i.e., \c Visitor (\c mate, \c read) is
47     called.
48
49     Type Requirements:
50     - \c Iterator must be an \input_iterator
51     - \c Iterator 's \c reference type must be convertible to BamRead
52     - \c Visitor must have an \c operator()(BamRead, BamRead) (or any
53       \c const or reference combination)
54
55     \note Input range \c [\a first, \a last \c ) must be sorted or behaviour is
56     undefined.
57
58     \since New in yat 0.10
59   */
60  template<class Iterator, class Visitor>
61  void bam_pair_analyse(Iterator first, Iterator last, Visitor& visitor)
62  {
63    BamPairIterator<Iterator> iter(first, last);
64    BamPairIterator<Iterator> end(last, last);
65    for (; iter!=end; ++iter)
66      visitor((*iter).first(), (*iter).second());
67  }
68
69}}}
70#endif
Note: See TracBrowser for help on using the repository browser.