Repository navigation
sum: a file that fails is left out of the output, but the exit code is 0 #613
Description
Version: seqkit v2.14.0 (bioconda), Linux x86_64
In each case below, sum writes a message, writes no line for that file,
continues with the next files and exits 0. A script that checks the exit
code does not see that a file is missing. A missing file gives exit 255, so
the two kinds of failure disagree. The progress bar lines are removed from
the output.
Test files:
$ printf '>a\nACGT\n>b\nGGGG\n' > t.fa
$ printf '>c\nTTTT\n' > u.fa
$ awk 'BEGIN{print ">A"; for(i=0;i<15;i++) printf "ACGT"; print ""}' > A.fa
$ printf '>p\nMKVLAAGIW\n' > prot.fa
$ printf '>a\nACGTACGT\n>b\nGGCCAATT\n' > two.fa
sum -c: k too big, or protein input
$ seqkit sum -c A.fa
[ERRO] k (1000) is too big for sequence of 60 bp: A.fa
$ echo $?
0
$ seqkit sum -c -k 3 prot.fa
[ERRO] the flag -c/--circular does not support protein sequences: prot.fa
$ echo $?
0
Expected: a non-zero exit code after an [ERRO] message.
sum -c: a file with more than one sequence
$ seqkit sum -c -k 2 two.fa u.fa
[WARN] skip file with more than 1 sequences: two.fa
seqkit.v0.1_DCD_k2_3fcbf84a5fc9f459c2b154ab7d4ed9b3 u.fa
$ echo $?
0
Expected: an error and a non-zero exit code when all files are done.
sum: a directory, a non-sequence file or a broken FASTQ
$ mkdir dd
$ printf 'hello\n' > x.txt
$ printf '@a\nACGT\n+\nII\n' > b.fq
$ seqkit sum dd x.txt b.fq t.fa
[WARN] skip file: dd: fastx: xopen: input is a directory
[WARN] b.fq: fastx: unequal sequence and quality
[WARN] x.txt: fastx: invalid FASTA/Q format
seqkit.v0.1_DLS_k0_af09c73fbf60e59e4c72e8052ee7cb8b t.fa
$ echo $?
0
$ seqkit sum nofile.fa t.fa
[ERRO] stat nofile.fa: no such file or directory
$ echo $?
255
Expected: an error and a non-zero exit code, as for a missing file.
sum --id-regexp: a bad regular expression skips every file
A regular expression that does not compile, or that has no capturing group,
is reported once for each file. No file gets a line.
$ seqkit sum -i --id-regexp '(' t.fa u.fa
[WARN] skip file: u.fa: fastx: fail to compile regexp "(": error parsing regexp: missing closing ): `(`
[WARN] skip file: t.fa: fastx: fail to compile regexp "(": error parsing regexp: missing closing ): `(`
$ echo $?
0
$ seqkit sum --id-regexp 'aaa' t.fa
[WARN] skip file: t.fa: fastx: regular expression must contain a capturing group for the ID; default: ^(\S+)\s?
$ echo $?
0
Expected: one error before any file is read, and a non-zero exit code.
sum - -: stdin given twice gives two different digests
Two workers read stdin at the same time. One line gets the digest of the
data. The other line gets the digest of an empty input. A file given twice
gives two equal lines.
$ cat t.fa | seqkit sum - -
seqkit.v0.1_LS_k0_56fc8fa222734a7d4b9ddedcca604bbf -
seqkit.v0.1_DLS_k0_af09c73fbf60e59e4c72e8052ee7cb8b -
$ seqkit sum t.fa t.fa
seqkit.v0.1_DLS_k0_af09c73fbf60e59e4c72e8052ee7cb8b t.fa
seqkit.v0.1_DLS_k0_af09c73fbf60e59e4c72e8052ee7cb8b t.fa
Expected: stdin is read once, and each - gets the same digest, or an
error when - is given more than once.
Activity
Fix quality conversion and sum errors, and reject duplicate stdin inp…
shenwei356 commentedon Oct 19, 2026
fixed. new binaries here: #608