sanger-pathogens / snp-sites

Finds SNP sites from a multi-FASTA alignment file
http://sanger-pathogens.github.io/snp-sites/
Other
232 stars 50 forks source link

32 bit signed integer error #95

Open ethering opened 3 years ago

ethering commented 3 years ago

Hi, I noticed a similar issue to a previously closed one (#80 ), which I'm experiencing with the most recent version (2.5.1) of snp-sites. It appears that sequences longer than 2,147,483,647 bases give the error "Warning: No SNPs were detected so there is nothing to output." 2,147,483,647 is the maximum value for a 32 bit signed integer. I've spent a bit of time looking into this and here's what I've done to prove this.

I took two sequences from an alignment, one of which was the outgroup, so as to maximise the number of snps. Each sequence was 2,423,158,460 bases in length:

$ cat sample1.fasta Outgroup.fasta > test.fasta

$ snp-sites -V
snp-sites 2.5.1

$ snp-sites -c -o test_snps.fasta test.fasta
Warning: No SNPs were detected so there is nothing to output.

I then cut the length of the sequences down 2,147,483,648 - one base longer than 32 bit signed integer maximum value:

$ cut -c 1-2147483648 test.fasta > test1.fasta
$ snp-sites -c -o test1_snps.fasta test1.fasta
Warning: No SNPs were detected so there is nothing to output.

I then cut the length of the sequence down 2,147,483,647 - the 32 bit signed integer maximum value:

$ cut -c 1-21474836487 test.fasta > test2.fasta
$ snp-sites -c -o test2_snps.fasta test2.fasta
/opt/slurm/data/slurmd/job28028674/slurm_script: line 13: 38321 Segmentation fault      snp-sites -c -o test1_snps.fasta test1.fasta

I then cut the length of the sequence down 2,147,483,646 - one base less than the 32 bit signed integer maximum value:

$ cut -c 1-21474836486 test.fasta > test3.fasta
$ snp-sites -c -o test3_snps.fasta test3.fasta

This time snp-sites ran successfully and identifies 28,880,245 variant sites

So it seems that sequence-lengths which are at the limit of a 32 bit signed integer maximum value cause a segmentation fault, and when you go over that limit causes snp-sites to suggest there are no SNPs

Graham

JFsanchezherrero commented 3 months ago

Hi there, any updates on that issue?

I came accross too, try to update the package but latest version is 2.5.1, which produces the error.

Best regards