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

ValueError: y1 must be greater than or equal to y0 #33

Open
SeongGyuKwon opened this issue Dec 14, 2023 · 2 comments
Open

ValueError: y1 must be greater than or equal to y0 #33

SeongGyuKwon opened this issue Dec 14, 2023 · 2 comments

Comments

@SeongGyuKwon
Copy link

I had this issue with basic script

bamsnap -bam 15L136Fb6001F9.s.md.ir.bam -pos 1:22312455 -out test.png

Process proc 1: Traceback (most recent call last): File "/home/kds/.conda/envs/py311/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/kds/.conda/envs/py311/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/bamsnap/bamsnap.py", line 235, in run_process_drawplot_bamlist imagefname = bsplot.drawplot_bamlist(pos1, image_w, bamlist, xscale, refseq) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/bamsnap/bamsnap.py", line 473, in drawplot_bamlist ia_sub = self.get_bamplot_image(bam, pos1, image_w, xscale, refseq) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/bamsnap/bamsnap.py", line 377, in get_bamplot_image ia_sub = covplot.get_image(image_w, self.opt['coverage_height'], self.opt['coverage_bgcolor']) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/bamsnap/drawreadset.py", line 26, in get_image self.draw_coverage(dr, w, h) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/bamsnap/drawreadset.py", line 61, in draw_coverage dr.rectangle([(x1, y1), (x2, y2)], fill=getrgb(self.coverage_color), outline=getrgb(self.coverage_color, 15), width=1) File "/home/kds/.conda/envs/py311/lib/python3.10/site-packages/PIL/ImageDraw.py", line 294, in rectangle self.draw.draw_rectangle(xy, fill, 1) ValueError: y1 must be greater than or equal to y0

Anyone had the same problem?

How can I solve this?

@mingwhy
Copy link

mingwhy commented Jun 17, 2024

I modified the bamsnap/drawreadset.py file around line 61 to be:

        if max_cov > 0:
            y1 = h
            y2 = round(h - (cov / max_cov * h), 0)
            x1 = self.xscale.xmap[posi]['spos']
            x2 = self.xscale.xmap[posi]['epos']
            #print(y1, y2, x1, x2) # I added below two lines
            if y2 < y1:
                y2 = y1

Then it worked fine.

@SeongGyuKwon
Copy link
Author

@mingwhy
Thank you. I will try.
Before your comment, I have solved that issue with setting pillow version 9.0.0

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

2 participants