SeqKit Tutorial

Overview of SeqKit

SeqKit is a versatile and high-speed toolkit designed for the manipulation of FASTA and FASTQ files, which are standard formats for storing nucleotide and protein sequences. Developed by Wei Shen, SeqKit stands out for its cross-platform compatibility, allowing it to run on major operating systems such as Windows, Linux, and macOS without any dependencies or pre-configurations. This makes it an accessible tool for researchers and bioinformaticians who need to perform common sequence file manipulations quickly and efficiently.

SeqKit is built to handle a variety of tasks, including but not limited to converting, searching, filtering, deduplication, splitting, shuffling, and sampling of sequence files. It is particularly noted for its performance, demonstrating competitive execution times and reasonable memory usage when compared to similar tools. The toolkit is implemented in Go programming language and utilizes the pgzip package for reading and writing gzip files, which allows for fast I/O operations. Additionally, SeqKit supports other compression formats like xz, zstd, and bzip2.

The toolkit is open-source and its source code is available on GitHub, encouraging contributions and modifications from the community. For those interested in citing SeqKit in their research, a peer-reviewed article is available in the journal PLOS ONE.

Installation

To install SeqKit, users can download executable binary files directly from the official website or the GitHub repository. Since SeqKit is a standalone program, it does not require any additional installations or configurations, making the setup process straightforward. Users simply need to ensure that the downloaded binary is executable and optionally place it in a directory that is included in the system's PATH environment variable for easy access.

Quick Start

Getting started with SeqKit is as simple as running the seqkit command followed by the specific subcommand that corresponds to the desired operation. The toolkit offers a wide range of subcommands, each tailored to perform a specific function on FASTA/Q files. For example, users can extract amplicons with the amplicon subcommand or monitor BAM record features with the bam subcommand.

Code Examples Of Popular Commands

Here are five popular SeqKit commands with code examples to demonstrate their usage:

  1. Converting FASTQ to FASTA: To convert a FASTQ file to FASTA format, you can use the fq2fa subcommand:
seqkit fq2fa input.fastq -o output.fasta
  1. Extracting Subsequences: If you need to extract subsequences from a FASTA file based on a range, the subseq subcommand is useful:
seqkit subseq -r 5:15 input.fasta -o subsequences.fasta
  1. Filtering Sequences by ID: To filter sequences by their ID, the grep subcommand can be used:
seqkit grep -f ids.txt input.fasta -o filtered.fasta
  1. Deduplication: Removing duplicate sequences by their content can be achieved with the rmdup subcommand:
seqkit rmdup input.fasta -o deduplicated.fasta
  1. Sampling Sequences: For sampling a specific number of sequences from a file, the sample subcommand comes in handy:
seqkit sample -n 100 input.fasta -o sample.fasta

Each of these commands can be further customized with additional flags and options to suit the specific needs of the user. SeqKit also supports parallel processing with the -j flag to specify the number of CPU threads, which can significantly speed up CPU-intensive tasks.

In conclusion, SeqKit is a powerful and user-friendly toolkit for FASTA/Q file manipulation. Its cross-platform nature, combined with its speed and comprehensive set of features, makes it an invaluable resource for anyone working with sequence data. Whether you're a seasoned bioinformatician or just starting out, SeqKit is definitely a tool worth exploring.