Make the --no-progressbar option effective on graph building progress too.

Former-commit-id: 3fabecfc9de69ad406d6840c8f821c16eebaef46
This commit is contained in:
Eric Coissac
2024-04-22 12:01:43 +02:00
parent df74b2b2bd
commit 8f08959ebb

View File

@ -7,6 +7,7 @@ import (
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiiter"
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitools/obiconvert"
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiutils"
"github.com/schollz/progressbar/v3"
log "github.com/sirupsen/logrus"
@ -300,36 +301,47 @@ func CLIOBIClean(itertator obiiter.IBioSequence) obiiter.IBioSequence {
obioptions.CLIParallelWorkers())
if RatioMax() < 1.0 {
bar := (*progressbar.ProgressBar)(nil)
if obiconvert.CLIProgressBar() {
pbopt := make([]progressbar.Option, 0, 5)
pbopt = append(pbopt,
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetWidth(15),
progressbar.OptionShowIts(),
progressbar.OptionSetPredictTime(true),
progressbar.OptionSetDescription("[Filter graph on abundance ratio]"),
)
bar = progressbar.NewOptions(len(samples), pbopt...)
}
for _, seqs := range samples {
FilterGraphOnRatio(seqs, RatioMax())
if bar != nil {
bar.Add(1)
}
}
}
Mutation(samples)
bar := (*progressbar.ProgressBar)(nil)
if obiconvert.CLIProgressBar() {
pbopt := make([]progressbar.Option, 0, 5)
pbopt = append(pbopt,
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetWidth(15),
progressbar.OptionShowIts(),
progressbar.OptionSetPredictTime(true),
progressbar.OptionSetDescription("[Filter graph on abundance ratio]"),
progressbar.OptionSetDescription("[Annotate sequence status]"),
)
bar := progressbar.NewOptions(len(samples), pbopt...)
for _, seqs := range samples {
FilterGraphOnRatio(seqs, RatioMax())
bar.Add(1)
}
bar = progressbar.NewOptions(len(samples), pbopt...)
}
Mutation(samples)
pbopt := make([]progressbar.Option, 0, 5)
pbopt = append(pbopt,
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetWidth(15),
progressbar.OptionShowIts(),
progressbar.OptionSetPredictTime(true),
progressbar.OptionSetDescription("[Annotate sequence status]"),
)
bar := progressbar.NewOptions(len(samples), pbopt...)
for name, seqs := range samples {
for _, pcr := range *seqs {
obistatus := Status(pcr.Sequence)
@ -338,7 +350,10 @@ func CLIOBIClean(itertator obiiter.IBioSequence) obiiter.IBioSequence {
obiweight := Weight(pcr.Sequence)
obiweight[name] = pcr.Weight
}
bar.Add(1)
if bar != nil {
bar.Add(1)
}
}
if SaveGraphToFiles() {