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

Implement pileup() for unindexed files and/or SAM files #916

Merged
merged 1 commit into from
May 12, 2020

Conversation

jmarshall
Copy link
Member

@jmarshall jmarshall commented May 4, 2020

Reorganise pileup so that it chooses between IteratorColumnRegion/ IteratorColumnAllRefs/ IteratorColumnAll primarily by has_coord (i.e., whether contig+etc/region was specified) and secondarily by has_index.

Add IteratorColumnAll() which iterates as per HTS_IDX_REST, piling up the entire file, which works without an index and for SAM files. (Unfortunately sam_itr_next() does not work for SAM files (even for HTS_IDX_REST) prior to HTSlib 1.10. Instead we follow samtools mpileup's
lead and special case this to use sam_read1() at the bottom level instead of sam_itr_next().)

The common parts of the two _setup_iterator functions could in future be refactored…

…opers#916)

Reorganise pileup() so that it chooses between IteratorColumnRegion/
IteratorColumnAllRefs/IteratorColumnAll primarily by has_coord (i.e.,
whether contig+etc/region was specified) and secondarily by has_index.

Add IteratorColumnAll() which iterates as per HTS_IDX_REST, piling up the
entire file, which works without an index and for SAM files.  Fixes pysam-developers#915.

Unfortunately sam_itr_next() does not work for SAM files (even for
HTS_IDX_REST) prior to HTSlib 1.10. Instead we follow samtools mpileup's
lead and special case this to use sam_read1() at the bottom level
instead of an HTS_IDX_REST iterator. We duplicate __advance_all() and
__advance_nofilter() functions, but __advance_samtools() is itself
complicated enough that we just make it handle both cases instead.
@jmarshall jmarshall merged commit 9e7bc31 into pysam-developers:master May 12, 2020
@jmarshall jmarshall deleted the pileup-no-index branch May 12, 2020 11:20
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