Repository navigation
Automation
This page is for scripts and workflow engines. The one rule to remember: trust the exit status, not the output. A run can write records and then fail, and only the status tells the two apart.
| Status | Meaning |
|---|---|
0 |
success |
1 |
a record or pair failed validation |
2 |
the command line is invalid |
3 |
I/O, gzip, output, or memory failure |
4 |
a line, sampling, or arithmetic limit was reached |
130, 143
|
interrupted by SIGINT or SIGTERM |
count, stats, and check on several independent inputs carry on past a failed input and exit with the highest status seen. Pair commands and process stop at the first failure.
z-fastq does not catch SIGINT or SIGTERM: the signal ends it, and the shell reports 130 or 143. A program that waits for z-fastq directly sees the signal, not an exit status.
Data goes to standard output and messages to standard error, so capture them separately:
if ! z-fastq stats reads.fastq > reads.stats.txt 2> reads.stats.err; then
cat reads.stats.err >&2
exit 1
fiAn invalid command line (status 2) is reported on standard error before anything else is written, including the case of an input that is also the output.
Commands that write FASTQ stream it: records go out as they are read. A failure later in the input, such as a malformed record or a damaged gzip member, leaves the earlier records written; the two files of deinterleave then end with the same complete pairs. A failed write, such as a full disk, can leave an output ending inside a record, and the two files of deinterleave with different numbers of records. An interrupted run leaves its output in place too, and deinterleave keeps both files.
Write to a temporary path and move it into place only after a zero status:
if z-fastq sample --count 10000 --seed 2025 reads.fastq > sample.fastq.tmp; then
mv sample.fastq.tmp sample.fastq
else
rm -f sample.fastq.tmp
exit 1
fi| Command | Schema | Fields |
|---|---|---|
stats --json |
z-fastq/stats-v1 |
Counting and statistics |
check --json |
z-fastq/check-v1 |
Validation |
process --report |
z-fastq/process-v1 |
Report reference |
process --qc-summary |
z-fastq/qc-summary-v1 |
Report reference |
Check the schema field before reading a document; tool.name and tool.version say which build wrote it. Version 0.1.0 froze the stats-v1 and check-v1 shapes. Results follow the order of the inputs, and an input that failed has its error inside its own entry. Still check the exit status: a document can hold failed inputs, and an output failure can cut it short.
Each is one JSON object on one line. After schema, tool, and byte_strings (Report reference), results holds one entry per input:
{"schema":"z-fastq/check-v1","tool":{"name":"z-fastq","version":"0.2.1"},"byte_strings":"escaped-bytes-v1","results":[{"input":"ok.fq","status":"ok"},{"input":"bad.fq","status":"error","error":{"code":"S002","message":"sequence byte is outside the selected alphabet","record_index":0,"byte_offset":5,"line_in_record":2}}]}-
input: the path as given, orinputs, the two paths, forcheck --paired. -
status:okorerror. Astats-v1entry withokalso holds every field ofstats, withnullwhere the text output prints-. -
error: the failure'scode,message, and position. A record failure (S001toS006) givesrecord_index,byte_offset, andline_in_record; a failure with no position in the records, such asio_errorfor a missing file, gives the same fields asnull. -
failed_input: in a failedcheck --pairedentry, the input whose record failed. - A pair failure in
check --pairedor--interleavedgivespair_indexandrecord_indexes, one per mate: in--paired, the last record read on each side; in--interleaved,nullfor a mate that does not exist.P001(names differ) addsbyte_offsets, andfirst_tokensandnormalized_ids, each mate's asprefix,length, andtruncated, andmate_markers;P002(a missing mate) addsremaining_side,R1orR2.
- Input and output: where data and messages go.
-
Report reference: the fields of the
processdocuments. - Recipes: short patterns built on these rules.
z-fastq v0.2.1 | Home | Getting started | Command cheat sheet | Troubleshooting | Source | Releases
z-fastq Wiki
Start
Use it
- Counting and statistics
- Validation
- Paired reads
- Sampling
- Interleaving
- Processing paired reads
- Quality control
Look things up
Decide and solve
Build on it