Question: Using Pysam to extract paired reads
1
gravatar for Linda
5.3 years ago by
Linda150
India
Linda150 wrote:

I am using Pysam to process a bam file containing paired reads. However, I get the error `AttributeError: 'csamtools.AlignedRead' object has no attribute 'rnext'` when I try to extract the chromosome that the mate of a read is aligned to. What am I doing wrong?

for row in samfile:

    print(samfile.getrname(row.rname)+' '+samfile.getrname(row.rnext))

It gives the read's refernce properly, however it gives an error for the mate's reference.

pysam bam • 2.8k views
ADD COMMENTlink modified 5.3 years ago by Andreas2.4k • written 5.3 years ago by Linda150
2

There are known issues with insufficient documentation for pysam. If you are comfortable with perl, you can try Bio::DB::Sam instead. It will do the same job with enough documentation for troubleshooting.

ADD REPLYlink written 5.3 years ago by rohan100
3
gravatar for Andreas
5.3 years ago by
Andreas2.4k
Singapore
Andreas2.4k wrote:

Hi,

Looks like your pysam installation is too old and doesn't support rnext (see also QA3.2 on https://github.com/BSSeeker/BSseeker2). Which version are you using? According to the logs rnext was introduced end of 2011, i.e. any version >= 0.6 should work.

Andreas

 

 

ADD COMMENTlink modified 5.3 years ago • written 5.3 years ago by Andreas2.4k

Yea, it is an old version that came along with the Enthought Python Distribution. Got it sorted out.

ADD REPLYlink written 5.2 years ago by Linda150
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: 861 users visited in the last hour