1 | #ifndef theplu_yat_omic_algorithm |
---|
2 | #define theplu_yat_omic_algorithm |
---|
3 | |
---|
4 | // $Id: algorithm.h 3175 2014-03-15 08:15:51Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2012, 2013 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 | |
---|
31 | #include <iterator> |
---|
32 | #include <map> |
---|
33 | #include <string> |
---|
34 | #include <utility> |
---|
35 | |
---|
36 | namespace theplu { |
---|
37 | namespace yat { |
---|
38 | namespace omic { |
---|
39 | |
---|
40 | /** |
---|
41 | \c bam_pair_analyse performs an operation on bam read pairs as |
---|
42 | defined by \a visitor. The function iterates over sorted input |
---|
43 | range of reads; if read is first read, it is cached for later |
---|
44 | use; if read is second read and mate is present in cache, \a |
---|
45 | visitor operates on pair, i.e., \c Visitor (\c mate, \c read) is |
---|
46 | called. |
---|
47 | |
---|
48 | Type Requirements: |
---|
49 | - \c Iterator must be an \input_iterator |
---|
50 | - \c Iterator 's \c reference type must be convertible to BamRead |
---|
51 | - \c Visitor must have an \c operator()(BamRead, BamRead) (or any |
---|
52 | \c const or reference combination) |
---|
53 | |
---|
54 | \note Input range \c [\a first, \a last \c ) must be sorted or behaviour is |
---|
55 | undefined. |
---|
56 | |
---|
57 | \since New in yat 0.10 |
---|
58 | */ |
---|
59 | template<class Iterator, class Visitor> |
---|
60 | void bam_pair_analyse(Iterator first, Iterator last, Visitor& visitor) |
---|
61 | { |
---|
62 | BamPairIterator<Iterator> iter(first, last); |
---|
63 | BamPairIterator<Iterator> end(last, last); |
---|
64 | for (; iter!=end; ++iter) |
---|
65 | visitor(iter->first(), iter->second()); |
---|
66 | } |
---|
67 | |
---|
68 | }}} |
---|
69 | #endif |
---|