yat  0.13.2pre
BamHeader.h
1 #ifndef theplu_yat_omic_bam_header
2 #define theplu_yat_omic_bam_header
3 
4 // $Id: BamHeader.h 3417 2015-05-25 01:35:59Z peter $
5 
6 /*
7  Copyright (C) 2012, 2013, 2014, 2015 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 
28 
29 #include YAT_SAM_HEADER
30 
31 #include <map>
32 #include <string>
33 
34 namespace theplu {
35 namespace yat {
36 namespace omic {
37 
38 #ifndef YAT_HAVE_HTSLIB
39  namespace detail {
40  bam_header_t * bam_hdr_dup(const bam_header_t* other);
41  }
42 #endif
43 
56  class BamHeader
57  {
58  public:
62  BamHeader(void);
63 
67  ~BamHeader(void);
68 
72  BamHeader(const BamHeader&);
73 
85  void parse_region(const std::string& reg, int& tid, int& begin,
86  int& end) const;
87 
102  const std::string& program_group(const std::string& id,
103  const std::string& key) const;
104 
118  //
119  const std::string& read_group(const std::string& id,
120  const std::string& key) const;
121 
127  void swap(BamHeader& other);
128 
132  const char* target_name(size_t tid) const;
133 
137  uint32_t target_length(size_t tid) const;
138 
144  std::string text(void) const;
145 
153  void text(const std::string& txt);
154 
164  int32_t tid(const std::string& name) const;
165 
169  int32_t n_targets(void) const;
170 
174  BamHeader& operator=(const BamHeader& rhs);
175 
176  private:
177 #ifndef YAT_HAVE_HTSLIB
178  typedef bam_header_t bam_hdr_t;
179 #endif
180  bam_hdr_t* header_;
181  typedef std::map<std::string, std::string> strMap;
182  typedef std::map<std::string, strMap> strMap2;
183  mutable strMap2 read_group_;
184  mutable strMap2 program_group_;
185 
186  friend class InBamFile;
187  friend class OutBamFile;
188 
189  const std::string& group(strMap2& map, const std::string& type,
190  const std::string& id,
191  const std::string& key) const;
192 
193  // using compiler generated copy and assignment
194  };
195 
203  void swap(BamHeader& lhs, BamHeader& rhs);
204 
205 }}}
206 #endif
BamHeader(void)
Default constructor.
int32_t tid(const std::string &name) const
inverse of target_name(size_t)
const std::string & program_group(const std::string &id, const std::string &key) const
Access value in @PG lines.
std::string text(void) const
int32_t n_targets(void) const
Wrapper around bam_hdr_t struct.
Definition: BamHeader.h:56
const std::string & read_group(const std::string &id, const std::string &key) const
Access value in @RG lines.
uint32_t target_length(size_t tid) const
const char * target_name(size_t tid) const
void parse_region(const std::string &reg, int &tid, int &begin, int &end) const
void swap(BamHeader &other)
Exchanges the content in *this and other.
BamHeader & operator=(const BamHeader &rhs)
assignment operator
~BamHeader(void)
Destructor.
Definition: BamFile.h:213
Definition: BamFile.h:118

Generated on Wed Jan 4 2017 02:23:07 for yat by  doxygen 1.8.5