2022-02-18 22:53:09 +01:00
|
|
|
package obiseq
|
|
|
|
|
2022-02-21 19:00:23 +01:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/schollz/progressbar/v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
|
2022-02-18 22:53:09 +01:00
|
|
|
newIter := MakeIBioSequenceBatch()
|
2022-02-21 19:00:23 +01:00
|
|
|
|
|
|
|
newIter.Add(1)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
newIter.WaitAndClose()
|
|
|
|
}()
|
|
|
|
|
|
|
|
bar := progressbar.NewOptions(
|
|
|
|
-1,
|
|
|
|
progressbar.OptionSetWriter(os.Stderr),
|
|
|
|
progressbar.OptionSetWidth(15),
|
|
|
|
progressbar.OptionShowCount(),
|
|
|
|
progressbar.OptionShowIts(),
|
|
|
|
progressbar.OptionSetDescription("[Sequence Processing]"))
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
for iterator.Next() {
|
|
|
|
batch := iterator.Get()
|
|
|
|
l := batch.Length()
|
|
|
|
newIter.Push(batch)
|
|
|
|
bar.Add(l)
|
|
|
|
}
|
|
|
|
|
|
|
|
newIter.Done()
|
|
|
|
}()
|
|
|
|
|
2022-02-18 22:53:09 +01:00
|
|
|
return newIter
|
|
|
|
}
|