diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a488e50..ed86a737 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,11 +21,11 @@ jobs: cache: 'pip' - name: Install BEDTools (Linux) - run: sudo apt-get install bedtools + run: sudo apt-get install bedtools libmagickwand-dev if: matrix.os == 'ubuntu-latest' - name: Install BEDTools (macOS) - run: brew install bedtools + run: brew install bedtools freetype imagemagick if: matrix.os == 'macos-13' - name: Install dependencies diff --git a/jcvi/formats/pdf.py b/jcvi/formats/pdf.py index 9f1c2ded..abe4a010 100644 --- a/jcvi/formats/pdf.py +++ b/jcvi/formats/pdf.py @@ -8,13 +8,15 @@ from natsort import natsorted -from PyPDF2 import PdfFileMerger, parse_filename_page_ranges -from PyPDF2.pagerange import PAGE_RANGE_HELP +from pypdf import PdfMerger, parse_filename_page_ranges +from pypdf.pagerange import PageRange from ..apps.base import ActionDispatcher, OptionParser, cleanup, logger from .base import must_open +PAGE_RANGE_HELP = PageRange.__init__.__doc__ + def main(): @@ -75,7 +77,7 @@ def cat(args): filename_page_ranges = parse_filename_page_ranges(args) nfiles = len(filename_page_ranges) - merger = PdfFileMerger() + merger = PdfMerger() with must_open(outfile, "wb") as fw: in_fs = {} try: diff --git a/jcvi/graphics/grabseeds.py b/jcvi/graphics/grabseeds.py index f26615fc..eb020f35 100644 --- a/jcvi/graphics/grabseeds.py +++ b/jcvi/graphics/grabseeds.py @@ -618,7 +618,7 @@ def seeds(args): ff = opts.filter calib = opts.calibrate outdir = opts.outdir - if outdir != ".": + if outdir and outdir != ".": mkdir(outdir) if calib: calib = json.load(must_open(calib)) diff --git a/setup.cfg b/setup.cfg index 6566d1c9..a37e99db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ zip_safe = False setup_requires = setuptools>=18.0; cython install_requires = CrossMap - PyPDF2 + Wand biopython boto3 brewer2mpl @@ -53,6 +53,8 @@ install_requires = ortools pybedtools pyefd + pypdf + pytesseract rich scikit-image scipy diff --git a/tests/graphics/data/calibrate.JPG b/tests/graphics/data/calibrate.JPG new file mode 100644 index 00000000..e6fac27c Binary files /dev/null and b/tests/graphics/data/calibrate.JPG differ diff --git a/tests/graphics/data/test.JPG b/tests/graphics/data/test.JPG new file mode 100644 index 00000000..f8395e15 Binary files /dev/null and b/tests/graphics/data/test.JPG differ diff --git a/tests/graphics/test_grabseeds.py b/tests/graphics/test_grabseeds.py new file mode 100644 index 00000000..432d2314 --- /dev/null +++ b/tests/graphics/test_grabseeds.py @@ -0,0 +1,24 @@ +import os +import os.path as op + +from jcvi.apps.base import cleanup +from jcvi.graphics.grabseeds import calibrate, seeds + + +def test_main(): + cwd = os.getcwd() + os.chdir(op.join(op.dirname(__file__), "data")) + output_image = "test.pdf" + json_file = "calibrate.json" + cleanup(output_image) + seeds(["test.JPG"]) + assert op.exists(output_image) + + # Test calibrate + json_file = "calibrate.json" + cleanup(json_file, output_image) + json_file = calibrate(["calibrate.JPG", "1"]) # `1` for the boxsize arg + assert op.exists(json_file) + seeds(["test.JPG", "--calibrate", json_file]) + + os.chdir(cwd)