Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BedTool.window_maker() fails if genome not provided #101

Closed
andrewparkermorgan opened this issue Feb 21, 2014 · 2 comments
Closed

BedTool.window_maker() fails if genome not provided #101

andrewparkermorgan opened this issue Feb 21, 2014 · 2 comments

Comments

@andrewparkermorgan
Copy link

Attempting to run BedTool.window_maker() with interval instead of genome input fails as shown below.

Traceback (most recent call last):
  File "./tile_with_probes.py", line 36, in <module>
    kmers = regions.window_maker(w = args.kmer, s = args.step)
  File "/nas02/home/a/p/apm/lib/python2.7/site-packages/pybedtools-0.6.2-py2.7-linux-x86_64.egg/pybedtools/bedtool.py", line 623, in decorated
    result = method(self, *args, **kwargs)
  File "/nas02/home/a/p/apm/lib/python2.7/site-packages/pybedtools-0.6.2-py2.7-linux-x86_64.egg/pybedtools/bedtool.py", line 176, in wrapped
    kwargs = self.check_genome(**kwargs)
  File "/nas02/home/a/p/apm/lib/python2.7/site-packages/pybedtools-0.6.2-py2.7-linux-x86_64.egg/pybedtools/bedtool.py", line 1178, in check_genome
    raise ValueError('No genome specified. Use the "g" or '
ValueError: No genome specified. Use the "g" or "genome" kwargs, or use the .set_chromsizes() method

It looks to me like the contents of the BedTool are not being passed to _wraps() via the implicit argument. If I make the following change at line 1911 in bedtool.py then window_maker() now runs as expected.

## OLD:
# @_wraps(prog='windowMaker', uses_genome=True, genome_none_if=['b'])
## NEW:
@_wraps(prog='windowMaker', implicit='b', uses_genome=True, genome_none_if=['b'])

But I have not checked whether or not this causes the function to break under other input cases.

@daler
Copy link
Owner

daler commented Feb 21, 2014

Hmm, looks like this change would breaks existing functionality -- check the output of

nosetests pybedtools/test/test.py:test_window_maker

The way the _wraps decorator is set up, if implicit is specified then it means an interval file is required . . . which is not always the case for bedtools makewindows.

Which version of pybedtools are you running? The latest version uses

@_wraps(prog='windowMaker', uses_genome=True, genome_none_if=['b'],
            other='b', implicit='b')

With the latest version, you should be able to do

kmers = regions.window_maker(regions, w=args.kmer, s=args.step)

It's a little awkward to provide the method with regions itself, but since the bedtools makewindows works with or without a provided interval file, it doesn't fit perfectly with the infrastructure for the other tools.

@leeleavitt
Copy link

leeleavitt commented Jun 28, 2022

Would appreciate some updated documentation on this function. Happy to provide with guidance to location to update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants