hts_itr_t reuse

Open
#527 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
c

Research direction

Start by reviewing the hts_itr_t lifecycle described here, including sam_itr_queryi() and sam_itr_next(), and the linked mailing-list discussion. Compare the proposed clone/fork and reset behaviors, then define the API and tests needed to show that repeated iteration over the same file and region is safe.

Written by the indexing model from the issue text.

Description

This is a follow-up to a question I asked in the samtools-devel mailinglist found here.

The problem in question arises if one wants to use an identical instance of a hts_itr_t struct multiple times (same file, same region). Since the struct gets changed during the iteration process (e.g. through sam_itr_next()) it would be ideal to have a sort of "source" iterator which stays in the iterators original state (e.g. created through sam_itr_queryi()), from which the iterator used within sam_itr_next() gets cloned so only the clone gets changed. Alternatively, if the iterator could be reset safely in between uses that would also solve the problem. At present, this seems to be not safe without destroying and recreating the struct.

The two scenarios I describe above could be handled with something like a hts_itr_clone()/hts_itr_fork() function, or with a hts_itr_reset() function as Rob proposes in his mailing list answer. Would an implementation of something like that be feasible?

Thanks!

Dominant language
C
Stars
950
Forks
475
Avg merge
3d 13h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/htslib

All issues in samtools/htslib

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.