Repository navigation
Recipes
These are copy-ready patterns I use for real jobs, not isolated flag examples. Read the linked command pages when you need to change a recipe or understand its failure boundary.
z-fasta validate --strict reference.faContinue only when validation exits 0:
z-fasta index reference.fa
z-fasta stats reference.fa > reference.stats.txtDo not let a clean-looking report hide a nonzero status. Treat strict validation as the approval gate.
z-fasta validate source.fa
z-fasta validate --fix -o source.clean.fa source.fa
z-fasta validate --strict source.clean.faEmit the compatibility index only after strict validation exits 0:
z-fasta index --emit-fai source.clean.fa > source.clean.fa.faiThe strict post-fix validation is the quality gate.
Convert or store the requests as BED:
z-fasta get reference.fa --bed regions.bed > regions.faBED streams without a whole-input row cap.
If the first tab-separated column contains identifiers:
cut -f1 selected.tsv | z-fasta get proteins.fa --names - > selected.faMake sure the stream contains no header row unless it begins with #.
z-fasta get reference.fa \
--bed genes.bed \
--strand-aware \
--annotate-rc \
> genes.faMinus rows become reverse-complement. Plus, dot, empty, and missing strand remain forward.
z-fasta get reference.fa \
--bed genes.bed \
--strand-aware \
--rc \
--annotate-rc \
> genes.opposite.faOn minus rows, BED reverse-complement and global reverse-complement cancel. On plus rows, the global transform remains.
GET can emit earlier records before a later names or BED request fails. Write to a temporary path and publish only after success:
output=regions.fa
output_tmp=$(mktemp "${output}.tmp.XXXXXX")
if z-fasta get reference.fa --bed regions.bed > "$output_tmp"; then
mv "$output_tmp" "$output"
else
rm -f "$output_tmp"
exit 1
fiThe temporary file sits beside the final path, so the successful mv remains on one filesystem.
z-fasta get reference.fa --names ids.txt --summary \
> selected.fa \
2> selected.summary.txtThe summary appears only after successful output.
z-fasta validate \
--strict \
--json \
incoming.fa \
> validation.jsonWarnings become exit 1 while the JSON severities remain unchanged. Read validation.outcome and the exit status together.
z-fasta validate \
--strict \
--schema refseq \
--max-header-len 200 \
--json \
reference.fa \
> validation.jsonz-fasta validate --custom-alphabet 'ACGTN-.' aligned.fa
z-fasta validate \
--custom-alphabet 'ACGTN-.' \
--fix \
-o aligned.clean.fa \
aligned.faBytes outside the alphabet do not block repair; the copy keeps them and validation still reports them.
z-fasta index assembly-a.fa
z-fasta index assembly-b.fa
z-fasta stats assembly-a.fa > assembly-a.stats.txt
z-fasta stats assembly-b.fa > assembly-b.stats.txt
diff -u assembly-a.stats.txt assembly-b.stats.txtBuild both indexes with the same tool before comparing the biological metrics; a samtools .fai leaves out later duplicates.
The raw diff also includes the FASTA path and file size. Use it for human review, not as a stable machine comparison contract.
z-fasta validate --strict reference.next.faReplace the source only after validation exits 0:
mv reference.next.fa reference.fa
z-fasta index reference.fa
z-fasta stats reference.fa > reference.stats.txtDo not touch an old sidecar forward to hide staleness. Rebuild it against the new source.
z-fasta v0.4.0 | Home | Quick start | Cheat sheet | Troubleshooting | Releases | MIT License
z-fasta Wiki
Start
Use z-fasta
Understand behavior
- Index formats
- Coordinates and names
- Limits and supported formats
- Performance and correctness
- Tool comparison
Solve a problem
Contribute