croth1 · GitHub

I am trying to write a reproducible notebook using pybedtools. My notebook environment has pybedtools and bedtools - bedtools is not in the system's default PATH. As pybedtools requires bedtools to be in the PATH, I tried following code to update the PATH:

import os
from os import path
import sys
import shutil
bin_dir = path.dirname(sys.executable)
os.environ['PATH'] += os.pathsep + bin_dir
shutil.which('bedtools')
subprocess.run(['bedtools', '--help'])

The two last statements confirm that updating the PATH should in principle work.

However I still get:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-8-b78b21db8d19> in <module>()
----> 1 prom_result = prom_bed.merge().to_dataframe()
/home/croth1/miniconda2/envs/enhprom_env/lib/python3.5/site-packages/pybedtools/bedtool.py in decorated(self, *args, **kwargs)
    804             # this calls the actual method in the first place; *result* is
    805             # whatever you get back
--> 806             result = method(self, *args, **kwargs)
    807
    808             # add appropriate tags
/home/croth1/miniconda2/envs/enhprom_env/lib/python3.5/site-packages/pybedtools/bedtool.py in not_implemented_func(*args, **kwargs)
    202         if not_implemented:
    203             def not_implemented_func(*args, **kwargs):
--> 204                 raise NotImplementedError(help_str)
    205             return not_implemented_func
    206
NotImplementedError: "mergeBed" does not appear to be installed or on the path, so this method is disabled.  Please install a more recent version of BEDTools and re-import to use this method.

I'm a bit puzzled - I had a quick glance and you also seem to simply run a subprocess.

Any idea what went wrong here?

Read the original on github.com ↗