Dear Ernesto,
thanks for using pysam. You are on the right track.
Using the multiprocessing module should work, but to be on the safe
side, open a separate file for read access in each worker
process. That is, instead of passing an instance of Samfile to a
subprocess, pass the filename instead and create a new samfile =
Samfile( ) in the function that is run in parallel.
There are definitely side-effects when multi-threading and
possibly ones when multi-processing. Generally it is best to avoid
accessing a bam-file through the same instance of a Samfile object
from multiple threads/processes.
Best wishes,
Andreas