Hi there, I started to work with pysam
to get a BAM file into a Jupyther notebook. I mostly followed what indicated in the manual for importing the file:
file_bam = pysam.AlignmentFile("<file>.bam", "rb")
and to then visualize the header with:
print(file_bam.header)
Though, I wonder is there an easy command to print the body of the file as in samtools view
with all associated info? I looked up a bit and found this pysam.view("-S", "<file>.bam")
but it seems quite slow and couldn't understand the meaning of the -S
flag (which I could not find in the manual).
Apologies, for the question but I was looking for something fast&snappy like samtools
; thanks in advance!
@i.sudbery thanks a lot for the exhaustive explanation! I realized that the
for
causes indeed some issues with processing of the file in PyCharm. I will use the various method of the AlignedSegment object; it's just I wished for a comprehensive view of the file in just one command...