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

Wish list: aux tag iterator API #1319

Closed
jkbonfield opened this issue Aug 10, 2021 · 0 comments · Fixed by #1354
Closed

Wish list: aux tag iterator API #1319

jkbonfield opened this issue Aug 10, 2021 · 0 comments · Fixed by #1354

Comments

@jkbonfield
Copy link
Contributor

(Put here simply so we don't forget it.)

The (now merged) Samtools PR samtools/samtools#516 copies over the aux_type2size and skip_aux functions as it has a mechanism of iterating through the tag list.

Something akin to these functions ought to be public, although perhaps not these explicit interfaces. I think a more iterator focused approach would work. Eg in a similar fashion to kstring initialisations:

bam_tag_iter_t it = BAM_TAG_ITER_INITIALIZE;  // or bam_tag_iter_initialize(&it) if we want it opaque.
uint8_t *tag;
while ((tag = bam_aux_next(b, &it))) {
    // do stuff
}

The tag initialise function just nulls the contents. The bam_aux_next function skips to the next tag, or identifies the first one if the pointer hasn't been set. The BAM data end pointer from skip_aux can be internalised into the data type and hidden from the user. Alternatively we just expose skip_aux as it is now and have an aux_end function to avoid the mess of grubbing through b->data + b->l_data internals.

aux_type2size may be useful as-is, as we already have search functions so being able to return how big it is would be helpful for more than this case. However it could be renamed perhaps - maybe bam_aux_size.

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 a pull request may close this issue.

1 participant