Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

shuffle, sample, sample2, split: records lost or changed and user files deleted, with exit 0

Aperta
#615 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start by locating the implementations of shuffle, sample, and split, then trace their two-pass input handling, temporary-file creation, FASTQ reader errors, and proportion validation. Reproduce the listed cases with the supplied FASTA/FASTQ examples and compare each result with its expected behavior. Done means all reported cases preserve records and user files, report invalid input or values with a non-zero exit, and keep one-pass and two-pass output consistent.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: seqkit v2.14.0 (bioconda), Linux x86_64

Each section below shows one problem. All commands exit 0. The [INFO]
lines are removed from the output where they do not help.

Test files:

$ printf '>a\nACGT\n>b\nGGGG\n' > t.fa
$ printf '>c\nTTTT\n' > u.fa
$ printf '>x\nAAAA\n>x\nCCCC\n>y\nGGGG\n' > dup.fa

shuffle: records with the same header line get the sequence of the last one

In one-pass mode, records with the same full header line all get the
sequence (and quality) of the last of them. The loaded count gives the
number of different headers, not the number of records.

$ seqkit shuffle -s 1 dup.fa
[INFO] 2 sequences loaded
>x
CCCC
>y
GGGG
>x
CCCC

Expected: each record keeps its own sequence: AAAA is in the output once.

shuffle -2: records with the same header line are dropped

In two-pass mode, the index keeps only the first record for a header line.
The other records are not written. There is only a [fai warning].

$ seqkit shuffle -2 -s 1 dup.fa
[fai warning] ignoring duplicate sequence "x" at byte offset 11
>x
AAAA
>y
GGGG

Expected: all three records are written, as in one-pass mode, or an
error and a non-zero exit code.

shuffle -2 and split -2: an existing file of the user is replaced and deleted

With gzip input or stdin, two-pass mode writes a temporary file
<tmp-dir>/<input>.fastx (or stdin.fastx). When a file with that name
exists, it is replaced and then deleted.

$ gzip -k t.fa
$ printf 'MY OWN FILE\n' > t.fa.gz.fastx
$ seqkit shuffle -2 -s 1 t.fa.gz > /dev/null
$ ls t.fa.gz.fastx
ls: cannot access 't.fa.gz.fastx': No such file or directory

$ printf 'MY OWN FILE\n' > stdin.fastx
$ cat t.fa | seqkit shuffle -2 -s 1 > /dev/null
$ ls stdin.fastx
ls: cannot access 'stdin.fastx': No such file or directory

seqkit split -2 -p 2 -O sp t.fa.gz and cat t.fa | seqkit split -2 -p 2 -O sp
delete the same files.

Expected: an existing file is not touched. A free temporary name is used,
or the command stops with an error.

shuffle -2: a CR at the end of a sequence line stays in the output

One-pass mode removes the CR of a CRLF file. Two-pass mode keeps it on the
sequence lines, so the two modes give different output.

$ printf '>a\r\nACGT\r\n>b\r\nGG\r\n' > c.fa
$ seqkit shuffle -2 -s 2 c.fa | od -c
0000000   >   b  \n   G   G  \r  \n   >   a  \n   A   C   G   T  \r  \n
$ seqkit shuffle -s 2 c.fa | od -c
0000000   >   b  \n   G   G  \n   >   a  \n   A   C   G   T  \n

Expected: the same output as one-pass mode.

sample -n: a broken FASTQ or a non-sequence file gives no error

With -n (one pass), a read error is not reported. The command writes none
or only a part of the records. With -p the same file gives an error.

$ printf '@a\nACGT\n+\nII\n' > b.fq
$ seqkit sample -n 1 b.fq
[INFO] 0 sequences outputted
$ seqkit sample -p 1 b.fq
[ERRO] fastx: unequal sequence and quality
$ echo $?
255

$ printf '@a\nACGT\n+\nIIII\n@b\nACGT\n+\nII\n' > b2.fq
$ seqkit sample -n 2 b2.fq
[INFO] 1 sequences outputted
@a
ACGT
+
IIII

$ printf 'hello\n' > x.txt
$ seqkit sample -n 1 x.txt
[INFO] 0 sequences outputted

Expected: the reader error, as with -p, and exit 255.

sample -X: only the first file is used, the others are dropped

The command line refuses two files:
[ERRO] no more than one file needed (2). With -X, two files are accepted,
but only the first one is read.

$ printf 't.fa\nu.fa\n' > l.txt
$ seqkit sample -p 1 -X l.txt
[INFO] 2 sequences outputted
>a
ACGT
>b
GGGG

$ printf 'u.fa\n' > l1.txt
$ seqkit sample -p 1 -X l1.txt t.fa
[INFO] 2 sequences outputted
>a
ACGT
>b
GGGG

The record c of u.fa is not in the output, and there is no message.

Expected: the same error as on the command line, or all files are used.

sample -p and sample2 -p: NaN passes the range check

-p 2 is refused with value of -p (--proportion) (2.000000) should be in range of (0, 1]. -p NaN is accepted. sample and sample2 with a file
write nothing. sample2 with stdin writes every record.

$ seqkit sample -p NaN t.fa
[INFO] 0 sequences outputted
$ seqkit sample2 -p NaN t.fa
[INFO] seq number: 2
[INFO] 0 sequences outputted
$ cat t.fa | seqkit sample2 -p NaN
[INFO] seq number: 0
[INFO] 2 sequences outputted
>a
ACGT
>b
GGGG

Expected: the range error and exit 255 for NaN.

Lingua principale
Go
Stelle
1.6k
Fork
189
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di shenwei356/seqkit

Tutte le issue di shenwei356/seqkit

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.