Skip to content

Added support for persisting IndexedReads index to disk#1037

Open
Prakash2403 wants to merge 1 commit intopysam-developers:masterfrom
Prakash2403:master
Open

Added support for persisting IndexedReads index to disk#1037
Prakash2403 wants to merge 1 commit intopysam-developers:masterfrom
Prakash2403:master

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