yat  0.12.3pre
BamRead.h
1 #ifndef theplu_yat_omic_bam_read
2 #define theplu_yat_omic_bam_read
3 
4 // $Id: BamRead.h 3302 2014-08-20 06:55:24Z peter $
5 
6 /*
7  Copyright (C) 2012, 2013, 2014 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 #include YAT_SAM_HEADER
28 
29 #include "yat/utility/Aligner.h"
30 // This file has to be included to keep compatibility with yat 0.11
31 #include "yat/utility/Cigar.h"
32 #include "yat/utility/deprecate.h"
33 
34 #include <functional>
35 #include <string>
36 #include <vector>
37 
38 namespace theplu {
39 namespace yat {
40 namespace omic {
41 
53  class BamRead
54  {
55  public:
62  BamRead(void);
63 
67  BamRead(const BamRead& other);
68 
72  virtual ~BamRead(void);
73 
77  const BamRead& operator=(const BamRead& rhs);
78 
84  const uint8_t* aux(void) const;
85 
97  const uint8_t* aux(const char tag[2]) const;
98 
111  void aux_append(const char tag[2], char type, int len, uint8_t* data);
112 
120  void aux_del(const char tag[2]);
121 
127  int aux_size(void) const;
128 
134  const bam1_core_t& core(void) const;
135 
141  bam1_core_t& core(void);
142 
149  const uint32_t* cigar(void) const;
150 
154  uint32_t cigar(size_t i) const;
155 
159  uint32_t cigar_op(size_t i) const;
160 
164  uint32_t cigar_oplen(size_t i) const;
165 
169  std::string cigar_str(void) const;
170 
179  void cigar(const std::vector<uint32_t>& c) YAT_DEPRECATE;
180 
188  void cigar(const utility::Aligner::Cigar& cigar);
189 
198  int32_t end(void) const;
199 
207  uint16_t flag(void) const;
208 
212  int32_t mpos(void) const;
213 
217  int32_t mtid(void) const;
218 
224  const char* name(void) const;
225 
231  void name(const std::string& n);
232 
236  int32_t pos(void) const;
237 
241  uint8_t qual(size_t i) const;
242 
251  void qual(size_t i, uint8_t q);
252 
258  std::string sequence(void) const;
259 
265  uint8_t sequence(size_t index) const;
266 
276  void sequence(size_t i, uint8_t x);
277 
283  void sequence(const std::string& seq, const std::vector<uint8_t>& qual);
284 
288  uint32_t sequence_length(void) const;
289 
295  void swap(BamRead& other);
296 
300  int32_t tid(void) const;
301 
302  private:
303  // ensure capacity of data pointer is (at least) n
304  void reserve(int n);
305 
306  bam1_t* bam_;
307 
308  friend class InBamFile;
309  friend class OutBamFile;
310  friend class BamReadIterator;
311  uint32_t calend(const bam1_core_t *c, const uint32_t *cigar) const;
312  };
313 
322  void swap(BamRead& lhs, BamRead& rhs);
323 
332  bool soft_clipped(const BamRead& bam);
333 
342  uint32_t left_soft_clipped(const BamRead& bam);
343 
352  uint32_t right_soft_clipped(const BamRead& bam);
353 
363  bool same_query_name(const BamRead& lhs, const BamRead& rhs);
364 
373  struct BamLessPos
374  : public std::binary_function<const BamRead&, const BamRead&, bool>
375  {
382  bool operator()(const BamRead& lhs, const BamRead& rhs) const;
383  };
384 
385 
394  struct BamLessEnd
395  : public std::binary_function<const BamRead&, const BamRead&, bool>
396  {
403  bool operator()(const BamRead& lhs, const BamRead& rhs) const;
404  };
405 
406 }}}
407 #endif
void aux_del(const char tag[2])
remove a tag in aux field
virtual ~BamRead(void)
Destructor.
uint32_t sequence_length(void) const
int32_t tid(void) const
chromosome ID
BamRead(void)
default constructor
bool operator()(const BamRead &lhs, const BamRead &rhs) const
bool operator()(const BamRead &lhs, const BamRead &rhs) const
int32_t end(void) const
rightmost coordinate
const char * name(void) const
const bam1_core_t & core(void) const
access core data struct
Class holding a bam query.
Definition: BamRead.h:53
uint32_t cigar_op(size_t i) const
const BamRead & operator=(const BamRead &rhs)
assignment operator
Definition: BamRead.h:373
int aux_size(void) const
int32_t mtid(void) const
Chromosome ID for mate.
std::string sequence(void) const
void aux_append(const char tag[2], char type, int len, uint8_t *data)
append a new tag to aux field
const uint8_t * aux(void) const
Compact Idiosyncratic Gapped Alignment Report.
Definition: Aligner.h:177
Definition: BamFile.h:176
int32_t mpos(void) const
leftmost position for mate
Definition: BamRead.h:394
Definition: BamFile.h:105
void swap(BamRead &other)
uint32_t cigar_oplen(size_t i) const
class to iterate through a InBamFile
Definition: BamReadIterator.h:60
uint16_t flag(void) const
bitwise flag
uint8_t qual(size_t i) const
int32_t pos(void) const
0-based laftmost coordinate
const uint32_t * cigar(void) const
access CIGAR array
std::string cigar_str(void) const

Generated on Mon Jun 1 2015 12:29:51 for yat by  doxygen 1.8.5