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

watch and bam: panics, and asked output that is missing with exit 0

Aperta
#616 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start with the watch and bam command entry points and their tests; reproduce the listed cases using the supplied FASTQ, SAM/BAM, and configuration examples. Trace each panic, silent output, and option error to its handling path, then add regression coverage. Done means invalid inputs return tagged errors with exit 255, valid BAM records are preserved in the stated modes, and the listed edge cases no longer panic.

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

Descrizione

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

Test files. The bam examples use two small BAM files made with samtools:

$ printf '@SQ\tSN:chr1\tLN:40\nr1\t0\tchr1\t1\t60\t10M\t*\t0\t0\tACGTACGTAC\tIIIIIIIIII\tNM:i:0\nr2\t0\tchr1\t5\t30\t10M\t*\t0\t0\tACGTACGTAC\tIIIIIIIIII\n' > x.sam
$ samtools view -b -o x.bam x.sam          # r2 has no NM tag
$ sed 's/IIIIIIIIII$/IIIIIIIIII\tNM:i:0/' x.sam > z.sam
$ samtools view -b -o z.bam z.sam          # every record has NM
$ printf '>chr1\nACGT\n' > notbam.bam      # not a BAM file
$ printf '@a\nACGT\n+\n#III\n' > q.fq

watch and bam: the histogram and picture code panics

$ : > empty.fq
$ seqkit watch empty.fq                    # on a terminal
panic: runtime error: index out of range [0] with length 0

$ printf '@a\nAAAA\n+\nIIII\n' > noGC.fq
$ seqkit watch -f GCSkew -O h.png noGC.fq
panic: runtime error: index out of range [0] with length 0

$ seqkit watch -O h.xyz q.fq               # also with no extension
panic: unsupported format: "xyz"           # and an empty h.xyz is left

$ seqkit watch -O /nonexist/h.png q.fq
panic: open /nonexist/h.png: no such file or directory

$ seqkit bam -f MapQual -O h.txt -Q x.bam
panic: unsupported format: "txt"

Each exits 2.

Expected

An [ERRO] message and exit 255, as for other bad input. No empty file is
left.

watch -f MeanQual: a quality letter below -b panics

$ seqkit watch -f MeanQual -y -b 40 q.fq
panic: runtime error: index out of range [-5]
$ echo $?
2

The same class of problem as #598.

Expected

An error that names the bad quality letter, exit 255.

watch: a terminal narrower than 11 columns panics

$ printf '>a\nACGT\n>b\nACGTACGTAC\n' > two.fa
$ script -qec "stty cols 5; seqkit watch -y two.fa" /dev/null
panic: runtime error: makeslice: len out of range

Exit code 2, also with -y (no plot).

Expected

The automatic bin count is at least 1.

watch -f and bam -f: a bad field name exits 1 with no [ERRO] tag

$ seqkit watch -f foo q.fq
Invalid field: foo
$ echo $?
1

$ seqkit bam -f foo x.bam > out.txt
Invalid field: foo
The valid fields are:
$ echo $?
1
$ head -2 out.txt                          # the field list goes to stdout
Read
Ref

All other option errors give [ERRO] and exit 255.

Expected

[ERRO] Invalid field: foo, exit 255, and the field list on stderr.

bam: a mapped record with no NM tag panics

What happens

The NM tag is optional in SAM, but seqkit bam x.bam (the default table)
panics at the first mapped record that has no NM tag. The output is cut.
-f Acc, the top mode and the toolbox do the same.

$ seqkit bam x.bam
Read	Ref	Pos	EndPos	MapQual	Acc	...
r1	chr1	0	10	60	100	...
panic: no NM tag
$ echo $?
2

$ seqkit bam -T '{AccStats: {Tsv: "-"}, Sink: True}' x.bam
panic: No NM tag in the BAM record!
Expected

An error that names the read, exit 255. Or the accuracy fields are computed
from MD/CIGAR, or left empty for that record.

bam -?: a negative value panics

$ seqkit bam -f MapQual -@ top.bam -? -1 -Q x.bam
panic: runtime error: makeslice: len out of range

Exit code 2.

Expected

An error such as value of flag --top-size should not be negative.

bam -x: the field table mode and -s pass no records (exit 0)

$ seqkit bam -x -f Read,MapQual z.bam > pass.bam
$ echo $?
0
$ samtools view -c pass.bam
[W::bam_hdr_read] EOF marker is absent. The input is probably truncated
0

$ seqkit bam -x -s z.bam | wc -c
0

With one field, -x passes the records.

Expected

pass.bam holds the 2 input records. With -s, the records pass or an error
says that -x and -s cannot be used together.

bam -T: an input that is not BAM panics

$ seqkit bam -T '{AccStats: {Tsv: "-"}, Sink: True}' notbam.bam
panic: runtime error: invalid memory address or nil pointer dereference
$ seqkit bam -s notbam.bam
[ERRO] gzip: invalid header
Expected

The same [ERRO] gzip: invalid header as the other modes, exit 255.

bam -@: no top file, no message, exit 0

With no -f, with two fields, or with a text field such as Ref, the file of
-@ is not written and nothing says why.

$ seqkit bam -f Ref -@ top.bam -? 3 -Q z.bam > /dev/null; echo $?
0
$ ls top.bam
ls: cannot access 'top.bam': No such file or directory
Expected

An error such as --top-bam requires a single numeric --field.

bam -s: one bad file removes the lines of the good files

$ cp z.bam w.bam
$ seqkit bam -s z.bam w.bam
PrimAlnPerc	MultimapPerc	PrimAln	...	File
100.00	0.00	2	...	z.bam
100.00	0.00	2	...	w.bam
$ seqkit bam -s z.bam notbam.bam w.bam
[ERRO] gzip: invalid header
$ echo $?
255

$ cat z.bam | seqkit bam -s - -
[ERRO] EOF
Expected

The header and the line for z.bam, then the error. (stats has the same
kind of problem, #599.)

bam -T Dump: an unknown field name is dropped with no message

$ cat dump.yml
Dump:
  Tsv: "-"
  Fields: ["Read","Foo"]
Sink: True
$ seqkit bam -T '{Yaml: "dump.yml"}' z.bam
Read
r1
r2
$ echo $?
0
Expected

An error such as Dump: unknown field: Foo.

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.