source: trunk/test/bam_pair_analyse.cc @ 3175

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

new class BamPair?. refs #784

  • 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 3175 2014-03-15 08:15:51Z peter $
2//
3// Copyright (C) 2012, 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
22using namespace theplu::yat;
23
24#if 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);
35#ifndef HAVE_LIBBAM
36  suite.out() << "no libbam\n";
37  return EXIT_SKIP;
38#endif
39#ifndef HAVE_SAMTOOLS
40  suite.out() << "no samtools available\n";
41  return EXIT_SKIP;
42#endif
43
44#ifdef HAVE_LIBBAM
45  test1(suite);
46#endif
47  return suite.return_value();
48}
49
50
51#ifdef HAVE_LIBBAM
52using namespace omic;
53
54class Counter
55{
56public:
57  Counter(void) : n_(0) {}
58  void operator()(const BamRead& first, const BamRead& second)
59  {
60    if (first.core().qual >= 20 && second.core().qual >= 20)
61      ++n_;
62  }
63  int n_;
64};
65
66void test1(test::Suite& suite)
67{
68  std::string file = "../../data/foo.sorted.bam";
69
70  InBamFile is(file);
71  BamReadIterator iter(is);
72  BamReadIterator end;
73  Counter counter;
74  bam_pair_analyse(iter, end, counter);
75  if (!suite.add(counter.n_==395))
76    suite.err() << "n: " << counter.n_ << "; expected 395\n";
77  is.close();
78}
79#endif
Note: See TracBrowser for help on using the repository browser.