Parallelism#

PyARAGORN is entirely thread-safe, which allows processing different contigs in parallel with the same RNAFinder object.

Reentrancy#

The RNAFinder.find_rna method is re-entrant, so calling it across different threads doesn’t cause any issue. The easiest way to call the find_rna method in parallel is with a multiprocessing.pool.ThreadPool, which can easily split the work into chunks to be processed across different threads:

from multiprocess.pool import ThreadPool
from pyaragorn import RNAFinder

sequences = [ ... ]       # a list of sequences to process
rna_finder = RNAFinder()  # a single RNA finder object

with ThreadPool() as pool:
    rna_genes = pool.map(rna_finder.find_rna, sequences)