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

Added support for persisting IndexedReads index to disk #1037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Prakash2403
Copy link

@Prakash2403 Prakash2403 commented Aug 26, 2021

I recently came across a situation where I needed to persist the IndexedReads index to disk. I was successfully able to do it and wanted to contribute this feature to this repository.

Steps on how to store/load the index

  1. How to store the index to the disk
>>> from pysam import AlignmentFile, IndexedReads
>>> bam: AlignmentFile = AlignmentFile('examples/sample.bam')
>>> name_index: IndexedReads = IndexedReads(bam)
>>> name_index.build()
>>> name_index.store('/some/path/to/sample.json')
  1. How to load the index from the disk
>>> from pysam import AlignmentFile, IndexedReads
>>> bam: AlignmentFile = AlignmentFile('examples/sample.bam')
>>> name_index: IndexedReads = IndexedReads(bam)
>>> name_index.load('/some/path/to/sample.json')

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.

2 participants