|
12 | 12 | */ |
13 | 13 |
|
14 | 14 | #include <algorithm> |
| 15 | +#include <cstddef> |
| 16 | +#include <cstdint> |
15 | 17 | #include <cstdlib> |
16 | 18 | #include <iomanip> |
| 19 | +#include <iterator> |
| 20 | +#include <sstream> |
| 21 | +#include <string> |
| 22 | +#include <vector> |
17 | 23 |
|
18 | 24 | template <typename T> |
19 | 25 | inline auto |
@@ -70,3 +76,45 @@ struct progress_bar { |
70 | 76 |
|
71 | 77 | static const std::size_t max_bar_width = 72; |
72 | 78 | }; |
| 79 | + |
| 80 | +// from 30 April 2020 SAM documentation |
| 81 | +// 1 0x1 template having multiple segments in sequencing |
| 82 | +// 2 0x2 each segment properly aligned according to the aligner |
| 83 | +// 4 0x4 segment unmapped |
| 84 | +// 8 0x8 next segment in the template unmapped |
| 85 | +// 16 0x10 SEQ being reverse complemented |
| 86 | +// 32 0x20 SEQ of the next segment in the template being reverse complemented |
| 87 | +// 64 0x40 the first segment in the template |
| 88 | +// 128 0x80 the last segment in the template |
| 89 | +// 256 0x100 secondary alignment |
| 90 | +// 512 0x200 not passing filters, such as platform/vendor quality controls |
| 91 | +// 1024 0x400 PCR or optical duplicate |
| 92 | +// 2048 0x800 supplementary alignment |
| 93 | + |
| 94 | +namespace samflags { |
| 95 | +// ADS: names of flags adjusted to how we typically interpret |
| 96 | +static const std::uint16_t read_paired = 0x1; |
| 97 | +static const std::uint16_t read_pair_mapped = 0x2; |
| 98 | +static const std::uint16_t read_unmapped = 0x4; |
| 99 | +static const std::uint16_t mate_unmapped = 0x8; |
| 100 | +static const std::uint16_t read_rc = 0x10; |
| 101 | +static const std::uint16_t mate_rc = 0x20; |
| 102 | +static const std::uint16_t template_first = 0x40; |
| 103 | +static const std::uint16_t template_last = 0x80; |
| 104 | +static const std::uint16_t secondary_aln = 0x100; |
| 105 | +static const std::uint16_t below_quality = 0x200; |
| 106 | +static const std::uint16_t pcr_duplicate = 0x400; |
| 107 | +static const std::uint16_t supplementary_aln = 0x800; |
| 108 | +constexpr auto |
| 109 | +check(const std::uint16_t to_check, const std::uint16_t &f) -> bool { |
| 110 | + return to_check & f; |
| 111 | +} |
| 112 | +constexpr auto |
| 113 | +set(std::uint16_t &to_set, const std::uint16_t f) { |
| 114 | + to_set |= f; |
| 115 | +} |
| 116 | +constexpr auto |
| 117 | +unset(std::uint16_t &to_unset, const std::uint16_t f) { |
| 118 | + to_unset &= ~f; |
| 119 | +} |
| 120 | +} // namespace samflags |
0 commit comments