Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_union(self, other, **kwargs):
kwargs = fill_kwargs(kwargs)
strandedness = kwargs["strandedness"]
strand = True if strandedness else False
if not strand:
self = self.unstrand()
other = other.unstrand()
gr = pr.concat([self, other], strand)
gr = gr.merge(strand=strand, **kwargs)
return gr
if not overlap:
# self = self.drop(like="__k__|__IX__")
result = nearest#.drop(like="__k__|__IX__")
else:
from collections import defaultdict
overlap_kwargs = {k: v for k, v in kwargs.items()}
# print("kwargs ties:", kwargs.get("ties"))
overlap_kwargs["how"] = defaultdict(lambda: None, {"first": "first", "last": "last"})[kwargs.get("ties")]
# start = time()
overlaps = self.join(other, **overlap_kwargs)
# end = time()
# print("overlaps", end - start)
overlaps.Distance = 0
# print("overlaps len", len(overlaps))
result = pr.concat([overlaps, nearest])
if not len(result):
return pr.PyRanges()
# print(result)
# print(overlaps.drop(like="__").df)
# raise
# start = time()
new_result = {}
if ties in ["first", "last"]:
# method = "tail" if ties == "last" else "head"
# keep = "last" if ties == "last" else "first"
for c, df in result:
# start = time()
# print(c)