Multithreading Python3 + Samtools
1
1
Entering edit mode
5.1 years ago
glihm ▴ 630

Hi there !

I am working on Ribosome Profiling data, and I want to use Python3 multithreading to speed up my program.

To describe the scope of my question:

I use python scripts that take as input alignment files like:

python3 python_script.py <(samtools view file.bam)

and I take it in charge in the script with the fileinput module (import fileinput). It works like a charm !

So related to this, do you think that it is safe to call 3 python scripts at the same time using the same file.bam (using the samtools view command) ? For instance:

python3 script1.py <(samtools view file.bam) &
python3 script2.py <(samtools view file.bam) &
python3 script3.py <(samtools view file.bam) &

I am not sure: if the samtools view command is called on the file.bam, can I safely read again this file with an other samtools view command ? The output is not a problem, every scripts will write a different file. I gave the example with 3 scripts, but I will certainly use 3 functions.

Any kind of help of suggestion will be highly appreciated.

Wocka

Python3 Samtools Multithreading RNA-Seq • 1.6k views
ADD COMMENT
2
Entering edit mode
5.1 years ago

You can call samtools (or any other program) any number of times on the same BAM file without issue. You can also use pysam inside of python to open the same files multiple times within the same script without issue.

ADD COMMENT
0
Entering edit mode

Thank you to confirm it Devon !

ADD REPLY

Login before adding your answer.

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