liu-congcong / MetaDecoder

An algorithm for clustering metagenomic sequences.
GNU General Public License v3.0
30 stars 2 forks source link

Handling empty SAM (with an informative error) #8

Closed telatin closed 1 year ago

telatin commented 1 year ago

Hello, thanks for sharing this tool!

I'm currently using metadecoder 1.0.12, and running:

# There are 93 sam files
metadecoder coverage -s *.sam -o metadecoder.coverage

and got:

Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/magflow/bin/metadecoder", line 216, in <module>
    metadecoder_coverage.main(parameters)
  File "/home/ubuntu/miniconda3/envs/magflow/lib/python3.7/site-packages/metadecoder/metadecoder_coverage.py", line 56, in main
    for block_start, block_end in generate_block(file, parameters.threads):
  File "/home/ubuntu/miniconda3/envs/magflow/lib/python3.7/site-packages/metadecoder/sam_utility.py", line 62, in generate_block
    block_size = ceil((file_size - block_start) / blocks)
UnboundLocalError: local variable 'block_start' referenced before assignment

I noticed that all the sam files have the valid header, but no alignments, and I would suggest handling this scenario with an informative error to make easier to troubleshoot. Thanks!

liu-congcong commented 1 year ago

Hi Telatin, Thank you for your suggestion. Version 1.0.16 has solved this problem. Please let me know if you encounter any problems while using it. Best, Cong-Cong

telatin commented 1 year ago

Will update then, thanks a million!