parklab / bamsnap

MIT License
109 stars 23 forks source link

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

Open SeongGyuKwon opened 7 months ago

SeongGyuKwon commented 7 months ago

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 commented 1 month ago

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 commented 1 month ago

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