source: trunk/yat/omic/BamReadFilter.h @ 2994

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

new class BamReadFilter?. closes #738

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef theplu_yat_omic_bam_read_filter
2#define theplu_yat_omic_bam_read_filter
3
4// $Id: BamReadFilter.h 2994 2013-03-10 13:04:07Z peter $
5
6/*
7  Copyright (C) 2013 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "config_bam.h"
26#include YAT_BAM_HEADER
27
28namespace theplu {
29namespace yat {
30namespace omic {
31
32  class BamRead;
33
34  /**
35     \brief Filter bam reads
36
37     Class is specifically designed to be used with
38     boost::filter_iterator. The code below for example
39     \code
40     InBamFile in("example.bam");
41     BamReadIterator begin(in);
42     BamReadIterator end;
43     BamReadFilter filter(20, 0);
44     some_algo(make_filter_iterator(filter, begin, end),
45               make_filter_iterator(filter, end));
46     \endcode
47     iterates over all read with mapping quality 20 or greater.
48   */
49  class BamReadFilter
50  {
51  public:
52    /**
53       Create a functor which accepts reads with mapping quality \a
54       mapQ (or greater), flag must be unset in bits described by a \a
55       filter_flags, and flag must be set in bits described by \a
56       required_flags.
57     */
58    BamReadFilter(unsigned char mapQ, unsigned int filtered_flags=BAM_DEF_MASK,
59                  unsigned int required_flags=0);
60
61    /**
62       return true if 1) bam mapping quality is at least mapQ AND 2)
63       bam flags & filter_flags == 0 (no filter bit set) AND 3) bam
64       flags & required_flags == required_flags (all req bits set)
65    */
66    bool operator()(const yat::omic::BamRead& bam) const;
67  private:
68    unsigned char mapQ_;
69    unsigned int filtered_;
70    unsigned int required_;
71  };
72
73}}}
74#endif
Note: See TracBrowser for help on using the repository browser.