Question: unmapped reads with pysam
1
gravatar for grant.hovhannisyan
7 weeks ago by
grant.hovhannisyan1.4k wrote:

I have a bam file produces by BWA-MEM. It has some unmapped reads, e.g.

D00733:389:CD1T7ANXX:3:1101:1572:2235   77  *   0   0   *   *   0   0   CAGTTTCACTGTATAAATTGCTTATACTTAGACATGCATGGCTTAATCTT  AAB=AFGDGCFFGGGGGGGGGCGGGGGGGGGGGGGGGGGGGGGGGGGGGF  AS:i:0  XS:i:0
D00733:389:CD1T7ANXX:3:1101:1572:2235   141 *   0   0   *   *   0   0   GTATCTTCTAGAGAGAGGGAATGGGCGAGAGAAAAAGAGATTTCGGTTTC  BBB@BGGGGGGGGFGGGGGGGGEGGGGGGDGFGGGGGGGGEGGGGGFGGG  AS:i:0  XS:i:0
D00733:389:CD1T7ANXX:3:1101:6797:2243   77  *   0   0   *   *   0   0   TGTCTGGACCTGGTGAGTTTCCCCGTGTTGAGTCAAATTAAGCCGCAGGC  3A<0BDGGGGGGGGGGGGGFGGGGGFGGGGGGGGGGGGGGGGGGGGGGGG  AS:i:0  XS:i:0

I use pysam to count some stats on the bam file, but for some reason pysam does not find these unmapped reads.

bam=pysam.AlignmentFile(file,"rb")
for line in bam.fetch():
    line=line.tostring(bam)
    line=line.split("\t")
    if  line[2]=="*":
        print(line)

The code does not return anything

Any ideas how to fix this?

Thanks

pysam • 152 views
ADD COMMENTlink modified 7 weeks ago • written 7 weeks ago by grant.hovhannisyan1.4k
2
gravatar for Asaf
7 weeks ago by
Asaf5.3k
Israel
Asaf5.3k wrote:

you should add until_eof=True in the fetch()

ADD COMMENTlink written 7 weeks ago by Asaf5.3k

Accepted :) Thank you!

ADD REPLYlink written 7 weeks ago by grant.hovhannisyan1.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2316 users visited in the last hour