| 1 |
#include <pbcopper/data/CigarOperation.h> |
| 2 |
|
| 3 |
#include <string_view> |
| 4 |
|
| 5 |
#include <cassert> |
| 6 |
|
| 7 |
namespace PacBio { |
| 8 |
namespace Data { |
| 9 |
|
| 10 |
char CigarOperation::Char() const { return CigarOperation::TypeToChar(Type()); } |
| 11 |
|
| 12 |
void CigarOperation::EnableAutoValidation() { AutoValidateCigar = true; } |
| 13 |
|
| 14 |
void CigarOperation::DisableAutoValidation() { AutoValidateCigar = false; } |
| 15 |
|
| 16 |
char CigarOperation::TypeToChar(const CigarOperationType type) |
| 17 |
{ |
| 18 |
constexpr std::string_view LOOKUP_TABLE{"MIDNSHP=XB??????"}; |
| 19 |
return LOOKUP_TABLE[static_cast<int32_t>(type)]; |
| 20 |
} |
| 21 |
|
| 22 |
bool ConsumesQuery(const CigarOperationType type) noexcept |
| 23 |
{ |
| 24 |
// X=PHSNDIM |
| 25 |
constexpr uint32_t LOOKUP_TABLE{0b110010011}; |
| 26 |
const auto val = static_cast<uint32_t>(type); |
| 27 |
assert(val <= 8); |
| 28 |
|
| 29 |
return (LOOKUP_TABLE >> val) & 0b1U; |
| 30 |
} |
| 31 |
|
| 32 |
bool ConsumesReference(const CigarOperationType type) noexcept |
| 33 |
{ |
| 34 |
// X=PHSNDIM |
| 35 |
constexpr uint32_t LOOKUP_TABLE{0b110001101}; |
| 36 |
const auto val = static_cast<uint32_t>(type); |
| 37 |
assert(val <= 8); |
| 38 |
|
| 39 |
return (LOOKUP_TABLE >> val) & 0b1U; |
| 40 |
} |
| 41 |
|
| 42 |
} // namespace Data |
| 43 |
} // namespace PacBio |