Metabuli icon indicating copy to clipboard operation
Metabuli copied to clipboard

Segmentation fault on classify with refseq_virus, [Edit: unless --max-ram is used]

Open samuell opened this issue 5 months ago • 3 comments

I'm getting segmentation faults when trying to run metabuli classify on various input files, towards the refseq_virus database.

Steps to reproduce:

  1. Download metabuli 1.1.1 with avx2, extract into ~/opt/metabuli/bin and add that folder to $PATH
  2. Create a simple read fasta file like this, in a file named seq.fa:
>seq1
GCTATGTTCCACCTACTCGTTCAGTTTATTGAAGCCGGTATTTAACCGCCTCCAGGAAAGTACCTCTGATGTTTTCGCAT
TTATCGTGAAACGCTTGCGCGTTTTCTGGTGCGCCGCTTCACTGACAGAAGTGATTTACAATTAGCTTCAATCGATTTAT
TGTCGAGTTTCTTTGCAGCATAAAAATCATTACACACTGCTATTTTCATCTAGAATTTTGTATTTCTCCATGGCAAGGTA
>seq2
TTATCGTGAAACGCTTGCGCGTTTTCTGGTGCGCCGCTTCACTGACAGAAGTGATTTACAATTAGCTTCAATCGATTTAT
TGTCGAGTTTCTTTGCAGCATAAAAATCATTACACACTGCTATTTTCATCTAGAATTTTGTATTTCTCCATGGCAAGGTA
AATTATGCTAAAGGGAAGCTAACAAGAAATTACATGATATTGTTGCCATGGCAGCATGTTAATAGATATAACTTTGTTTG
AGTTTACAGGATGCAAAGTTGG

(Although I got the same problem with real world fastq files) 3. Download the refseq_virus database and unpack it into your current folder, so that you got a ./refseq_virus in your current folder. 4. Run:

metabuli classify --seq-mode 3 seq.fa refseq_virus metabuli-out job01

Result

classify --seq-mode 3 seq.fa refseq_virus metabuli-out job01 

Metabuli Version (commit):                              a65c014fa739d61fdea7db727eb4988b8d8c0f6a
Threads                                                 12
Sequencing type                                         3
Min. sequence similarity score                          0
Min. query coverage                                     0
Min. num. of cons. matches for non-euk. classification  4
Min. num. of cons. matches for euk. classification      9
Min. score for species- or lower-level classification.  0
Allowed extra Hamming distance                          0
Directory where the taxonomy dump files are stored    
Mask residues                                           0
Mask residues probability                               0.9
RAM usage in GiB                                        128
Number of matches per query k-mer.                      4
Accession-level DB build/search                         0
Best * --tie-ratio is considered as a tie               0.95
Not storing k-mer's redundancy.                         0
Print lineage information                               0
Validate format of input FASTA/FASTQ file(s)            0
Validate the database                                   0

DB name: refseq_virus+humanT2T
DB creation date: 2024-3-26
Loading the list for taxonomy IDs ... Done
Indexing query file ...Done
Total number of sequences: 2
Total read length: 502nt
Extracting query metamers ... 
Time spent for metamer extraction: 0
Sorting query metamer list ...
Time spent for sorting query metamer list: 0
Comparing query and reference metamers...
Segmentation fault (core dumped)

Expected result

No Segmentation fault (core dumped) in the output.

System info

  • Metabuli version: 1.1.1 (a65c014fa739d61fdea7db727eb4988b8d8c0f6a)
  • OS: Linux Mint 21.1
  • CPU: 12th Gen Intel(R) Core(TM) i7-1255U
  • CPU Flags: Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities

samuell avatar Jul 18 '25 16:07 samuell

Just discovered:

The problem goes away if I specify max RAM usage (even if set to the max amount of memory on my laptop), so running this command instead:

metabuli classify --max-ram 32 --seq-mode 3 seq.fa refseq_virus metabuli-out job01

Then it finishes without error:

classify --max-ram 32 --seq-mode 3 seq.fa refseq_virus metabuli-out job01 

Metabuli Version (commit):                              a65c014fa739d61fdea7db727eb4988b8d8c0f6a
Threads                                                 12
Sequencing type                                         3
Min. sequence similarity score                          0
Min. query coverage                                     0
Min. num. of cons. matches for non-euk. classification  4
Min. num. of cons. matches for euk. classification      9
Min. score for species- or lower-level classification.  0
Allowed extra Hamming distance                          0
Directory where the taxonomy dump files are stored    
Mask residues                                           0
Mask residues probability                               0.9
RAM usage in GiB                                        32
Number of matches per query k-mer.                      4
Accession-level DB build/search                         0
Best * --tie-ratio is considered as a tie               0.95
Not storing k-mer's redundancy.                         0
Print lineage information                               0
Validate format of input FASTA/FASTQ file(s)            0
Validate the database                                   0

DB name: refseq_virus+humanT2T
DB creation date: 2024-3-26
Loading the list for taxonomy IDs ... Done
Indexing query file ...Done
Total number of sequences: 2
Total read length: 502nt
Extracting query metamers ... 
Time spent for metamer extraction: 0
Sorting query metamer list ...
Time spent for sorting query metamer list: 0
Comparing query and reference metamers...
Time spent for the comparison: 1
Sorting matches ...
Time spent for sorting matches: 0
Analyzing matches ...
Time spent for analyzing: 0
The number of processed sequences: 2 (1)
Number of query k-mers: 906
The number of matches: 85
Time for processing: 0h 0m 0s 938ms

samuell avatar Jul 18 '25 16:07 samuell

in metabuli classifiedRefiner , similar segmentation fault also occurred without using --max-ram

metabuli classifiedRefiner 'Test_classifications.tsv' "./tax" \
    --exclude-taxid "7711" \
    --threads 30 \
    --report 1

it returns


Metabuli Version (commit):                                                                      a65c014fa739d61fdea7db727eb4988b8d8c0f6a
Remove unclassified reads                                                                       false
Exclude taxId as well as its children                                                           7711
Select taxId as well as its children                                                        
Select columns with number, (7:full lineage, generated if absent)                           
Make report of refined classification file                                                      true
Adjust classification to the specified rank                                                 
0: without higher rank, 1: with higher rank, 2: separate file for higher rank classification    0
Threads                                                                                         30
Min. sequence similarity score                                                                  0

Loading nodes file ... Done, got 2682588 nodes
Loading merged file ... Done, added 91487 merged nodes.
Loading names file ... Done
Init computeSparseTable ...Done
Write refined classification result to: 
Test_classifications_refined.tsv
Segmentation fault (core dumped)

Lelouchzhu avatar Jul 31 '25 05:07 Lelouchzhu

@samuell Thank you for letting us know it! I will improve README and printed logs to better handle this thing. @Lelouchzhu Is the job completed correctly when you specified --max-ram? Could you share Test_classifications.tsv and tax so that I can reproduce it?

jaebeom-kim avatar Jul 31 '25 06:07 jaebeom-kim