Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added sam_flag module #440

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rLannes
Copy link

@rLannes rLannes commented Sep 30, 2024

Description:

This pull request introduces a new module, bam::sam_flag, to facilitate easier handling of SAM flags. The module provides a more intuitive and type-safe way to work with SAM flags, improving code readability and reducing potential errors.

Key features:

  1. SamFlag struct: A zero-cost abstraction that contains constants for all standard SAM flags.
  2. check_flag() function: A utility function to easily check for the presence or absence of specific flags.

Benefits:

  • Improved code readability when working with SAM flags.
  • Reduced chance of errors from manual flag manipulation.
  • Type-safe constants for all standard SAM flags.
  • Easy-to-use function for checking flag combinations.

Implementation choice:
The main design choice was to use a struct with associated constants rather than an enum to represent the flag values. The benefit is no runtime cost, but it comes at the cost of not being as nice to work with as an enum.

Example usage:

let read_flag = 65; // PAIRED (1) + FIRST_IN_PAIR (64)
assert!(check_flag(read_flag, SamFlag::PAIRED + SamFlag::FIRST_IN_PAIR, SamFlag::READ_UNMAPPED));

@rLannes rLannes changed the title buadded SamFlag module [feat] added sam_flag module Sep 30, 2024
@rLannes rLannes changed the title [feat] added sam_flag module feat added sam_flag module Sep 30, 2024
@rLannes rLannes changed the title feat added sam_flag module feat: added sam_flag module Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant