source: branches/0.11-stable/test/bam_pair_analyse.cc @ 3233

Last change on this file since 3233 was 3233, checked in by Peter, 9 years ago

refs #797. Fix the bug in 0.11.x

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: bam_pair_analyse.cc 3233 2014-05-23 09:47:19Z peter $
2//
3// Copyright (C) 2012, 2013, 2014 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#if HAVE_LIBBAM
21#include "yat/omic/algorithm.h"
22#include "yat/omic/BamRead.h"
23#include "yat/omic/BamReadIterator.h"
24#endif
25
26// include Suite.h late to see that algorithm.h is OK to include
27// first. See ticket #793.
28#include "Suite.h"
29using namespace theplu::yat;
30
31void test1(test::Suite& suite);
32
33int main(int argc, char* argv[])
34{
35  test::Suite suite(argc, argv);
36#ifndef HAVE_LIBBAM
37  suite.out() << "no libbam\n";
38  return EXIT_SKIP;
39#endif
40#ifndef HAVE_SAMTOOLS
41  suite.out() << "no samtools available\n";
42  return EXIT_SKIP;
43#endif
44
45#ifdef HAVE_LIBBAM
46  test1(suite);
47#endif
48  return suite.return_value();
49}
50
51
52#ifdef HAVE_LIBBAM
53using namespace omic;
54
55class Counter
56{
57public:
58  Counter(void) : n_(0) {}
59  void operator()(const BamRead& first, const BamRead& second)
60  {
61    if (first.core().qual >= 20 && second.core().qual >= 20)
62      ++n_;
63  }
64  int n_;
65};
66
67void test1(test::Suite& suite)
68{
69  std::string file = "../../data/foo.sorted.bam";
70
71  InBamFile is(file);
72  BamReadIterator iter(is);
73  BamReadIterator end;
74  Counter counter;
75  bam_pair_analyse(iter, end, counter);
76  suite.out() << counter.n_ << "\n";
77  suite.add(counter.n_==395);
78  is.close();
79}
80#endif
Note: See TracBrowser for help on using the repository browser.