add the --skip-empty option

Former-commit-id: ec9cb0ecaf90a61bf9289cf4c089b5cc2fcb65a5
This commit is contained in:
2023-07-17 14:24:02 +02:00
parent b44fcfb2a0
commit be47ec909c
10 changed files with 65 additions and 12 deletions

View File

@@ -39,11 +39,20 @@ func FormatFastq(seq *obiseq.BioSequence, quality_shift int, formater FormatHead
}
func FormatFastqBatch(batch obiiter.BioSequenceBatch, quality_shift int,
formater FormatHeader) []byte {
formater FormatHeader, skipEmpty bool) []byte {
var bs bytes.Buffer
for _, seq := range batch.Slice() {
bs.WriteString(FormatFastq(seq, quality_shift, formater))
bs.WriteString("\n")
if seq.Len() > 0 {
bs.WriteString(FormatFastq(seq, quality_shift, formater))
bs.WriteString("\n")
} else {
if skipEmpty {
log.Warnf("Sequence %s is empty and skiped in output", seq.Id())
} else {
log.Fatalf("Sequence %s is empty", seq.Id())
}
}
}
return bs.Bytes()
}
@@ -90,7 +99,7 @@ func WriteFastq(iterator obiiter.IBioSequence,
for iterator.Next() {
batch := iterator.Get()
chunk := FileChunck{
FormatFastqBatch(batch, quality, header_format),
FormatFastqBatch(batch, quality, header_format, opt.SkipEmptySequence()),
batch.Order(),
}
chunkchan <- chunk