mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Optimize memory for readers and writers
This commit is contained in:
@ -464,6 +464,39 @@ func (iterator IBioSequence) Rebatch(size int) IBioSequence {
|
||||
return newIter
|
||||
}
|
||||
|
||||
func (iterator IBioSequence) FilterEmpty() IBioSequence {
|
||||
|
||||
newIter := MakeIBioSequence()
|
||||
|
||||
newIter.Add(1)
|
||||
|
||||
go func() {
|
||||
newIter.WaitAndClose()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
order := 0
|
||||
iterator = iterator.SortBatches()
|
||||
|
||||
for iterator.Next() {
|
||||
seqs := iterator.Get()
|
||||
lc := seqs.Len()
|
||||
|
||||
if lc > 0 {
|
||||
newIter.Push(seqs.Reorder(order))
|
||||
order++
|
||||
}
|
||||
}
|
||||
|
||||
newIter.Done()
|
||||
}()
|
||||
|
||||
if iterator.IsPaired() {
|
||||
newIter.MarkAsPaired()
|
||||
}
|
||||
|
||||
return newIter
|
||||
}
|
||||
func (iterator IBioSequence) Recycle() {
|
||||
|
||||
log.Debugln("Start recycling of Bioseq objects")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package obiiter
|
||||
|
||||
import (
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -40,8 +41,8 @@ func (iter IBioSequence) PairTo(p IBioSequence) IBioSequence {
|
||||
|
||||
newIter := MakeIBioSequence()
|
||||
|
||||
iter = iter.SortBatches()
|
||||
p = p.SortBatches()
|
||||
iter = iter.SortBatches().Rebatch(obioptions.CLIBatchSize())
|
||||
p = p.SortBatches().Rebatch(obioptions.CLIBatchSize())
|
||||
|
||||
newIter.Add(1)
|
||||
|
||||
|
Reference in New Issue
Block a user