Entire Sequence from Bam File using Python Pysam Module
0
0
Entering edit mode
8.2 years ago
BioICoder ▴ 40

Hello there,

Is there away to be able to extract the entire chromosome sequence from the bam file using the Pysam Python module? I am trying to analyze the entire aligned sequence of some chromosome for instance chr1 from NGS.

Thanks a lot in advance.

alignment Python Pysam NGS • 3.1k views
ADD COMMENT
1
Entering edit mode

if you mean extracting the reads aligned to chr1 you can use

import pysam
samfile = pysam.AlignmentFile("your.bam", "rb")
for read in samfile.fetch('chr1', chr_beginning, chr_end):
          print read
samfile.close()

and if you want extract your chromosome in bam format using samtools

samtools index your.bam
samtools view -bh your.bam chr1  > small.bam
ADD REPLY

Login before adding your answer.

Traffic: 1756 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6