2902 |
13 Dec 12 |
peter |
// $Id$ |
2902 |
13 Dec 12 |
peter |
2 |
// |
3999 |
08 Oct 20 |
peter |
// Copyright (C) 2012, 2013, 2014, 2020 Peter Johansson |
2902 |
13 Dec 12 |
peter |
4 |
// |
2902 |
13 Dec 12 |
peter |
// This program is free software; you can redistribute it and/or modify |
2902 |
13 Dec 12 |
peter |
// it under the terms of the GNU General Public License as published by |
2902 |
13 Dec 12 |
peter |
// the Free Software Foundation; either version 3 of the License, or |
2902 |
13 Dec 12 |
peter |
// (at your option) any later version. |
2902 |
13 Dec 12 |
peter |
9 |
// |
2902 |
13 Dec 12 |
peter |
// This program is distributed in the hope that it will be useful, but |
2902 |
13 Dec 12 |
peter |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
2902 |
13 Dec 12 |
peter |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2902 |
13 Dec 12 |
peter |
// General Public License for more details. |
2902 |
13 Dec 12 |
peter |
14 |
// |
2902 |
13 Dec 12 |
peter |
// You should have received a copy of the GNU General Public License |
2902 |
13 Dec 12 |
peter |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
2902 |
13 Dec 12 |
peter |
17 |
|
2902 |
13 Dec 12 |
peter |
18 |
#include <config.h> |
2902 |
13 Dec 12 |
peter |
19 |
|
3883 |
24 Mar 20 |
peter |
20 |
#if YAT_HAVE_HTSLIB |
2902 |
13 Dec 12 |
peter |
21 |
#include "yat/omic/algorithm.h" |
2902 |
13 Dec 12 |
peter |
22 |
#include "yat/omic/BamRead.h" |
2902 |
13 Dec 12 |
peter |
23 |
#include "yat/omic/BamReadIterator.h" |
2943 |
04 Jan 13 |
peter |
24 |
#endif |
2902 |
13 Dec 12 |
peter |
25 |
|
3295 |
25 Jul 14 |
peter |
// include Suite.h late to see that algorithm.h is OK to include |
3295 |
25 Jul 14 |
peter |
// first. See ticket #793. |
3295 |
25 Jul 14 |
peter |
28 |
#include "Suite.h" |
3295 |
25 Jul 14 |
peter |
29 |
using namespace theplu::yat; |
3295 |
25 Jul 14 |
peter |
30 |
|
2943 |
04 Jan 13 |
peter |
31 |
void test1(test::Suite& suite); |
2943 |
04 Jan 13 |
peter |
32 |
|
2943 |
04 Jan 13 |
peter |
33 |
int main(int argc, char* argv[]) |
2943 |
04 Jan 13 |
peter |
34 |
{ |
3201 |
03 May 14 |
peter |
35 |
test::Suite suite(argc, argv, true); |
2943 |
04 Jan 13 |
peter |
36 |
|
3883 |
24 Mar 20 |
peter |
37 |
#ifdef YAT_HAVE_HTSLIB |
2943 |
04 Jan 13 |
peter |
38 |
test1(suite); |
2943 |
04 Jan 13 |
peter |
39 |
#endif |
2943 |
04 Jan 13 |
peter |
40 |
return suite.return_value(); |
2943 |
04 Jan 13 |
peter |
41 |
} |
2943 |
04 Jan 13 |
peter |
42 |
|
2943 |
04 Jan 13 |
peter |
43 |
|
3883 |
24 Mar 20 |
peter |
44 |
#ifdef YAT_HAVE_HTSLIB |
2902 |
13 Dec 12 |
peter |
45 |
using namespace omic; |
2902 |
13 Dec 12 |
peter |
46 |
|
2902 |
13 Dec 12 |
peter |
47 |
class Counter |
2902 |
13 Dec 12 |
peter |
48 |
{ |
2902 |
13 Dec 12 |
peter |
49 |
public: |
2902 |
13 Dec 12 |
peter |
50 |
Counter(void) : n_(0) {} |
2902 |
13 Dec 12 |
peter |
51 |
void operator()(const BamRead& first, const BamRead& second) |
2902 |
13 Dec 12 |
peter |
52 |
{ |
2902 |
13 Dec 12 |
peter |
53 |
if (first.core().qual >= 20 && second.core().qual >= 20) |
2902 |
13 Dec 12 |
peter |
54 |
++n_; |
2902 |
13 Dec 12 |
peter |
55 |
} |
2902 |
13 Dec 12 |
peter |
56 |
int n_; |
2902 |
13 Dec 12 |
peter |
57 |
}; |
2902 |
13 Dec 12 |
peter |
58 |
|
2943 |
04 Jan 13 |
peter |
59 |
void test1(test::Suite& suite) |
2902 |
13 Dec 12 |
peter |
60 |
{ |
2902 |
13 Dec 12 |
peter |
61 |
std::string file = "../../data/foo.sorted.bam"; |
2902 |
13 Dec 12 |
peter |
62 |
|
2902 |
13 Dec 12 |
peter |
63 |
InBamFile is(file); |
2902 |
13 Dec 12 |
peter |
64 |
BamReadIterator iter(is); |
2902 |
13 Dec 12 |
peter |
65 |
BamReadIterator end; |
2902 |
13 Dec 12 |
peter |
66 |
Counter counter; |
2902 |
13 Dec 12 |
peter |
67 |
bam_pair_analyse(iter, end, counter); |
3175 |
15 Mar 14 |
peter |
68 |
if (!suite.add(counter.n_==395)) |
3175 |
15 Mar 14 |
peter |
69 |
suite.err() << "n: " << counter.n_ << "; expected 395\n"; |
2902 |
13 Dec 12 |
peter |
70 |
is.close(); |
2902 |
13 Dec 12 |
peter |
71 |
} |
2943 |
04 Jan 13 |
peter |
72 |
#endif |