let me know examples of "pysam.view()" for counting BAM.
1
0
Entering edit mode
8.4 years ago
mink2mink2 • 0

Hi, guys. I'm a beginer of pysam. I got some body's code.

import pysam
cn = pysam.view("-F4","-c","./a.bam");
print cn;

when I use pysam 0.7.7, it works well. However, when I use pysam 0.9.1.4, it returns "Segmentation Fault".

Actually, I don't know those code's meaning. So, I just tested below code by myself.

import pysam
cn = pysam.view("./a.bam");
print cn;

And the result is "MemoryError".

Could anybody give me any examples for testing my pysam 0.9.1.4?

I really don't know what problem is.

I want to know whether I missed something on installation or my pysam(0.9.1.4) has bug something..etc.

Please save my code..

pysam samtools view • 3.4k views
ADD COMMENT
0
Entering edit mode

What do you try to achieve?

ADD REPLY
1
Entering edit mode
8.4 years ago
pld 5.1k

Looks like you ran out of memory: https://docs.python.org/3/library/exceptions.html#exceptions.MemoryError

Your problem is that in the second snippet, you aren't returning the count of reads, you're returning the BAM data. This is causing your machine to run out of memory.

You need to add the -c option when calling pysam.view.

I would suggest reading the documentation for both pysam and samtools before venturing further.

ADD COMMENT
0
Entering edit mode

Thank you for your helping!! I will test with cn = pysam.view("-c", "a.bam");

ADD REPLY
0
Entering edit mode

the result is "Segmentation Fault"..

So I just test on the terminal next code.

$samtools view -c a.bam
9238589

I guess my samtools has no problem..

What should I test for inspection?

Please give me any hint...

ADD REPLY
0
Entering edit mode

Can you post the full error when you run pysam?

ADD REPLY
0
Entering edit mode

Hm, works for me, but I'm using version 0.9.

ADD REPLY
0
Entering edit mode

Thank you for your reply, and at that time, I decided not to use pysam.view. Thanks a lot.

ADD REPLY

Login before adding your answer.

Traffic: 2037 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