Comments (13)
working on this, but hit a roadblock with an annoying problem caused by, in __init__.py
:
from bedtool import bedtool
From IPython and the test suite, this works no prob:
import pybedtools
a = pybedtools.example_bedtool('a.bed')
But from a doctest within bedtool.py
, this gives a "module not callable" error:
a = pybedtools.example_bedtool('a.bed')
Seems like some sort of name clash within the doctest execution context. The only solution I could come up with is renaming bedtool.py
to bedtool_base.py
. Then __init__.py
has this instead:
from bedtool_base import bedtool
and the docstrings work. Lame, I know, but it's all I could get to work.
from pybedtools.
also, i decided to let the test suite do the checking of actual results. Otherwise, to get the doctests to pass, you need <BLANKLINE>
and the #doctest: +NORMALIZE_WHITESPACE
directive each time, which clutters the docstrings for interactive use. For example, this is a nice complete doctest, but it's uuuugly:
Example usage::
>>> # create new bedtool object
>>> a = pybedtools.example_bedtool('a.bed')
# get overlaps with "b.bed"
>>> b_fn = pybedtools.example_bed_fn('b.bed')
>>> overlaps = a.intersect(b_fn)
>>> print overlaps #doctest: +NORMALIZE_WHITESPACE
chr1 155 200 feature2 0 +
chr1 155 200 feature3 0 -
chr1 900 901 feature4 0 +
<BLANKLINE>
So it's simply replaced by
Example usage::
>>> # create new bedtool object
>>> a = pybedtools.example_bedtool('a.bed')
# get overlaps with "b.bed"
>>> b_fn = pybedtools.example_bed_fn('b.bed')
>>> overlaps = a.intersect(b_fn)
and the test suite does the "real" testing of expected output.
from pybedtools.
yeah, i think we can also send those flags to doctest.testmod()
for the first problem, did you try:
from .bedtool import bedtool
?
from pybedtools.
I just tried the .bedtool
relative import; that didn't work.
Turns out it was nosetests that was causing that import problem. Now that I'm using the standard doctest.testmod()
in the bedtool.py
module rather than having nose find the doctests, it works. So now I'm back to using the plain 'ol
from bedtool import bedtool
Docstring testing at the moment has to be done by running the bedtool module; hopefully sphinx's make doctest
will run these eventually.
Also, sending the flags like you suggested to doctest.testmod()
works like a charm.
So both problems solved!
from pybedtools.
when i run
nosetests --with-doctest --doctest-extension=.py .
from the base dir, i see the problem you mention above.
what do you think about renaming the class bedtool to BedTool? to avoid this?
from pybedtools.
yeah, prob a good PEP8 move to do this. I'm working on some doctests on the bits of downtime I have today, so I'll work on changing this over in the code and in the tests.
Another issue is that I can't find a way to pass doctest optionflags to nosetests. (specifically +NORMALIZE_WHITESPACE). There's a patch floating around to provide --doctest-options, but I don't want to rely on a patched nosetests. Any ideas for this?
from pybedtools.
i've just converted the whole set, yeah, now only having problems with flags to nosetests
from pybedtools.
SHA: 0de20ba
from pybedtools.
Sweet, thanks. Merged it.
from pybedtools.
Re: optionflags . . .
The reason for wanting to pass +normalize_whitespace to nosetests is so that in the source code, all tabs in expected output can be converted to spaces. I initially wanted to do this to avoid potential ambiguous whitespace issues in the python source.
But maybe it's worth putting the tabs back in,
- to get nosetests to run, and
- as an additional test to make sure things really are giving output that has tabs, which is what BEDTools is expecting.
What do you think?
from pybedtools.
cool. (fyi, i left all the sphinx stuffs unchanged)
from pybedtools.
re whitespace, your call, can also use output spariingly in the doctests and just test for equality:
>>> str(bed_line) == expected
True
but yes, getting the tests to run through nose as well would be convenient.
from pybedtools.
ok, this should work in the base dir:
nosetests --with-coverage
i removed lots of output from function and method doctests . . . this means they're not very rigorous at the moment, but i think i'd rather keep the rigorous tests in test1.py anyway. eventually i'll probably add minor equality tests like you suggest.
also, i learned about the doctest_global_setup config value for sphinx's doctest plugin, which now lets this run doctest within the docs and then compile 'em all (when run from the docs dir):
make doctest html latexpdf
from pybedtools.
Related Issues (20)
- Support Python 3.10 and 3.11 HOT 1
- "python setup.py bdist_wheel did not run successfully" when pip installing with python v3.11 HOT 8
- to_dataframe() creates 0th row with generic names in nucleotide_content HOT 2
- build failure under python 3.11 HOT 6
- pybedtools intersect error HOT 2
- Cannot create a BedTool object from list of regions that uses np.int64 coordinates
- remove historical py27 support HOT 1
- bedtools intersect reported incorrect interval intersection HOT 3
- Cythonizing files requires `language_level=2` to be set in cythonize() HOT 4
- pybedtools multi_bam_coverage assistance HOT 2
- "fastaFromBed" error HOT 2
- intersect with multiple -b arguments not working with -sorted HOT 1
- Unable to install pybedtools==0.9.1 in Python3.10 HOT 4
- Len modifying the Bedtools after a filter HOT 2
- Has pybedtools considered packaging bedtools? HOT 3
- how to mask gap regions for randomization? HOT 1
- Issue while doing pip install pybedtools HOT 3
- Inconsistent behaviour when using files from `pathlib.PosixPath` with BedTool functions...
- pybedtools.bedtool.Bedtool.sort()
- total_coverage giving a incorrect value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybedtools.