Skip to content

Commit

Permalink
Add tests for depth()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Aug 10, 2024
1 parent fc2f2a6 commit 3c85f7e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions jcvi/graphics/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ def depth(args):

image_name = opts.outfile
savefig(image_name, dpi=iopts.dpi, iopts=iopts)
return image_name


def add_window_options(p):
Expand Down
Binary file added tests/graphics/data/VAR0_srtd.wgs.regions.bed.gz
Binary file not shown.
Binary file added tests/graphics/data/VAR1_srtd.wgs.regions.bed.gz
Binary file not shown.
Binary file added tests/graphics/data/VAR2_srtd.wgs.regions.bed.gz
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/graphics/data/chrinfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
chr01A, #c51b7d, 1A
chr01B, #4d9221, 1B
chr02A, #c51b7d, 2A
chr02B, #4d9221, 2B
chr03A, #c51b7d, 3A
chr03B, #4d9221, 3B
chr04A, #c51b7d, 4A
chr04B, #4d9221, 4B
chr05A, #c51b7d, 5A
chr05B, #4d9221, 5B
chr06A, #c51b7d, 6A
chr06B, #4d9221, 6B
3 changes: 3 additions & 0 deletions tests/graphics/data/titleinfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VAR0_srtd.wgs.regions.bed.gz, *S. species*, ‘Variety 1’
VAR1_srtd.wgs.regions.bed.gz, *S. species*, ‘Variety 2’
VAR2_srtd.wgs.regions.bed.gz, *S. species*, ‘Variety 3’
20 changes: 19 additions & 1 deletion tests/graphics/test_landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@
import os.path as op

from jcvi.apps.base import cleanup
from jcvi.graphics.landscape import stack
from jcvi.graphics.landscape import depth, stack


def test_depth():
cwd = os.getcwd()
os.chdir(op.join(op.dirname(__file__), "data"))
cleanup("depth.pdf")
image_name = depth(
[
"VAR0_srtd.wgs.regions.bed.gz",
"VAR1_srtd.wgs.regions.bed.gz",
"VAR2_srtd.wgs.regions.bed.gz",
"--chrinfo=chrinfo.txt",
"--titleinfo=titleinfo.txt",
"--figsize=11x7",
]
)
assert op.exists(image_name)
os.chdir(cwd)


def test_stack():
Expand Down

0 comments on commit 3c85f7e

Please sign in to comment.