source: trunk/test/bam_pair_analyse.cc @ 2902

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

test for bam_pair_analyse. refs #729

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1// $Id: bam_pair_analyse.cc 2902 2012-12-13 07:39:34Z peter $
2//
3// Copyright (C) 2012 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#include "yat/omic/algorithm.h"
23#include "yat/omic/BamRead.h"
24#include "yat/omic/BamReadIterator.h"
25
26using namespace theplu::yat;
27using namespace omic;
28
29class Counter
30{
31public:
32  Counter(void) : n_(0) {}
33  void operator()(const BamRead& first, const BamRead& second)
34  {
35    if (first.core().qual >= 20 && second.core().qual >= 20)
36      ++n_;
37  }
38  int n_;
39};
40
41
42int main(int argc, char* argv[])
43{
44#ifndef HAVE_SAMTOOLS
45  return EXIT_SKIP;
46#endif
47  test::Suite suite(argc, argv);
48
49  std::string file = "../../data/foo.sorted.bam";
50
51  InBamFile is(file);
52  BamReadIterator iter(is);
53  BamReadIterator end;
54  Counter counter;
55  bam_pair_analyse(iter, end, counter);
56
57  suite.out() << counter.n_ << "\n";
58
59  suite.add(counter.n_==395);
60
61  is.close();
62  return suite.return_value();
63}
Note: See TracBrowser for help on using the repository browser.