source: trunk/test/bam_pair_analyse.cc @ 3210

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

update copyright years

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: bam_pair_analyse.cc 3210 2014-05-05 06:10:02Z 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#include "Suite.h"
21
22using namespace theplu::yat;
23
24#if YAT_HAVE_LIBBAM
25#include "yat/omic/algorithm.h"
26#include "yat/omic/BamRead.h"
27#include "yat/omic/BamReadIterator.h"
28#endif
29
30void test1(test::Suite& suite);
31
32int main(int argc, char* argv[])
33{
34  test::Suite suite(argc, argv, true);
35
36#ifdef YAT_HAVE_LIBBAM
37  test1(suite);
38#endif
39  return suite.return_value();
40}
41
42
43#ifdef YAT_HAVE_LIBBAM
44using namespace omic;
45
46class Counter
47{
48public:
49  Counter(void) : n_(0) {}
50  void operator()(const BamRead& first, const BamRead& second)
51  {
52    if (first.core().qual >= 20 && second.core().qual >= 20)
53      ++n_;
54  }
55  int n_;
56};
57
58void test1(test::Suite& suite)
59{
60  std::string file = "../../data/foo.sorted.bam";
61
62  InBamFile is(file);
63  BamReadIterator iter(is);
64  BamReadIterator end;
65  Counter counter;
66  bam_pair_analyse(iter, end, counter);
67  if (!suite.add(counter.n_==395))
68    suite.err() << "n: " << counter.n_ << "; expected 395\n";
69  is.close();
70}
71#endif
Note: See TracBrowser for help on using the repository browser.