3140 |
16 Dec 13 |
peter |
// $Id$ |
3140 |
16 Dec 13 |
peter |
2 |
// |
3999 |
08 Oct 20 |
peter |
// Copyright (C) 2013, 2014, 2020 Peter Johansson |
3140 |
16 Dec 13 |
peter |
4 |
// |
3140 |
16 Dec 13 |
peter |
// This program is free software; you can redistribute it and/or modify |
3140 |
16 Dec 13 |
peter |
// it under the terms of the GNU General Public License as published by |
3140 |
16 Dec 13 |
peter |
// the Free Software Foundation; either version 3 of the License, or |
3140 |
16 Dec 13 |
peter |
// (at your option) any later version. |
3140 |
16 Dec 13 |
peter |
9 |
// |
3140 |
16 Dec 13 |
peter |
// This program is distributed in the hope that it will be useful, but |
3140 |
16 Dec 13 |
peter |
// WITHOUT ANY WARRANTY; without even the implied warranty of |
3140 |
16 Dec 13 |
peter |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3140 |
16 Dec 13 |
peter |
// General Public License for more details. |
3140 |
16 Dec 13 |
peter |
14 |
// |
3140 |
16 Dec 13 |
peter |
// You should have received a copy of the GNU General Public License |
3140 |
16 Dec 13 |
peter |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
3140 |
16 Dec 13 |
peter |
17 |
|
3140 |
16 Dec 13 |
peter |
18 |
#include <config.h> |
3140 |
16 Dec 13 |
peter |
19 |
|
3140 |
16 Dec 13 |
peter |
20 |
#include "Suite.h" |
3140 |
16 Dec 13 |
peter |
21 |
|
3883 |
24 Mar 20 |
peter |
22 |
#ifdef YAT_HAVE_HTSLIB |
3140 |
16 Dec 13 |
peter |
23 |
#include "yat/omic/BamFile.h" |
3140 |
16 Dec 13 |
peter |
24 |
#include "yat/omic/BamHeader.h" |
3140 |
16 Dec 13 |
peter |
25 |
#endif |
3140 |
16 Dec 13 |
peter |
26 |
|
3140 |
16 Dec 13 |
peter |
27 |
using namespace theplu::yat; |
3140 |
16 Dec 13 |
peter |
28 |
|
3883 |
24 Mar 20 |
peter |
29 |
#ifndef YAT_HAVE_HTSLIB |
3140 |
16 Dec 13 |
peter |
30 |
void do_main(test::Suite& suite) {} |
3140 |
16 Dec 13 |
peter |
31 |
#else |
3140 |
16 Dec 13 |
peter |
32 |
void do_main(test::Suite& suite); |
3140 |
16 Dec 13 |
peter |
33 |
#endif |
3140 |
16 Dec 13 |
peter |
34 |
|
3140 |
16 Dec 13 |
peter |
35 |
int main(int argc, char* argv[]) |
3140 |
16 Dec 13 |
peter |
36 |
{ |
3201 |
03 May 14 |
peter |
37 |
test::Suite suite(argc, argv, true); |
3140 |
16 Dec 13 |
peter |
38 |
try { |
3140 |
16 Dec 13 |
peter |
39 |
do_main(suite); |
3140 |
16 Dec 13 |
peter |
40 |
} |
3140 |
16 Dec 13 |
peter |
41 |
catch (std::runtime_error& e) { |
3140 |
16 Dec 13 |
peter |
42 |
suite.err() << "what: " << e.what() << "\n"; |
3140 |
16 Dec 13 |
peter |
43 |
suite.add(false); |
3140 |
16 Dec 13 |
peter |
44 |
} |
3140 |
16 Dec 13 |
peter |
45 |
|
3140 |
16 Dec 13 |
peter |
46 |
return suite.return_value(); |
3140 |
16 Dec 13 |
peter |
47 |
} |
3140 |
16 Dec 13 |
peter |
48 |
|
3883 |
24 Mar 20 |
peter |
49 |
#ifdef YAT_HAVE_HTSLIB |
3140 |
16 Dec 13 |
peter |
50 |
void do_main(test::Suite& suite) |
3140 |
16 Dec 13 |
peter |
51 |
{ |
3140 |
16 Dec 13 |
peter |
52 |
using namespace omic; |
3140 |
16 Dec 13 |
peter |
53 |
std::string file = "../../data/foo.sorted.bam"; |
3140 |
16 Dec 13 |
peter |
54 |
|
3140 |
16 Dec 13 |
peter |
55 |
InBamFile bam_stream(file); |
3140 |
16 Dec 13 |
peter |
56 |
BamHeader hdr = bam_stream.header(); |
3140 |
16 Dec 13 |
peter |
57 |
int32_t tid1 = hdr.tid("2"); |
3140 |
16 Dec 13 |
peter |
58 |
if (tid1 != 1) { |
3140 |
16 Dec 13 |
peter |
59 |
suite.add(false); |
3140 |
16 Dec 13 |
peter |
60 |
suite.err() << "incorrect tid1: " << tid1 << " expected: 1\n"; |
3140 |
16 Dec 13 |
peter |
61 |
} |
3140 |
16 Dec 13 |
peter |
62 |
int32_t tid2 = hdr.tid("2"); |
3140 |
16 Dec 13 |
peter |
63 |
if (tid1 != tid2) { |
3140 |
16 Dec 13 |
peter |
64 |
suite.add(false); |
3140 |
16 Dec 13 |
peter |
65 |
suite.err() << "error: tid1: " << tid1 << " != tid2: " << tid2 << "\n"; |
3140 |
16 Dec 13 |
peter |
66 |
} |
3140 |
16 Dec 13 |
peter |
67 |
} |
3140 |
16 Dec 13 |
peter |
68 |
#endif |