Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pybedtools/bedtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,11 @@ def handle_kwargs(self, prog:str, arg_order: Optional[list[str]] = None, **kwarg
"mapBed": ",",
}
stdin = None

# If anything in kwargs is a pathlib Path, convert to string here.
for k, v in kwargs.items():
if isinstance(v, pathlib.PurePath):
kwargs[k] = str(v)

# -----------------------------------------------------------------
# Decide how to send instream1 to BEDTools. If there's no implicit
Expand Down
13 changes: 13 additions & 0 deletions pybedtools/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ def test_pathlib_nonexistent_file():
path = pathlib.Path(fn)
with pytest.raises(FileNotFoundError):
pybedtools.BedTool(path)


def test_pathlib_on_methods():
# Above functions test the creation of BedTool from Path objects; here we
# test arbitrary methods to test that Path objs are converted to str when
# composing the relevant command.
fn_a = os.path.join(pybedtools.filenames.data_dir(), "a.bed")
fn_b = os.path.join(pybedtools.filenames.data_dir(), "b.bed")
p_a = pathlib.Path(fn_a)
p_b = pathlib.Path(fn_b)
bt = pybedtools.BedTool(fn_a)
res = bt.intersect(p_b)

Loading