jpayne@68: import multiprocessing jpayne@68: from . import helpers jpayne@68: import pybedtools jpayne@68: jpayne@68: jpayne@68: def random_jaccard(x, y, genome_fn, shuffle_kwargs, jaccard_kwargs): jpayne@68: z = x.shuffle(g=genome_fn, **shuffle_kwargs).sort() jpayne@68: result = z.jaccard(y, **jaccard_kwargs) jpayne@68: helpers.close_or_delete(z) jpayne@68: return result jpayne@68: jpayne@68: jpayne@68: def random_intersection(x, y, genome_fn, shuffle_kwargs, intersect_kwargs): jpayne@68: z = x.shuffle(g=genome_fn, **shuffle_kwargs) jpayne@68: zz = z.intersect(y, stream=True, **intersect_kwargs) jpayne@68: result = len(zz) jpayne@68: helpers.close_or_delete(z, zz) jpayne@68: return result jpayne@68: jpayne@68: jpayne@68: def random_intersection_bp(x, y, genome_fn, shuffle_kwargs, intersect_kwargs): jpayne@68: z = x.shuffle(g=genome_fn, **shuffle_kwargs) jpayne@68: zz = z.intersect(y, stream=True, **intersect_kwargs) jpayne@68: result = sum(len(i) for i in zz) jpayne@68: helpers.close_or_delete(z, zz) jpayne@68: return result