mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Some code refactoring, a new version of obiuniq more efficient in memory and a first make file allowing to build obitools
This commit is contained in:
46
pkg/obiiter/pipe.go
Normal file
46
pkg/obiiter/pipe.go
Normal file
@ -0,0 +1,46 @@
|
||||
package obiiter
|
||||
|
||||
|
||||
type Pipeable func(input IBioSequenceBatch) IBioSequenceBatch
|
||||
|
||||
func Pipeline(start Pipeable,parts ...Pipeable) Pipeable {
|
||||
p := func (input IBioSequenceBatch) IBioSequenceBatch {
|
||||
data := start(input)
|
||||
for _,part := range parts {
|
||||
data = part(data)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (input IBioSequenceBatch) Pipe(start Pipeable, parts ...Pipeable) IBioSequenceBatch {
|
||||
p := Pipeline(start,parts...)
|
||||
return p(input)
|
||||
}
|
||||
|
||||
|
||||
type Teeable func(input IBioSequenceBatch) (IBioSequenceBatch,IBioSequenceBatch)
|
||||
|
||||
func (input IBioSequenceBatch) CopyTee() (IBioSequenceBatch,IBioSequenceBatch) {
|
||||
first := MakeIBioSequenceBatch()
|
||||
second:= MakeIBioSequenceBatch()
|
||||
|
||||
first.Add(1)
|
||||
|
||||
go func() {
|
||||
first.WaitAndClose()
|
||||
second.Close()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for input.Next() {
|
||||
b:=input.Get()
|
||||
first.Push(b)
|
||||
second.Push(b)
|
||||
}
|
||||
}()
|
||||
|
||||
return first,second
|
||||
}
|
Reference in New Issue
Block a user