streetslab / dimelo

python package for analysis of dimelo-seq & nanopore modified base data
MIT License
3 stars 5 forks source link

(parse_bam) AttributeError: 'str' object has no attribute 'chromosome' #12

Closed thekugelmeister closed 2 years ago

thekugelmeister commented 2 years ago

When specifying a region argument to parse_bam in the format specified by the documentation (chr:start-end, presumably as a string), I get the following error:

Traceback (most recent call last):
  File "dimelo_package_test.py", line 19, in <module>
    extractAllBases=True,
  File "/home/thekugelmeister/devspace/streets_rotation/dimelo/dimelo/parse_bam.py", line 247, in parse_bam
    for window in windows
  File "/home/thekugelmeister/miniconda3/envs/dimelo/lib/python3.7/site-packages/joblib/parallel.py", line 1054, in __call__
    self.retrieve()
  File "/home/thekugelmeister/miniconda3/envs/dimelo/lib/python3.7/site-packages/joblib/parallel.py", line 933, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/home/thekugelmeister/miniconda3/envs/dimelo/lib/python3.7/site-packages/joblib/_parallel_backends.py", line 542, in wrap_future_result
    return future.result(timeout=timeout)
  File "/home/thekugelmeister/miniconda3/envs/dimelo/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/home/thekugelmeister/miniconda3/envs/dimelo/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
AttributeError: 'str' object has no attribute 'chromosome'

This appears to be caused by direct reference to this string as if it were a Region object, rather than converting it first.

amaslan commented 2 years ago

You are correct. The plotting function that calls parse_bam for one particular window in this way is plot_browser and the window string is converted to a region object before passing to parse_bam. I will update for parse_bam to take a string from plot_browser and in general to take a string as the documentation suggests. Thank you!

amaslan commented 2 years ago

Fixed on cleanup branch. Also added example code to parse_bam documentation for calling with single region defined with string. Will close when merged into main.