This file is the canonical agent guide for this repository. It consolidates the
older AGENTS.md and CLAUDE.md guidance into one source of truth for coding
agents working on SeqFu (CLAUDE.md is now a symlink to this file).
SeqFu is a Nim suite of command-line tools for robust and reproducible FASTA and
FASTQ manipulation. The main seqfu binary exposes subcommands for counting,
statistics, filtering, trimming, interleaving, deinterleaving, tabulation,
viewing, and related sequence workflows. Several specialized utilities are built
as standalone binaries.
Citation:
Telatin A, Fariselli P, Birolo G. SeqFu: A Suite of Utilities for the Robust and Reproducible Manipulation of Sequence Files. Bioengineering 2021, 8, 59. doi.org/10.3390/bioengineering8050059
make # Build all binaries and copied scripts into bin/
make test # Build everything, then run test/mini.sh
make clean # Remove compiled build targets from bin/
nimble build # Build Nim namedBin targets through Nimble
bash test/mini.sh # Run the bash integration suite
bash test/mini.sh grep # Run a focused module test where supportedWhen a restricted environment blocks Nim cache writes, use a writable cache, for
example --nimcache:/private/tmp/seqfu2-nimcache, and report cache issues
separately from source or dependency failures.
- Nim requirement:
nim >= 2.2.0fromseqfu.nimble. - Package version is defined in
seqfu.nimbleand passed at compile time as-d:NimblePkgVersion=$(VERSION). - Main Makefile flags:
--mm:orc -d:NimblePkgVersion=$(VERSION) -d:release --opt:speed --passC:"-Wno-error=incompatible-pointer-types". - Threaded standalone tools add
--threads:on; check the Makefile before adding or changing threaded binaries. - C/C++ helper tools are built from
test/byte/and linked with zlib where the Makefile says so.
src/sfu.nim: mainseqfuentry point, subcommand dispatch table, help text, andincludelist for subcommand modules.src/fastx_*.nim: commands that operate on FASTA and/or FASTQ records.src/fastq_*.nim: FASTQ-specific commands.src/fu_*.nim: standalone or shared specialized utilities.src/seqfu_utils.nim: shared utilities, version handling, types, filename helpers, and common sequence helpers.src/seqfu_records.nim,src/seqfu_legacy_fastx.nim,src/stats_utils.nim,src/merge_utils.nim: shared parser/record/stat support.src/msa.nimandsrc/lib/msa_reader.nim: interactive MSA viewer support.scripts/: Python and shell utilities copied intobin/.test/mini.shandtest/test-*.sh: bash integration harness and modules.data/: small fixtures, including gzipped FASTA/FASTQ files.
- Active FASTA/FASTQ parsing uses
readfx >= 0.8.0; do not describe new work as using the oldreadfqparser unless you have verified a legacy path. src/lib/klib.nimmay still exist for compatibility/history, but current command work should inspect live imports before making parser assumptions.- Regex code uses the Nim
regexpackage. In includedseqfumodules, imports share scope, so preferimport regex except re, match, replace, Regexand qualified calls such asregex.match,regex.replace, andregex.re2. - Important declared dependencies include
docopt,argparse,terminaltables,colorize,illwill,malebolgia,tableview,checksums,iterutils, andzip.
- Use 2-space indentation for Nim.
- Keep imports ordered as standard library, external packages, then local modules where practical.
- Use PascalCase for types, camelCase for variables/procs, and UPPER_CASE for constants.
- Use
include ./filenamefor modules compiled intosrc/sfu.nim. - Use
{.gcsafe.}and{.cast(gcsafe).}deliberately for threaded code or included dispatch wrappers. - Keep streaming behavior for FASTA/FASTQ commands unless a command explicitly requires whole-file state.
- Avoid retaining pointer-backed records from
readfxpointer iterators; consume immediately or copy the needed fields.
For a new seqfu subcommand:
- Create an appropriately named module, usually
src/fastx_<name>.nimorsrc/fastq_<name>.nim. - Add
include ./<module>insrc/sfu.nim. - Add the command and aliases to the
progsdispatch table. - Add concise help text to the appropriate help table in
src/sfu.nim. - Add focused tests in
test/mini.shor a sourcedtest/test-<name>.sh.
For a new standalone utility:
- Create
src/fu_<name>.nimor another source file matching the existing naming pattern. - Add it to
namedBininseqfu.nimble. - Add a Makefile target and include it in
TARGETS. - Add
--threads:ononly if the tool actually needs threaded runtime support. - Add smoke and behavior tests.
- Prefer the smallest meaningful test first, for example
bash test/mini.sh countorbash test/mini.sh grep. - Run
make testwhen changes affect dispatch, shared utilities, parser behavior, output formats, build metadata, or multiple commands. - Many
test/test-*.shfiles are meant to be sourced bytest/mini.sh. If a new module can also run directly, initialize defaults forBINDIR,FILES,OK,FAIL,PASS, andERRORS. - Sourced test modules must update shared
PASSandERRORS; a module that prints successful checks but reports0 passed, 0 failedis not wired correctly. - Use exact sequence and quality payload assertions for parser/output changes where counts alone would miss regressions.
- Before calling a branch ready, run relevant focused tests,
make testwhen warranted, andgit diff --check.
- Update version metadata in
seqfu.nimble. - The test harness may compare local version behavior with release state through
the
RELEASEenvironment variable; use${RELEASE:-0}style defaults in bash when needed. - For Nim API documentation work, update source Nimdoc comments unless generated docs are explicitly requested.
- Keep planning Markdown and generated notes out of commits unless explicitly requested.
- Read the current source before editing; this repository changes quickly enough that older notes may be stale.
- Preserve unrelated worktree changes and untracked files.
- Do not use broad cleanup commands or
git add .. - Keep changes tightly scoped to the requested behavior.
- For dependency, parser, linkage, or migration work, verify the declared metadata and the active imports/call sites in the checkout before concluding.