Mercurial > repos > rliterman > csp2
annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/site-packages/pybedtools/stats.py @ 68:5028fdace37b
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 16:23:26 -0400 |
parents | |
children |
rev | line source |
---|---|
jpayne@68 | 1 import multiprocessing |
jpayne@68 | 2 from . import helpers |
jpayne@68 | 3 import pybedtools |
jpayne@68 | 4 |
jpayne@68 | 5 |
jpayne@68 | 6 def random_jaccard(x, y, genome_fn, shuffle_kwargs, jaccard_kwargs): |
jpayne@68 | 7 z = x.shuffle(g=genome_fn, **shuffle_kwargs).sort() |
jpayne@68 | 8 result = z.jaccard(y, **jaccard_kwargs) |
jpayne@68 | 9 helpers.close_or_delete(z) |
jpayne@68 | 10 return result |
jpayne@68 | 11 |
jpayne@68 | 12 |
jpayne@68 | 13 def random_intersection(x, y, genome_fn, shuffle_kwargs, intersect_kwargs): |
jpayne@68 | 14 z = x.shuffle(g=genome_fn, **shuffle_kwargs) |
jpayne@68 | 15 zz = z.intersect(y, stream=True, **intersect_kwargs) |
jpayne@68 | 16 result = len(zz) |
jpayne@68 | 17 helpers.close_or_delete(z, zz) |
jpayne@68 | 18 return result |
jpayne@68 | 19 |
jpayne@68 | 20 |
jpayne@68 | 21 def random_intersection_bp(x, y, genome_fn, shuffle_kwargs, intersect_kwargs): |
jpayne@68 | 22 z = x.shuffle(g=genome_fn, **shuffle_kwargs) |
jpayne@68 | 23 zz = z.intersect(y, stream=True, **intersect_kwargs) |
jpayne@68 | 24 result = sum(len(i) for i in zz) |
jpayne@68 | 25 helpers.close_or_delete(z, zz) |
jpayne@68 | 26 return result |