aidenlab / straw

Extract data quickly from Juicebox via straw
MIT License
62 stars 36 forks source link

In case of detected errors, straw prints them and returns instead of raising an Exception #83

Closed Balthasar-eu closed 3 years ago

Balthasar-eu commented 3 years ago

Describe the bug When a check in the package fails currently a message is printed and the function returns -1 or None instead of raising an Exception, which leads to random errors later.

To Reproduce Steps to reproduce the behavior: Have valid HiC file. use:

import straw
straw.straw("NONE",filename,100,100,BP,10000)

Which will fail, of the organism from the file does not have a chromosome 100, the error message is however:

  File "/home/balthasar/.local/lib/python3.9/site-packages/straw/straw.py", line 470, in straw
    master=list1[0]

TypeError: 'int' object is not subscriptable

Expected behavior The error message should instead be:

  File "/home/balthasar/.local/lib/python3.9/site-packages/straw/straw.py", line 110, in readHeader
    raise ValueError("One of the chromosomes wasn't found in the file. Check that the chromosome name matches the genome.\n")

ValueError: One of the chromosomes wasn't found in the file. Check that the chromosome name matches the genome.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

Balthasar-eu commented 3 years ago

I have to admit, that I did not test the pull request for any other case but the wrong chromosome name, but the changes are pretty limited and the current master version seems to forget to import sys anyways and will fail if read_metadata is executed.