Entering edit mode
9.1 years ago
Echo
▴
70
Many bioinformatics problems are embarrassingly easy parallel.
With several lines of codes, you can make your code run in parallel using multicore in your machine.
Below are examples I copied from official docs. (I used them in production with minor change)
Python
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
p = Pool(5)
print(p.map(f, [1, 2, 3]))
https://docs.python.org/2/library/multiprocessing.html
Perl
use MCE::Loop;
MCE::Loop::init {
chunk_size => 1
};
mce_loop { do_work($_) } [ 1..10000 ];
https://metacpan.org/pod/MCE::Loop
For R, it is easy to do too, there are several options.
I used 'foreach' and it can even combine the result for me.