1 | #ifndef theplu_yat_omic_bam_header |
---|
2 | #define theplu_yat_omic_bam_header |
---|
3 | |
---|
4 | // $Id: BamHeader.h 3188 2014-03-25 10:24:29Z 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 | |
---|
27 | #include YAT_BAM_HEADER |
---|
28 | |
---|
29 | #include <string> |
---|
30 | |
---|
31 | namespace theplu { |
---|
32 | namespace yat { |
---|
33 | namespace omic { |
---|
34 | |
---|
35 | /** |
---|
36 | \brief Wrapper around bam_header_t struct. |
---|
37 | |
---|
38 | Class is typically created via InBamFile::header(). |
---|
39 | |
---|
40 | It is possible to copy and assign a BamHeader, but note that a |
---|
41 | BamHeader does not own underlying data. The underlying data is |
---|
42 | owned by the InBamFile and the BamHeader is thus invalid after |
---|
43 | the corresponding InBamFile has been destroyed. |
---|
44 | |
---|
45 | \since New in yat 0.10 |
---|
46 | */ |
---|
47 | class BamHeader |
---|
48 | { |
---|
49 | public: |
---|
50 | /** |
---|
51 | \brief Default constructor |
---|
52 | */ |
---|
53 | BamHeader(void); |
---|
54 | |
---|
55 | /** |
---|
56 | Parse a region in the format: 'chr2:100,000-200,000 and return |
---|
57 | values in variables \a tid, \a begin and \a end. \a reg is |
---|
58 | 1-based and \a begin and \a end are 0-based, i.e., |
---|
59 | "chr2:100,000-200,000" will set \a begin = 99999 and \a end = |
---|
60 | 200000. |
---|
61 | |
---|
62 | \see bam_parse_region |
---|
63 | |
---|
64 | \throw utility::runtime_error on failure |
---|
65 | |
---|
66 | \since new in yat 0.11 |
---|
67 | */ |
---|
68 | void parse_region(const std::string& reg, int& tid, int& begin, |
---|
69 | int& end) const; |
---|
70 | |
---|
71 | /** |
---|
72 | Name of chromosome with ID \a tid |
---|
73 | */ |
---|
74 | const char* target_name(size_t tid) const; |
---|
75 | |
---|
76 | /** |
---|
77 | Length of chromosome with ID \a tid |
---|
78 | */ |
---|
79 | uint32_t target_length(size_t tid) const; |
---|
80 | |
---|
81 | /** |
---|
82 | \brief inverse of target_name(size_t) |
---|
83 | |
---|
84 | \note If \a name does not exist, behaviour is undefined. |
---|
85 | |
---|
86 | \since new in yat 0.11 |
---|
87 | */ |
---|
88 | int32_t tid(const std::string& name) const; |
---|
89 | |
---|
90 | /** |
---|
91 | Number of chromosomes |
---|
92 | */ |
---|
93 | int32_t n_targets(void) const; |
---|
94 | private: |
---|
95 | bam_header_t* header_; |
---|
96 | |
---|
97 | friend class InBamFile; |
---|
98 | friend class OutBamFile; |
---|
99 | BamHeader(bam_header_t* h); |
---|
100 | |
---|
101 | // using compiler generated copy and assignment |
---|
102 | //BamHeader(const BamHeader&); |
---|
103 | //BamHeader& operator=(const BamHeader& rhs); |
---|
104 | }; |
---|
105 | |
---|
106 | }}} |
---|
107 | #endif |
---|