mbhall88/skillz

seqkit

Manipulate FASTA/FASTQ files with seqkit — filter, subset, convert, search, deduplicate, split, sample, translate, rename, and summarise sequence data.

Ver código fuente
Documento original del Skill

Contenido del repositorio de origen con títulos, ejemplos, código, tablas, enlaces e imágenes preservados.

seqkit

seqkit is a fast, streaming toolkit for fastx files (FASTA or FASTQ). It has 39 subcommands covering nearly every routine sequence-file operation. Before writing a script that reads a fastx file, check the routing table below.

Requires seqkit on $PATH. If it is not there, this skill does not apply — fall back to scripting.

Rules

  1. Write long flags. Short flags mean different things in different

subcommands: -s is --by-seq in rmdup but --rand-seed in sample, --step in sliding, and --pattern in mutate. -p is --pattern in grep but --point in mutate. Long flags are unambiguous and self-documenting. See references/traps.md for the collision table, needed when reading someone else's command.

  1. `seqkit <cmd> --help` is the authority on whether a flag exists. Never

assume a flag from another subcommand transfers. This document does not list flags on purpose — --help cannot go stale, and published seqkit docs demonstrably do.

  1. If it isn't fastx, it isn't seqkit. Interval arithmetic, BAM

manipulation, alignment, and tabular wrangling are other tools' jobs. See references/boundaries.md.

Leave global flags (-j/--threads, -w/--line-width, --id-regexp) at their defaults unless the user asks.

Routing table

⚠ marks a subcommand with a documented trap — read its entry in references/traps.md before using it.

Inspect and summarise

Want to...Command
Count records, total bases, min/max/mean length, GC%, Q20/Q30seqkit stats ⚠ (lengths and GC include gaps)
Get N50, L50, or any Nxseqkit stats --all --tabular -N 50,90 ⚠
Get machine-readable stats for downstream processingseqkit stats --tabular ⚠
Get per-record length, GC, name, or average quality as a tableseqkit fx2tab ⚠
Find records containing ambiguous or unexpected basesseqkit fx2tab --alphabet ⚠
Get a per-sequence MD5 hashseqkit fx2tab --seq-hash ⚠
Tabulate several files at once, tagging each row with its source file (2.14+)seqkit fx2tab --file-name ⚠
Prove two files contain the same sequences, any order or strandseqkit sum ⚠
Prove two files contain the same records, IDs included (2.14+)seqkit sum --include-id ⚠
Watch length/quality/GC distributions while a pipeline runsseqkit watch
Get BAM record statistics or histogramsseqkit bam

Filter and subset

Want to...Command
Keep sequences above/below a lengthseqkit seq --min-len / --max-len ⚠
Keep reads above an average qualityseqkit seq --min-qual ⚠
Filter and transform in one pass (2.13+)seqkit seq --f-pattern ⚠
Pull out records by ID, from a listseqkit grep --pattern-file ⚠ (matches the whole ID; use --use-regexp for partial)
Pull out records by ID, preserving the list's orderseqkit faidx --region-file ⚠
Take the first N recordsseqkit head
Take the first N bases' worth of recordsseqkit head --length 2G
Take records 101-200, or the last 100seqkit range --range
Take a random subsetseqkit sample2 (2.13+) ⚠
Extract a region by coordinatesseqkit subseq --region ⚠
Extract regions listed in a BED or GTF fileseqkit subseq --bed / --gtf ⚠
Extract features plus flanking sequenceseqkit subseq --gtf --up-stream ⚠
Extract a named region from an indexed FASTAseqkit faidx ⚠
Pull out the first genome from a multi-strain file by name prefixseqkit head-genome

Search

Want to...Command
Find records whose ID matches a patternseqkit grep --use-regexp ⚠
Find records containing a subsequence or motifseqkit grep --by-seq ⚠
Find records containing a motif, allowing mismatchesseqkit grep --by-seq --max-mismatch ⚠
Search with IUPAC/degenerate basesseqkit grep --by-seq --degenerate ⚠
Get the coordinates of every motif matchseqkit locate ⚠
Get motif matches as BED or GTFseqkit locate --bed / --gtf ⚠
Scan for restriction sites from a FASTA of motifsseqkit locate --degenerate --pattern-file ⚠
Do in-silico PCR from a primer pairseqkit amplicon ⚠
Locally align short queries into long sequencesseqkit fish ⚠

Convert and tabulate

Want to...Command
Convert FASTQ to FASTAseqkit fq2fa
Recover FASTQ (with qualities) for sequences you only have as FASTAseqkit fa2fq
Turn fastx into a TSV for downstream toolsseqkit fx2tab ⚠
Turn a TSV back into fastxseqkit tab2fx
Convert FASTQ quality encoding (Solexa/Illumina/Sanger)seqkit convert
Translate DNA/RNA to protein, any genetic code, any frameseqkit translate
Reverse complementseqkit seq --reverse --complement ⚠
Strip gaps from an alignmentseqkit seq --remove-gaps ⚠
Unwrap FASTA to one line per sequenceseqkit seq --line-width 0 ⚠
Extract just the IDs or just the sequencesseqkit seq --name --only-id / --seq ⚠

Set operations and deduplication

Want to...Command
Remove duplicate records by ID or by sequenceseqkit rmdup ⚠ (--by-seq also collapses reverse complements)
Get a report of which records were duplicatedseqkit rmdup --dup-num-file ⚠
Find sequences shared across several filesseqkit common ⚠
Re-pair paired-end reads, dropping or saving singletonsseqkit pair ⚠
Join sequences with the same ID across filesseqkit concat ⚠
Repeat each record N timesseqkit duplicate

Split and sample

Want to...Command
Split into N files, or files of N recordsseqkit split2 --by-part / --by-size ⚠
Split into one file per record, named by IDseqkit split2 --by-size 1 --seqid-as-filename ⚠
Split by ID, by a regex on the header, or by regionseqkit split ⚠
Split paired-end FASTQ, keeping pairs togetherseqkit split2 --read1 --read2 ⚠
Take a random sample of recordsseqkit sample2 (2.13+) ⚠
Chop a sequence into fixed-size windowsseqkit sliding
Merge sliding windows back into intervalsseqkit merge-slides

Edit and reorder

Want to...Command
Rewrite headers with a regexseqkit replace ⚠
Substitute, mask, or delete bases by regex (FASTQ from 2.14+)seqkit replace --by-seq ⚠
Rewrite headers from a TSV lookup tableseqkit replace --kv-file ⚠
Number records sequentially, or stamp the filename into the headerseqkit replace with {nr} / {fbne} ⚠
Make duplicate IDs uniqueseqkit rename ⚠
Introduce point mutations, insertions, or deletionsseqkit mutate ⚠
Rotate a circular genome to a new originseqkit restart
Sort by ID, length, or sequenceseqkit sort ⚠
Shuffle record orderseqkit shuffle ⚠

Streaming and repair

Want to...Command
Repair a truncated or malformed FASTQ, skipping bad recordsseqkit sana
Stream fastx files as they appear in a directoryseqkit scat
Feed a long list of input filesany command, with --infile-list

References

but wrong output, or exhaust memory. Indexed by subcommand.

where the composition is the insight.

and what does it instead.


Verified against seqkit v2.14.0. If a command here is unknown to your seqkit, it is older — check seqkit version.