Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sequali crashes when no adapters are found #159

Closed
Redmar-van-den-Berg opened this issue May 22, 2024 · 3 comments · Fixed by #160
Closed

sequali crashes when no adapters are found #159

Redmar-van-den-Berg opened this issue May 22, 2024 · 3 comments · Fixed by #160

Comments

@Redmar-van-den-Berg
Copy link

Redmar-van-den-Berg commented May 22, 2024

Sequali takes the last item from the list of found adapters, which crashes when the list is empty

Processing TestSample1-R2.fq.gz: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 419k/419k [00:00<00:00, 4.01MiB/s]
Processing TestSample1-R1.fq.gz: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 418k/418k [00:00<00:00, 3.91MiB/s]
Traceback (most recent call last):
  File "/data/micromamba/envs/sequali/bin/sequali", line 11, in <module>
    sys.exit(main())
  File "/data/micromamba/envs/sequali/lib/python3.10/site-packages/sequali/__main__.py", line 281, in main
    report_modules = calculate_stats(
  File "/data/micromamba/envs/sequali/lib/python3.10/site-packages/sequali/report_modules.py", line 2110, in calculate_stats
    AdapterFromOverlapReport.from_insert_size_metrics(insert_size_metrics))
  File "/data/micromamba/envs/sequali/lib/python3.10/site-packages/sequali/report_modules.py", line 1833, in from_insert_size_metrics
    longest_adapter_read1 = adapters_read1[-1][0]
IndexError: list index out of range

I've made a small workaround, but I'm not sure exactly where the empty string gets used further on, so use with caution:

        longest_adapter_read1 = adapters_read1[-1][0] if adapters_read1 else ""
        longest_adapter_read2 = adapters_read2[-1][0] if adapters_read2 else ""

The report looks like this with the workaround:
image

@rhpvorderman
Copy link
Owner

Thanks for reporting. Let me see if I can create a reproducible test case.

@Redmar-van-den-Berg
Copy link
Author

I encountered the bug with the R1.fq.gz and R2.fq.gz files from here: https://github.com/LUMC/HAMLET/tree/main/test/data/fastq

@rhpvorderman
Copy link
Owner

rhpvorderman commented May 22, 2024

The issue is that it always crashes when there are no adapters. I fixed it in #160 .
EDIT: The fix you provided works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants