3
$\begingroup$

Is it faster to use the PySam package to run a python script on a bam

for read in samfile.fetch('chr1', 100, 120):
 print read

compared to using a pipe and reading line by line from stdin in a python script.

samtools view example.bam | python script.py.

for line in tqdm(sys.stdin, total=number_of_lines)
$\endgroup$
5
$\begingroup$

It's a bit hard to say with certainty, though I would suspect that offloading the BAM decompression by using a pipe will be very slightly faster. Note that decompressing and parsing the BAM file will not be the bottleneck in your processing, rather the python script itself will be.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.