3878 |
12 Mar 20 |
peter |
// $Id$ |
3878 |
12 Mar 20 |
peter |
2 |
// |
3878 |
12 Mar 20 |
peter |
// Copyright (C) 2020 Peter Johansson |
3878 |
12 Mar 20 |
peter |
4 |
// |
3878 |
12 Mar 20 |
peter |
// This program is free software; you can redistribute it and/or modify |
3878 |
12 Mar 20 |
peter |
// it under the terms of the GNU General Public License as published by |
3878 |
12 Mar 20 |
peter |
// the Free Software Foundation; either version 3 of the License, or |
3878 |
12 Mar 20 |
peter |
// (at your option) any later version. |
3878 |
12 Mar 20 |
peter |
9 |
// |
3878 |
12 Mar 20 |
peter |
// This program is distributed in the hope that it will be useful, but |
3878 |
12 Mar 20 |
peter |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
3878 |
12 Mar 20 |
peter |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3878 |
12 Mar 20 |
peter |
// General Public License for more details. |
3878 |
12 Mar 20 |
peter |
14 |
// |
3878 |
12 Mar 20 |
peter |
// You should have received a copy of the GNU General Public License |
3878 |
12 Mar 20 |
peter |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
3878 |
12 Mar 20 |
peter |
17 |
|
3878 |
12 Mar 20 |
peter |
18 |
#include <config.h> |
3878 |
12 Mar 20 |
peter |
19 |
|
3883 |
24 Mar 20 |
peter |
20 |
#ifdef YAT_HAVE_HTSLIB |
3878 |
12 Mar 20 |
peter |
21 |
#include "yat/omic/BamFile.h" |
3878 |
12 Mar 20 |
peter |
22 |
#include "yat/omic/BamPairIterator2.h" |
3878 |
12 Mar 20 |
peter |
23 |
#include "yat/omic/BamRead.h" |
3878 |
12 Mar 20 |
peter |
24 |
#include "yat/omic/BamReadIterator.h" |
3878 |
12 Mar 20 |
peter |
25 |
#endif |
3878 |
12 Mar 20 |
peter |
26 |
|
3878 |
12 Mar 20 |
peter |
27 |
#include <cassert> |
3878 |
12 Mar 20 |
peter |
28 |
#include <string> |
3878 |
12 Mar 20 |
peter |
29 |
#include <vector> |
3878 |
12 Mar 20 |
peter |
30 |
|
3878 |
12 Mar 20 |
peter |
// include Suite.h late to expose bug #797 |
3878 |
12 Mar 20 |
peter |
32 |
#include "Suite.h" |
3878 |
12 Mar 20 |
peter |
33 |
|
3878 |
12 Mar 20 |
peter |
34 |
using namespace theplu::yat; |
3883 |
24 Mar 20 |
peter |
35 |
#ifdef YAT_HAVE_HTSLIB |
3878 |
12 Mar 20 |
peter |
36 |
using namespace omic; |
3878 |
12 Mar 20 |
peter |
37 |
#endif |
3878 |
12 Mar 20 |
peter |
38 |
|
3878 |
12 Mar 20 |
peter |
39 |
void test1(test::Suite& suite); |
3878 |
12 Mar 20 |
peter |
40 |
void test2(test::Suite& suite); |
3878 |
12 Mar 20 |
peter |
41 |
|
3878 |
12 Mar 20 |
peter |
42 |
int main(int argc, char* argv[]) |
3878 |
12 Mar 20 |
peter |
43 |
{ |
3878 |
12 Mar 20 |
peter |
44 |
test::Suite suite(argc, argv, true); |
3878 |
12 Mar 20 |
peter |
45 |
try { |
3883 |
24 Mar 20 |
peter |
46 |
#ifdef YAT_HAVE_HTSLIB |
3878 |
12 Mar 20 |
peter |
47 |
test1(suite); |
3878 |
12 Mar 20 |
peter |
48 |
test2(suite); |
3878 |
12 Mar 20 |
peter |
49 |
#endif |
3878 |
12 Mar 20 |
peter |
50 |
} |
3878 |
12 Mar 20 |
peter |
51 |
catch (std::runtime_error& e) { |
3878 |
12 Mar 20 |
peter |
52 |
suite.add(false); |
3878 |
12 Mar 20 |
peter |
53 |
suite.err() << "error: what: " << e.what() << "\n"; |
3878 |
12 Mar 20 |
peter |
54 |
} |
3878 |
12 Mar 20 |
peter |
55 |
return suite.return_value(); |
3878 |
12 Mar 20 |
peter |
56 |
} |
3878 |
12 Mar 20 |
peter |
57 |
|
3883 |
24 Mar 20 |
peter |
58 |
#ifdef YAT_HAVE_HTSLIB |
3878 |
12 Mar 20 |
peter |
59 |
|
3878 |
12 Mar 20 |
peter |
60 |
void test1(test::Suite& suite) |
3878 |
12 Mar 20 |
peter |
61 |
{ |
3878 |
12 Mar 20 |
peter |
62 |
std::string file = "../../data/foo.sorted.bam"; |
3878 |
12 Mar 20 |
peter |
63 |
|
3878 |
12 Mar 20 |
peter |
64 |
InBamFile in(file); |
3878 |
12 Mar 20 |
peter |
65 |
BamReadIterator iter(in); |
3878 |
12 Mar 20 |
peter |
66 |
BamReadIterator end; |
3878 |
12 Mar 20 |
peter |
67 |
|
3878 |
12 Mar 20 |
peter |
68 |
BamPairIterator2<BamReadIterator> pair_iterator(iter, end); |
3878 |
12 Mar 20 |
peter |
69 |
BamPairIterator2<BamReadIterator> pair_end(end, end); |
3878 |
12 Mar 20 |
peter |
70 |
std::vector<BamPair> result(pair_iterator, pair_end); |
3878 |
12 Mar 20 |
peter |
71 |
|
3878 |
12 Mar 20 |
peter |
72 |
in.close(); |
3878 |
12 Mar 20 |
peter |
73 |
if (!suite.add(result.size())) |
3878 |
12 Mar 20 |
peter |
74 |
suite.err() << "error: empty result\n"; |
3878 |
12 Mar 20 |
peter |
75 |
|
3878 |
12 Mar 20 |
peter |
76 |
} |
3878 |
12 Mar 20 |
peter |
77 |
|
3878 |
12 Mar 20 |
peter |
78 |
|
3878 |
12 Mar 20 |
peter |
79 |
void test2(test::Suite& suite) |
3878 |
12 Mar 20 |
peter |
80 |
{ |
3878 |
12 Mar 20 |
peter |
81 |
std::string file = "../../data/foo.sorted.bam"; |
3878 |
12 Mar 20 |
peter |
82 |
|
3878 |
12 Mar 20 |
peter |
83 |
InBamFile in(file); |
3878 |
12 Mar 20 |
peter |
84 |
BamReadIterator iter(in); |
3878 |
12 Mar 20 |
peter |
85 |
BamReadIterator end; |
3878 |
12 Mar 20 |
peter |
86 |
|
3878 |
12 Mar 20 |
peter |
87 |
BamPairIterator2<BamReadIterator> pair_iterator(iter, end); |
3878 |
12 Mar 20 |
peter |
88 |
BamPairIterator2<BamReadIterator> pair_end(end, end); |
3878 |
12 Mar 20 |
peter |
89 |
suite.test_input_iterator(pair_iterator); |
3878 |
12 Mar 20 |
peter |
90 |
} |
3878 |
12 Mar 20 |
peter |
91 |
#endif |