Adds a first version of a new obidistribute command

This commit is contained in:
2022-02-14 00:01:01 +01:00
parent 1544bafde1
commit eb32620bb3
13 changed files with 567 additions and 36 deletions

View File

@@ -0,0 +1,48 @@
package obiformats
import (
"fmt"
"log"
"sync"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
)
type SequenceBatchWriterToFile func(iterator obiseq.IBioSequenceBatch,
filename string,
options ...WithOption) (obiseq.IBioSequenceBatch, error)
func WriterDispatcher(prototypename string,
dispatcher obiseq.IDistribute,
formater SequenceBatchWriterToFile,
options ...WithOption) {
jobDone := sync.WaitGroup{}
jobDone.Add(1)
go func() {
n := 0
for newflux := range dispatcher.News() {
data, _ := dispatcher.Outputs(newflux)
out, err := formater(data,
fmt.Sprintf(prototypename, newflux),
options...)
if err != nil {
log.Fatalf("cannot open the output file for key %s", newflux)
}
n++
if n > 1 {
jobDone.Add(1)
}
go func() {
out.Recycle()
jobDone.Done()
}()
}
}()
jobDone.Wait()
}

View File

@@ -122,10 +122,10 @@ func WriteFastqBatch(iterator obiseq.IBioSequenceBatch, file io.Writer, options
}
log.Println("Start of the fastq file writing")
go ff(iterator)
for i := 0; i < nwriters-1; i++ {
go ff(iterator.Split())
}
go ff(iterator)
next_to_send := 0
received := make(map[int]FileChunck, 100)