#NEWLINE# def _array_parallel( fn , cls , genelist , chunksize = 250 , processes = 1 , **kwargs ) : #NEWLINE# #INDENT# '\n    Returns an array of genes in `genelist`, using `bins` bins.\n\n    `genelist` is a list of pybedtools.Interval objects\n\n    Splits `genelist` into pieces of size `chunksize`, creating an array\n    for each chunk and merging ret\n\n    A chunksize of 25-100 seems to work well on 8 cores.\n    ' #NEWLINE# pool = multiprocessing . Pool ( processes ) #NEWLINE# chunks = list ( chunker ( genelist , chunksize ) ) #NEWLINE# results = pool . map ( func = _array_star , iterable = itertools . izip ( itertools . repeat ( fn ) , itertools . repeat ( cls ) , chunks , itertools . repeat ( kwargs ) ) ) #NEWLINE# pool . close ( ) #NEWLINE# pool . join ( ) #NEWLINE# return chunks