1 | // $Id: bam.cc 2972 2013-01-26 06:53:56Z peter $ |
---|
2 | // |
---|
3 | // Copyright (C) 2013 Peter Johansson |
---|
4 | // |
---|
5 | // This program is free software; you can redistribute it and/or modify |
---|
6 | // it under the terms of the GNU General Public License as published by |
---|
7 | // the Free Software Foundation; either version 3 of the License, or |
---|
8 | // (at your option) any later version. |
---|
9 | // |
---|
10 | // This program is distributed in the hope that it will be useful, but |
---|
11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | // General Public License for more details. |
---|
14 | // |
---|
15 | // You should have received a copy of the GNU General Public License |
---|
16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | |
---|
18 | #include <config.h> |
---|
19 | |
---|
20 | #include "Suite.h" |
---|
21 | |
---|
22 | #ifdef HAVE_LIBBAM |
---|
23 | #include "yat/omic/BamFile.h" |
---|
24 | #include "yat/omic/BamRead.h" |
---|
25 | #endif |
---|
26 | |
---|
27 | #include <cassert> |
---|
28 | #include <string> |
---|
29 | |
---|
30 | using namespace theplu::yat; |
---|
31 | |
---|
32 | void test1(test::Suite& suite); |
---|
33 | |
---|
34 | int main(int argc, char* argv[]) |
---|
35 | { |
---|
36 | test::Suite suite(argc, argv); |
---|
37 | #ifndef HAVE_LIBBAM |
---|
38 | suite.out() << "no libbam\n"; |
---|
39 | return EXIT_SKIP; |
---|
40 | #endif |
---|
41 | #ifndef HAVE_SAMTOOLS |
---|
42 | suite.out() << "no samtools\n"; |
---|
43 | return EXIT_SKIP; |
---|
44 | #endif |
---|
45 | #ifdef HAVE_LIBBAM |
---|
46 | test1(suite); |
---|
47 | #endif |
---|
48 | return suite.return_value(); |
---|
49 | } |
---|
50 | |
---|
51 | #ifdef HAVE_LIBBAM |
---|
52 | using namespace omic; |
---|
53 | |
---|
54 | void test1(test::Suite& suite) |
---|
55 | { |
---|
56 | std::string file = "../../data/foo.sorted.bam"; |
---|
57 | |
---|
58 | InBamFile in; |
---|
59 | in.open(file); |
---|
60 | BamRead bam; |
---|
61 | in.read(bam); |
---|
62 | std::string str = "AGCTTTGTTATTATTTGAGGGTGTGGTTCAGTTGTAAACAGTGTATG" |
---|
63 | "TTTTAGAATTTGTGTTATTGTGATGGCGATGACCAAGTACAACATATTTCCCA"; |
---|
64 | std::string seq = bam.sequence(); |
---|
65 | if (str!=seq) { |
---|
66 | suite.err() << "incorrect sequence: '" << bam.sequence() << "'\n"; |
---|
67 | suite.err() << "expected: '" << str << "'\n"; |
---|
68 | suite.add(false); |
---|
69 | } |
---|
70 | } |
---|
71 | #endif |
---|