I want to use pybedtools
in a python program that I am compiling into an executable with pyinstaller
. The intent is that this executable will contain all of the necessary files to run the program, including shipping BEDtools
as a binary. However, when I try to run pybedtools using the code below, I get a NotImplementedError, implying that pybedtools doesn't work with this approach. Is it possible to run pybedtools wrapping a binary like this? Is set_bedtools_path
not the right tool to use for this problem?
Example code:
import os
import pybedtools
pybedtools.helpers.set_bedtools_path(os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'bedtools.static.binary'))
a = pybedtools.example_bedtool('a.bed')
b = pybedtools.example_bedtool('b.bed')
print(a.intersect(b))
I could not find a way to accomplish this task using a static binary. However, an equivalent (although perhaps slightly less elegant) solution was to download the .tar archive from the bedtools website, compile it from source, include the entire directory as data, and use
pybedtools.helpers.set_bedtools_path(...)
to point the package to the bedtools/bin/ folder.