parklab / bamsnap

MIT License
109 stars 23 forks source link

Runs into error with genomic region size in megabases #25

Open ManavalanG opened 3 years ago

ManavalanG commented 3 years ago

Is there a limit on the size of genomic region that can be plotted using bamsnap? My attempts to plot 1.5MB region failed with this error:

Process proc 1:
Traceback (most recent call last):
  File ".conda/envs/bamsnap/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File ".conda/envs/bamsnap/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/bamsnap.py", line 235, in run_process_drawplot_bamlist
    imagefname = bsplot.drawplot_bamlist(pos1, image_w, bamlist, xscale, refseq)
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/bamsnap.py", line 467, in drawplot_bamlist
    ia = self.append_coordinates_image(ia, pos1, image_w, xscale)
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/bamsnap.py", line 430, in append_coordinates_image
    ia_sub = coord.get_image()
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/coordinates.py", line 106, in get_image
    self.draw(dr)
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/coordinates.py", line 62, in draw
    self.cal_axis()
  File ".conda/envs/bamsnap/lib/python3.9/site-packages/bamsnap/coordinates.py", line 52, in cal_axis
    unitlen = 10 ** (len(str(axis_base_unit)) - 1)
UnboundLocalError: local variable 'axis_base_unit' referenced before assignment

Error is occuring due to conditional used with hardcoded list here:

https://github.com/parklab/bamsnap/blob/a9c219dfe92b08d8419c0610c102ae07430c4d7e/src/bamsnap/coordinates.py#L47-L51

riazgillani commented 2 years ago

Hello - I am experiencing a similar error with large genomic regions. Is there a workaround?