Greg Dougherty
Greg Dougherty

Reputation: 3471

How do i get and use AlignmentHeader from pysam?

I need to pull header information from a cram file for use in python code. This seemed to be a good use for pysam.

however, I can not find any pysam sample code that lets you look at the header of an existing file.

pysam has the AlignmentHeader class, but nowhere in the pysam git repository can I find any indication of how I would use it, other than creating one to create a file.

Which is not the point.

So, does pysam let you get header information?

Upvotes: 0

Views: 392

Answers (1)

Greg Dougherty
Greg Dougherty

Reputation: 3471

Turns out the answer is:

import pysam
cram = pysam.AlignmentFile (theCram, 'rc')
cramHeader = cram.header.to_dict ()

Hopefully this will help someone else in the future

Upvotes: 1

Related Questions