pysam.PileupRead.alignment doesn't return a pysam.AlignedSegment object

174 views
Skip to first unread message

Pubudu Samarakoon

unread,
Oct 29, 2014, 1:08:53 PM10/29/14
to pysam-us...@googlegroups.com
Dear all

I'm new a new member to the group.
I'm trying to access pysam.AlignedSegment object from pysam.PileupRead alignment function. However looks like I'm only receiving object from AlignedRead class.

import pysam
import itertools

samfile = pysam.Samfile( "bam/sample.bam", "rb" )
for c in samfile.pileup('1', 10000, 10001):
    for r in c.pileups:
    print c.__class__.__name__, r.__class__.__name__, r.alignment.__class__.__name__

samfile.close()

> Results
PileupProxy PileupRead AlignedRead

Any ideas, suggestions or advices are highly appreciated

Thank you very much
Pubudu

Pubudu Samarakoon

unread,
Oct 29, 2014, 1:38:31 PM10/29/14
to pysam-us...@googlegroups.com
Hi again

To be more specific on the error I'm getting, please check the following code.


import pysam
import itertools

samfile = pysam.Samfile( "bam/sample.bam", "rb" )
for c in samfile.pileup('1', 10000, 10001):
    for r in c.pileups:
    print r.alignment.next_reference_start

samfile.close()

> Error
Traceback (most recent call last):
  File "samRead.py", line 41, in <module>
    print r.alignment.next_reference_start
AttributeError: 'pysam.csamfile.AlignedRead' object has no attribute 'next_reference_start'



Any ideas, suggestions or advices are highly appreciated

Best
Pubudu
Reply all
Reply to author
Forward
0 new messages