# shenwei356/seqkit architecture

> Architecture diagram of the GitHub repository shenwei356/seqkit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shenwei356/seqkit
- Repository: https://github.com/shenwei356/seqkit

## Overview

SeqKit is a cross-platform command-line toolkit for manipulating FASTA/Q sequence data. Users invoke a subcommand on files or streams and receive transformed records, search results, statistics, or other command-specific output. The README documents format conversion, sequence editing, searching, sampling, indexing, and analysis; the tree maps these capabilities to command modules. The shown entry point calls the command package, while command-to-command and shared parsing internals are not fully visible in the excerpts, so those connections are limited to documented behavior.

Main entry points: [`seqkit/cmd/root.go`](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/root.go) (Command dispatcher), [`seqkit/main.go`](https://github.com/shenwei356/seqkit/blob/master/seqkit/main.go) (Program entry), [`seqkit/cmd/seq.go`](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/seq.go) (Sequence transform), [`seqkit/cmd/grep.go`](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/grep.go) (Sequence filtering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_main["Program entry<br/>[main.go]"]
  node_dispatcher["Command dispatcher<br/>[root.go]"]
  node_shared["Shared command utilities"]
end

subgraph group_basic["Sequence operations"]
  node_seq["Sequence transform<br/>[seq.go]"]
  node_subseq["Region extraction<br/>[subseq.go]"]
  node_sliding["Sliding windows<br/>[sliding.go]"]
  node_translate["Sequence translation<br/>[translate.go]"]
  node_mutate["Sequence mutation<br/>[mutate.go]"]
  node_replace["Pattern replacement<br/>[replace.go]"]
  node_rename["Sequence renaming<br/>[rename.go]"]
end

subgraph group_search["Search and selection"]
  node_grep["Sequence filtering<br/>[grep.go]"]
  node_locate["Motif location<br/>[locate.go]"]
  node_amplicon["Amplicon extraction<br/>[amplicon.go]"]
  node_fish["Short-sequence search<br/>[fish.go]"]
  node_sample["Sequence sampling<br/>[sample.go]"]
  node_sample2["Sampling v2<br/>[sample2.go]"]
end

subgraph group_formats["Formats and files"]
  node_faidx["FASTA indexing<br/>[faidx.go]"]
  node_convert["Quality conversion<br/>[convert.go]"]
  node_fx2tab["FASTA/Q to table<br/>[fx2tab.go]"]
  node_tab2fx["Table to FASTA/Q<br/>[tab2fx.go]"]
  node_split["File splitting<br/>[split.go]"]
  node_scat["Stream concatenation<br/>[scat.go]"]
end

subgraph group_analysis["Analysis and alignment"]
  node_stat["Sequence statistics<br/>[stat.go]"]
  node_watch["Feature monitoring<br/>[watch.go]"]
  node_bam["BAM analysis<br/>[bam.go]"]
  node_bamtools["BAM tools<br/>[bam_toolbox.go]"]
end

node_user(("CLI user"))

node_user -->|"runs"| node_main
node_main -->|"calls Execute"| node_dispatcher
node_dispatcher -.->|"offers subcommand"| node_seq
node_dispatcher -.->|"offers subcommand"| node_subseq
node_dispatcher -.->|"offers subcommand"| node_sliding
node_dispatcher -.->|"offers subcommand"| node_translate
node_dispatcher -.->|"offers subcommand"| node_mutate
node_dispatcher -.->|"offers subcommand"| node_replace
node_dispatcher -.->|"offers subcommand"| node_rename
node_dispatcher -.->|"offers subcommand"| node_grep
node_dispatcher -.->|"offers subcommand"| node_locate
node_dispatcher -.->|"offers subcommand"| node_amplicon
node_dispatcher -.->|"offers subcommand"| node_fish
node_dispatcher -.->|"offers subcommand"| node_sample
node_dispatcher -.->|"offers subcommand"| node_sample2
node_dispatcher -.->|"offers subcommand"| node_faidx
node_dispatcher -.->|"offers subcommand"| node_convert
node_dispatcher -.->|"offers subcommand"| node_fx2tab
node_dispatcher -.->|"offers subcommand"| node_tab2fx
node_dispatcher -.->|"offers subcommand"| node_split
node_dispatcher -.->|"offers subcommand"| node_scat
node_dispatcher -.->|"offers subcommand"| node_stat
node_dispatcher -.->|"offers subcommand"| node_watch
node_dispatcher -.->|"offers subcommand"| node_bam
node_dispatcher -.->|"offers subcommand"| node_bamtools
node_seq -.->|"uses utilities"| node_shared
node_grep -.->|"uses utilities"| node_shared

click node_main "https://github.com/shenwei356/seqkit/blob/master/seqkit/main.go"
click node_dispatcher "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/root.go"
click node_seq "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/seq.go"
click node_subseq "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/subseq.go"
click node_sliding "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sliding.go"
click node_translate "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/translate.go"
click node_mutate "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/mutate.go"
click node_replace "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/replace.go"
click node_rename "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/rename.go"
click node_grep "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/grep.go"
click node_locate "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/locate.go"
click node_amplicon "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/amplicon.go"
click node_fish "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/fish.go"
click node_sample "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sample.go"
click node_sample2 "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sample2.go"
click node_faidx "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/faidx.go"
click node_convert "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/convert.go"
click node_fx2tab "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/fx2tab.go"
click node_tab2fx "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/tab2fx.go"
click node_split "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/split.go"
click node_scat "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/scat.go"
click node_stat "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/stat.go"
click node_watch "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/watch.go"
click node_bam "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/bam.go"
click node_bamtools "https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/bam_toolbox.go"
click node_shared "https://github.com/shenwei356/seqkit/tree/master/seqkit/cmd"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_dispatcher,node_shared,node_user toneBlue
class node_seq,node_subseq,node_sliding,node_translate,node_mutate,node_replace,node_rename toneAmber
class node_grep,node_locate,node_amplicon,node_fish,node_sample,node_sample2 toneMint
class node_faidx,node_convert,node_fx2tab,node_tab2fx,node_split,node_scat toneRose
class node_stat,node_watch,node_bam,node_bamtools toneIndigo
```

## Components

### CLI entry

- [Program entry](https://github.com/shenwei356/seqkit/blob/master/seqkit/main.go): `seqkit/main.go`
- [Command dispatcher](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/root.go): `seqkit/cmd/root.go`
- [Shared command utilities](https://github.com/shenwei356/seqkit/tree/master/seqkit/cmd): `seqkit/cmd`

### Sequence operations

- [Sequence transform](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/seq.go): `seqkit/cmd/seq.go`
- [Region extraction](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/subseq.go): `seqkit/cmd/subseq.go`
- [Sliding windows](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sliding.go): `seqkit/cmd/sliding.go`
- [Sequence translation](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/translate.go): `seqkit/cmd/translate.go`
- [Sequence mutation](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/mutate.go): `seqkit/cmd/mutate.go`
- [Pattern replacement](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/replace.go): `seqkit/cmd/replace.go`
- [Sequence renaming](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/rename.go): `seqkit/cmd/rename.go`

### Search and selection

- [Sequence filtering](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/grep.go): `seqkit/cmd/grep.go`
- [Motif location](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/locate.go): `seqkit/cmd/locate.go`
- [Amplicon extraction](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/amplicon.go): `seqkit/cmd/amplicon.go`
- [Short-sequence search](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/fish.go): `seqkit/cmd/fish.go`
- [Sequence sampling](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sample.go): `seqkit/cmd/sample.go`
- [Sampling v2](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/sample2.go): `seqkit/cmd/sample2.go`

### Formats and files

- [FASTA indexing](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/faidx.go): `seqkit/cmd/faidx.go`
- [Quality conversion](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/convert.go): `seqkit/cmd/convert.go`
- [FASTA/Q to table](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/fx2tab.go): `seqkit/cmd/fx2tab.go`
- [Table to FASTA/Q](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/tab2fx.go): `seqkit/cmd/tab2fx.go`
- [File splitting](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/split.go): `seqkit/cmd/split.go`
- [Stream concatenation](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/scat.go): `seqkit/cmd/scat.go`

### Analysis and alignment

- [Sequence statistics](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/stat.go): `seqkit/cmd/stat.go`
- [Feature monitoring](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/watch.go): `seqkit/cmd/watch.go`
- [BAM analysis](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/bam.go): `seqkit/cmd/bam.go`
- [BAM tools](https://github.com/shenwei356/seqkit/blob/master/seqkit/cmd/bam_toolbox.go): `seqkit/cmd/bam_toolbox.go`

### Other components

- **CLI user**

## Connections

- CLI user → Program entry: runs (evidence: `seqkit/main.go`)
- Program entry → Command dispatcher: calls Execute (evidence: `seqkit/main.go`)
- Command dispatcher → Sequence transform: offers subcommand
- Command dispatcher → Region extraction: offers subcommand
- Command dispatcher → Sliding windows: offers subcommand
- Command dispatcher → Sequence translation: offers subcommand
- Command dispatcher → Sequence mutation: offers subcommand
- Command dispatcher → Pattern replacement: offers subcommand
- Command dispatcher → Sequence renaming: offers subcommand
- Command dispatcher → Sequence filtering: offers subcommand
- Command dispatcher → Motif location: offers subcommand
- Command dispatcher → Amplicon extraction: offers subcommand
- Command dispatcher → Short-sequence search: offers subcommand
- Command dispatcher → Sequence sampling: offers subcommand
- Command dispatcher → Sampling v2: offers subcommand
- Command dispatcher → FASTA indexing: offers subcommand
- Command dispatcher → Quality conversion: offers subcommand
- Command dispatcher → FASTA/Q to table: offers subcommand
- Command dispatcher → Table to FASTA/Q: offers subcommand
- Command dispatcher → File splitting: offers subcommand
- Command dispatcher → Stream concatenation: offers subcommand
- Command dispatcher → Sequence statistics: offers subcommand
- Command dispatcher → Feature monitoring: offers subcommand
- Command dispatcher → BAM analysis: offers subcommand
- Command dispatcher → BAM tools: offers subcommand
- Sequence transform → Shared command utilities: uses utilities
- Sequence filtering → Shared command utilities: uses utilities
