A library for working with phylogenetic and population genetic data.
v0.32.0
sam_flags.hpp
Go to the documentation of this file.
1
#ifndef GENESIS_POPULATION_FORMAT_SAM_FLAGS_H_
2
#define GENESIS_POPULATION_FORMAT_SAM_FLAGS_H_
3
4
/*
5
Genesis - A toolkit for working with phylogenetic data.
6
Copyright (C) 2014-2024 Lucas Czech
7
8
This program is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21
Contact:
22
Lucas Czech <lczech@carnegiescience.edu>
23
Department of Plant Biology, Carnegie Institution For Science
24
260 Panama Street, Stanford, CA 94305, USA
25
*/
26
34
#ifdef GENESIS_HTSLIB
35
36
#include <cstdint>
37
#include <string>
38
39
namespace
genesis
{
40
namespace
population {
41
42
// =================================================================================================
43
// SAM/BAM/CRAM Flags
44
// =================================================================================================
45
46
// Enum not used at the moment, as we instead simply use the htslib int bit sets.
47
// Keeping it here, in case it comes in useful in the future.
48
49
// /**
50
// * @brief Flags for read properties as used in SAM/BAM/CRAM files.
51
// *
52
// * Each read in these file formats can be annotated by certain flags that mark its status:
53
// *
54
// * | Value | Name | Description |
55
// * | ----- | ------------- | --------------------------------------------------------------- |
56
// * | 0x1 | PAIRED | paired-end (or multiple-segment) sequencing technology |
57
// * | 0x2 | PROPER_PAIR | each segment properly aligned according to the aligner |
58
// * | 0x4 | UNMAP | segment unmapped |
59
// * | 0x8 | MUNMAP | next segment in the template unmapped |
60
// * | 0x10 | REVERSE | SEQ is reverse complemented |
61
// * | 0x20 | MREVERSE | SEQ of the next segment in the template is reverse complemented |
62
// * | 0x40 | READ1 | the first segment in the template |
63
// * | 0x80 | READ2 | the last segment in the template |
64
// * | 0x100 | SECONDARY | secondary alignment |
65
// * | 0x200 | QCFAIL | not passing quality controls |
66
// * | 0x400 | DUP | PCR or optical duplicate |
67
// * | 0x800 | SUPPLEMENTARY | supplementary alignment |
68
// *
69
// * We use the same flag values as htslib, so these can be translated at will.
70
// * Using an enum here instead of their direct values ensures a bit of typesafety on our end.
71
// *
72
// * See http://www.htslib.org/doc/samtools-flags.html and
73
// * https://broadinstitute.github.io/picard/explain-flags.html for details.
74
// */
75
// enum class SamFlag : int
76
// {
77
// /**
78
// * @brief The read is paired in sequencing, no matter whether it is mapped in a pair.
79
// */
80
// kPaired = 1,
81
//
82
// /**
83
// * @brief The read is mapped in a proper pair.
84
// */
85
// kProperPair = 2,
86
// /**
87
//
88
// * @brief The read itself is unmapped; conflictive with BAM_FPROPER_PAIR.
89
// */
90
// kUnmapped = 4,
91
//
92
// /**
93
// * @brief The mate is unmapped.
94
// */
95
// kMateUnmapped = 8,
96
//
97
// /**
98
// * @brief The read is mapped to the reverse strand.
99
// */
100
// kReverse = 16,
101
//
102
// /**
103
// * @brief The mate is mapped to the reverse strand.
104
// */
105
// kMateReverse = 32,
106
//
107
// /**
108
// * @brief This is read1.
109
// */
110
// kRead1 = 64,
111
//
112
// /**
113
// * @brief This is read2.
114
// */
115
// kRead2 = 128,
116
//
117
// /**
118
// * @brief Not primary alignment.
119
// */
120
// kSecondary = 256,
121
//
122
// /**
123
// * @brief QC failure.
124
// */
125
// kQcFail = 512,
126
//
127
// /**
128
// * @brief Optical or PCR duplicate.
129
// */
130
// kDuplicate = 1024,
131
//
132
// /**
133
// * @brief Supplementary alignment.
134
// */
135
// kSupplementary = 2048
136
// };
137
138
// =================================================================================================
139
// Flag Helper Functions
140
// =================================================================================================
141
161
int
string_to_sam_flag
( std::string
const
& value );
162
173
std::string
sam_flag_to_string
(
int
flags );
174
175
}
// namespace population
176
}
// namespace genesis
177
178
#endif // htslib guard
179
#endif // include guard
genesis::population::string_to_sam_flag
int string_to_sam_flag(std::string const &value)
Parse a string as a set of flags for sam/bam/cram reads.
Definition:
sam_flags.cpp:81
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition:
placement/formats/edge_color.cpp:42
genesis::population::sam_flag_to_string
std::string sam_flag_to_string(int flags)
Turn a set of flags for sam/bam/cram reads into their textual representation.
Definition:
sam_flags.cpp:132
lib
genesis
population
format
sam_flags.hpp
Generated on Mon Aug 5 2024 16:57:53 for genesis by
1.8.17