No retraction, correction or concern found when last checked on Oct 15, 2026.
SNP-sites: rapid efficient extraction of SNPs from multi-FASTA alignments
Andrew J. Page, Ben Taylor, Aidan J. Delaney and 4 more
Microbial Genomics · 2016
Abstract
Rapidly decreasing genome sequencing costs have led to a proportionate increase in the number of samples used in prokaryotic population studies. Extracting single nucleotide polymorphisms (SNPs) from a large whole genome alignment is now a routine task, but existing tools have failed to scale efficiently with the increased size of studies. These tools are slow, memory inefficient and are installed through non-standard procedures. We present SNP-sites which can rapidly extract SNPs from a multi-FASTA alignment using modest resources and can output results in multiple formats for downstream analysis. SNPs can be extracted from a 8.3 GB alignment file (1842 taxa, 22 618 sites) in 267 seconds using 59 MB of RAM and 1 CPU core, making it feasible to run on modest computers. It is easy to install through the Debian and Homebrew package managers, and has been successfully tested on more than 20 operating systems. SNP-sites is implemented in C and is available under the open source license GNU GPL version 3.
Full text
From PubMed Central, U.S. National Library of Medicine, as current on Oct 16, 2026. Paragraph numbers are ours, so an answer can point at one.
Data Summary
1. The source code for SNP-sites is available from GitHub under GNU GPL v3; (URL – https://github.com/sanger-pathogens/snp-sites)
2. The software is available from Homebrew using the recipe “brew install snp-sites” and from Debian using "apt-get install snp-sites”.
3. Salmonella Typhi multi-FASTA alignment data has been deposited in Figshare: https://dx.doi.org/10.6084/m9.figshare.2067249.v1
Impact Statement
Rapidly extracting SNPs from increasingly large alignments, both in number of sites and number of taxa, is a problem that current tools struggle to deal with efficiently. SNP-sites was created with these challenges in mind and this paper demonstrates that it scales well, using modest desktop computers, to sample sizes far in excess of what is currently analysed in single population studies. The software has also been packaged to allow it to be easily installed on a wide variety of operating systems and hardware, something often neglected in bioinformatics.
Introduction
As the cost of sequencing has rapidly decreased, the number of samples sequenced within a study has proportionately increased and now stands in the thousands. A common task in prokaryotic bioinformatics analysis is the extraction of all single nucleotide polymorphisms (SNPs) from a multiple FASTA alignment. Whilst it is a simple problem to describe, current tools cannot rapidly or efficiently extract SNPs in the increasingly large datasets found in prokaryotic population studies. These inefficiencies, such as loading all the data into memory, or slow speed due to algorithm design, make it infeasible to analyse these sample sets on modest computers. Furthermore, existing tools employ challenging, non-standard installation procedures.
A number of applications exist which can extract SNPs from a multi-FASTA alignment, such as JVarKit, TrimAl, PGDSpider and PAUP*.
JVarKit is a Java toolkit which can output SNP positions in variant call format (VCF). The standardised VCF allows for post-processing with BCFtools, which is used to analyse variation in very large datasets such as the Human 1000 Genomes project. It is reasonably fast, however it uses nearly 8 bytes of RAM per base of sequencing, which results in substantial memory usage for even small datasets. For example, a 1 GB alignment (200 taxa, 50 000 sites, 5 Mbp genomes) required 7.2 GB of RAM. TrimAl (version 1.4) is a C++ tool which outputs variation, given a multiple FASTA alignment, however it does not support VCF, only outputting the positions of SNPs in a bespoke format. It is very slow for small sample sets, however it uses less memory than JVarKit. PGDSpider is a Java based application which can output a VCF file, however the authors warn it is not suitable for large files, so it has been excluded from this analysis. PAUP* is a popular commercial application but as it is no longer distributed it was not available for comparison. None of these applications are easily installable on a wide variety of operating systems and environments. TrimAl is the only application available in Homebrew and none are available through the Debian package management system.
Here we present SNP-sites which overcomes these limitations by managing disk I/O and memory carefully, and optimizing the implementation using C (ISO C99 compliant). Standard installation methods are used, with the software prepackaged and available through the Debian and Homebrew package managers. The software has been successfully run on more than 20 architectures using Debian Linux, Redhat Enterprise Linux and on multiple versions of OS X. A Cython version of the SNP-sites algorithm called PySnpSites (https://github.com/bewt85/PySnpSites) is also presented for comparison purposes.
Theory and Implementation
The input to the software is a single multiple FASTA alignment of nucleotides, where all sequences are the same length and have already been aligned. The file can optionally be gzipped. This alignment may have been generated by overlaying SNPs on a consensus reference genome, or using a multiple alignment tool, such as MUSCLE, PRANK, MAFFT, or ClustalW.
By default the output format is a multiple FASTA alignment. The output format can optionally be changed to PHYLIP format or VCF (version 4.1). When used as a preprocessing step for FastTree, this substantially decreases the memory usage of FastTree during phylogenetic tree reconstruction. The PHYLIP format can be used as input to RAxML for creating phylogenetic trees. For phylogenetic reconstructions removing monomorphic sites from an alignment may require a different model to avoid parameters being incorrectly estimated. The VCF output retains the position of the SNPs in each sample and can be parsed using standard tools such as BCFtools or for GWAS analysis using PLINK.
Each sequence is read in sequentially. A consensus sequence is generated in the first pass and is iteratively compared to each sequence. The position of any difference is noted. A second pass of the input file extracts the bases at each SNP site and outputs them in the chosen format. Where a base is unknown or is a gap (n/N/?/-), the base is regarded as a non-variant.
For example, given the input alignment:
the output is:
The first site (column) of the input contains the base A in all samples. As there is no variation this site is excluded from the output. The second site in the input contains bases A and G, and since there is variation at this site, it is outputted. The third site in the input contains a gap and the base A. Since gaps are regarded as non-variants, this site is not outputted.
The maximum resource requirements of the algorithm are known. Given the number of SNP sites is p, the number of samples is s and the number of bases in a single alignment is g, the maximum memory usage can be defined as:
max(p×s, g×2)
Given that f is the size of the input file and o is the size of the output file, the file I/O is defined as:
2×f<= I/O<= 2×f+o
The computational complexity is O(n). These properties make the algorithm theoretically scalable and feasible on large datasets far beyond what is currently analysed within a single study.
All changes to SNP-sites are validated automatically against a hand-generated set of example cases incorporated into unit tests. A continuous integration system (https://travis-ci.org/sanger-pathogens/snp-sites) ensures that modifications which change the output erroneously are publicly flagged.
To test the performance of SNP-sites, we have compared it with JVarKit, TrimAl and PySnpSites (https://github.com/bewt85/PySnpSites). PySnpSites is a Cython-based partial reimplementation of the SNP-sites algorithm. A number of simulated datasets were generated to exercise the different parameters and to see their effect on memory usage and running time. All of the software to generate these datasets is contained within the SNP-sites source code repository.
All experiments were performed using a single processor (2.1 Ghz AMD Opteron 6272) with a maximum of 16 GB of RAM available. The maximum run-time of an application was set as 12 h, after which time the experiment was halted.
Alignments were generated with varying numbers of SNPs to show the effect of SNP density on the performance of each application. Each alignment had 1000 samples and a genome alignment length of 5 Mbp, with a total file size of 4.8 GB. This is a scale encountered in recent studies. As the SNP density increases, so does the running time and memory usage as seen in Fig. 1. The running time of both SNP-sites and PySnpSites is reasonable, however the memory usage of PySnpSites rapidly exceeds the maximum allowed memory (16 GB). Where 20 % of bases in the input alignment are SNPs, SNP-sites uses only 1 GB of RAM, or approximately 20 % of the file input size, scaling with the volume of variation rather than the size of the input file. In all experiments JVarKit exceeded the maximum allowed memory and was halted. All experiments using TrimAl exceeded the maximum running time of 12 h. As both of these applications did not successfully complete they are not present in the results.
The number of samples analysed within a single study now stands in the thousands. To cope with this scale and to demonstrate how applications will perform in the future, we generated alignments with 100 to 100 000 samples. Each genome contained 1 Mbp, and 1000 SNP sites. The total file sizes ranged from 0.1 GB to 86 GB. As the number of taxa increase, the running time of PySnpSites and SNP-sites increases linearly, with SNP-sites taking 32 min to analyse an 86 GB alignment with 100 000 taxa as can be seen in Fig. 2(a). The running time of JVarKit is ten times greater than that of PySnpSites and SNP-sites as shown in Fig. 2(b), however it exceeds the 16 GB maximum memory limit beyond 1000 taxa. The running time of TrimAl is another order of magnitude greater, making it rapidly infeasible to run. The memory usage of SNP-sites is substantially less than all other applications, with the closest, PySnpSites using 9.2 GB of RAM compared to 0.274 GB of RAM for SNP-sites.
Finally the length of each genome in the alignment was varied from 100 000 to 100 Mbp with 1000 taxa and 1000 SNP sites in each alignment. PySnpSites and SNP-sites performed consistently well as shown in Fig. 3(a), with both taking ≈40 min to process the largest 95 GB alignment file. SNP-sites uses just 203 MB of RAM compared to 691 MB by PySnpSites as shown in Fig. 3(b). The other two applications exceed the maximum running times and/or the maximum memory whilst trying to analyse 5 Mbp genomes, which is the size of a typical Gram-negative bacterial genome.
The performance of SNP-sites was evaluated on a real data set of Salmonella Typhi from. A total of 1842 taxa were aligned to the 4.8 Mbp chromosome (GenBank accession number AL513382) of S. Typhi CT18. This gave a total alignment file size of 8.3 GB and incorporated SNPs at 22 618 sites. SNP-sites used 59 MB of RAM and took 267 seconds.
Conclusion
Extracting variation from a multiple FASTA alignment is a common task, and whilst it is simple to define, existing tools fail to perform well. We showed that SNP-sites performed consistently under a variety of conditions, using low amounts of RAM and had a low running time for even for the largest datasets we simulated to represent the scale of studies expected in the near future. This makes it feasible to run on standard desktop machines. SNP-sites uses standard installation methods with the software prepackaged and available through the Debian and Homebrew package managers. The software has been successfully tested and run on more than 20 architectures using Debian Linux and on multiple versions of OS X.
References 20
- 1.
Capella-Gutiérrez S. Silla-Martínez J. M. Gabaldón T. (2009 ). trimAl: a tool for automated alignment trimming in large-scale phylogenetic analyses. Bioinformatics251972–1973. Available at: http://bioinformatics.oxfordjournals.org/cgi/content/long/25/15/1972.
Not in our library10.1093/bioinformatics/btp348
- 2.
- 3.
Chewapreecha C. Harris S. R. Croucher N. J. Turner C. Marttinen P. Cheng L. Pessia A. Aanensen D. M. Mather A. E. other authors (2014 ). Dense genomic sampling identifies highways of pneumococcal recombination. Nat Genet46305–309.
Not in our library10.1038/ng.2895
- 4.
Danecek P. Auton A. Abecasis G. Albers C. A. Banks E. DePristo M. A. Handsaker R. E. Lunter G. Marth G. T. other authors (2011 ). The variant call format and VCF tools. Bioinformatics272156–2158. Available at http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=3137218&tool=pmcentrez&rendertype=abstract.
Not in our library10.1093/bioinformatics/btr330
- 5.
Edgar R. C. (2004 ). MUSCLE: multiple sequence alignment with high accuracy and high throughput. Nucleic Acids Res321792–1797. Available at http://www.ncbi.nlm.nih.gov/pubmed/15034147.
Not in our library10.1093/nar/gkh340
- 6.
Felsenstein J. (1989 ). Phylip: Phylogeny inference package (version 3.2). Cladistics5164–166. Available at http://evolution.genetics.washington.edu/phylip/faq.html#citation.
Not in our library
- 7.
Katoh K. Standley D. M. (2013 ). MAFFT multiple sequence alignment software version 7: Improvements in performance and usability. Mol Biol Evol30772–780. Available at http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=3603318&tool=pmcentrez&rendertype=abstract.
Not in our library10.1093/molbev/mst010
- 8.
Lindenbaum P. (2015 ). JVarkit: java-based utilities for Bioinformatics. Figshare. Available at http://dx.doi.org/10.6084/m9.figshare.1425030.
Not in our library
- 9.
Lischer H. E. Excoffier L. (2012 ). Pgdspider: an automated data conversion tool for connecting population genetics and genomics programs. Bioinformatics28298–299. Available at http://www.ncbi.nlm.nih.gov/pubmed/22110245.
Not in our library10.1093/bioinformatics/btr642
- 10.
Löytynoja A. (2014 ). Phylogeny-aware alignment with PRANK. Methods Mol Biol1079155–170. Available at http://europepmc.org/abstract/MED/24170401.
Not in our library10.1007/978-1-62703-646-7_10
- 11.
Nasser W. (2014 ). Evolutionary pathway to increased virulence and epidemic group A streptococcus disease derived from 3,615 genome sequences. National Academy of Sciences of the United States of America, 111E1768–1776. Available at http://www.pubmedcentral.nih.gov/articlerender.fcgi?artid=4035937&tool=pmcentrez&rendertype=abstract.
Not in our library10.1073/pnas.1403138111
- 12.
- 13.
Stamatakis A. (2014 ). Raxml version 8: A tool for phylogenetic analysis and post-analysis of large phylogenies. Bioinformatics301312–1313.
Not in our library10.1093/bioinformatics/btu033
- 14.
Sudmant P. H. Rausch T. Gardner E. J. Handsaker R. E. Abyzov A. Huddleston J. Zhang Y. Ye K. Jun G. Korbel J. O. 1000 Genomes Project Consortium(2015 ). An integrated map of structural variation in 2,504 human genomes. Nat New Biol52675–81. Available at http://dx.doi.org/10.1038/nature15394.
Not in our library10.1038/nature15394
- 15.
Swofford D. L. (2002 ). paup*: Phylogenetic analysis using parsimony (and other methods), version 4. Sunderland, MA: Sinauer Associates.
Not in our library
- 16.
Thompson J. D. Gibson T. J. Higgins D. G. (2002 ). Multiple sequence alignment using ClustalW and ClustalX. Curr Protoc Bioinformatics. Available at http://www.ncbi.nlm.nih.gov/pubmed/18792934.
Not in our library10.1002/0471250953.bi0203s00
- 17.
Wong V. K. Baker S. Pickard D. J. Parkhill J. Page A. J. Feasey N. A. Kingsley R. A. Thomson N. R. Keane J. A. Dougan G. (2015 ). Phylogeographical analysis of the dominant multidrug-resistant H58 clade of Salmonella Typhi identifies inter- and intracontinental transmission events. Nat Genet47632–639. Available at http://www.ncbi.nlm.nih.gov/pubmed/25961941.
Not in our library10.1038/ng.3281
- 18.
Page, A.J. (2016). Github https://github.com/sanger-pathogens/snp-sites.
Not in our library
- 19.
Wong, V & Holt K. (2016). Figshare: https://dx.doi.org/10.6084/m9.figshare.2067249.v1
Not in our library
- 20.
Parkhill, J. (2001). Genbank accession number AL513382.
Not in our library
Cited by papers we hold 21
- Suppression of gut colonization by multidrug-resistant Escherichia coli clinical isolates through cooperative niche exclusion · 2025Not checked
- Evolution and host-specific adaptation of Pseudomonas aeruginosa · 2024No notice
- Retrospective detection of asymptomatic monkeypox virus infections among male sexual health clinic attendees in Belgium · 2022No notice
- Convergence of virulence and antimicrobial resistance in increasingly prevalent Escherichia coli ST131 papGII+ sublineages · 2022Not checked
- A 2-million-year-old ecosystem in Greenland uncovered by environmental DNA · 2022No notice
- Monitoring the Microevolution of Salmonella enterica in Healthy Dairy Cattle Populations at the Individual Farm Level Using Whole-Genome Sequencing · 2021Not checked
- Genetic diversity of Salmonella Paratyphi A isolated from enteric fever patients in Bangladesh from 2008 to 2018. · 2021Not checked
- Ecological niche adaptation of Salmonella Typhimurium U288 is associated with altered pathogenicity and reduced zoonotic potential · 2021Not checked
- CoronaHiT: high-throughput sequencing of SARS-CoV-2 genomes · 2021Not checked
- Persistence of Brucella abortus lineages revealed by genomic characterization and phylodynamic analysis. · 2020Not checked
- Genomic and Phenotypic Analyses of Acinetobacter baumannii Isolates From Three Tertiary Care Hospitals in Thailand · 2020Not checked
- Stepwise evolution of Salmonella Typhimurium ST313 causing bloodstream infection in Africa · 2020No notice
- A Klebsiella pneumoniae ST307 outbreak clone from Germany demonstrates features of extensive drug resistance, hypermucoviscosity, and enhanced iron acquisition · 2020No notice
- Proposal of a Taxonomic Nomenclature for the Bacillus cereus Group Which Reconciles Genomic Definitions of Bacterial Species with Clinical and Industrial Phenotypes · 2020No notice
- Bactopia: a Flexible Pipeline for Complete Analysis of Bacterial Genomes · 2020No notice
- Developing Chloroplast Genomic Resources from 25 <i>Avena</i> Species for the Characterization of Oat Wild Relative Germplasm · 2019Not checked
- An African Salmonella Typhimurium ST313 sublineage with extensive drug-resistance and signatures of host adaptation · 2019No notice
- Emergence of an Extensively Drug-Resistant Salmonella enterica Serovar Typhi Clone Harboring a Promiscuous Plasmid Encoding Resistance to Fluoroquinolones and Third-Generation Cephalosporins · 2018No notice
- A molecular portrait of maternal sepsis from Byzantine Troy · 2017Not checked
- ARIBA: rapid antimicrobial resistance genotyping directly from sequencing reads · 2017No notice
and 1 more
Reads
Read by people on this page
None yet.
Checked or read by AI through naulon
None yet.
A person counts once a day per paper. We keep no cookie and no address: a reader is a hash that changes every day. Any month under five reads shows no number.
Are you an author?
Is this your paper?
Claim it to add your note and be paid when agents cite it. Free.