Debug fasta and fastq writer when the first sequence is hudge

Former-commit-id: d208ff838abb7e19e117067f6243298492d60f14
This commit is contained in:
Eric Coissac
2024-06-26 18:39:42 +02:00
parent 1835cb2cf3
commit e40d0bfbe7
7 changed files with 78 additions and 17 deletions

View File

@ -52,14 +52,24 @@ func FormatFastqBatch(batch obiiter.BioSequenceBatch,
formater FormatHeader, skipEmpty bool) []byte {
var bs bytes.Buffer
for i, seq := range batch.Slice() {
lt := 0
for _, seq := range batch.Slice() {
lt += seq.Len()
}
// Iterate over each sequence in the batch
first := true
for _, seq := range batch.Slice() {
if seq.Len() > 0 {
_formatFastq(&bs, seq, formater)
if i == 0 {
bs.Grow(len(bs.Bytes()) * len(batch.Slice()) * 5 / 4)
if first {
bs.Grow(lt + (len(bs.Bytes())-seq.Len())*batch.Len()*5/4)
first = false
}
} else {
if skipEmpty {
log.Warnf("Sequence %s is empty and skiped in output", seq.Id())