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
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.