mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
patch a bug in obiannotate
This commit is contained in:
@ -63,6 +63,11 @@ func (iterator IBioSequence) MakeIConditionalWorker(predicate obiseq.SequencePre
|
|||||||
//
|
//
|
||||||
// The function returns a new IBioSequence containing the modified slices.
|
// The function returns a new IBioSequence containing the modified slices.
|
||||||
func (iterator IBioSequence) MakeISliceWorker(worker obiseq.SeqSliceWorker, breakOnError bool, sizes ...int) IBioSequence {
|
func (iterator IBioSequence) MakeISliceWorker(worker obiseq.SeqSliceWorker, breakOnError bool, sizes ...int) IBioSequence {
|
||||||
|
|
||||||
|
if worker == nil {
|
||||||
|
return iterator
|
||||||
|
}
|
||||||
|
|
||||||
nworkers := obidefault.ParallelWorkers()
|
nworkers := obidefault.ParallelWorkers()
|
||||||
|
|
||||||
if len(sizes) > 0 {
|
if len(sizes) > 0 {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
// corresponds to the last commit, and not the one when the file will be
|
// corresponds to the last commit, and not the one when the file will be
|
||||||
// commited
|
// commited
|
||||||
|
|
||||||
var _Commit = "52d5f6f"
|
var _Commit = "50d11ce"
|
||||||
var _Version = "Release 4.4.0"
|
var _Version = "Release 4.4.0"
|
||||||
|
|
||||||
// Version returns the version of the obitools package.
|
// Version returns the version of the obitools package.
|
||||||
|
@ -133,6 +133,34 @@ func SeqToSliceWorker(worker SeqWorker,
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SeqToSliceFilterOnWorker(condition SequencePredicate,
|
||||||
|
breakOnError bool) SeqSliceWorker {
|
||||||
|
|
||||||
|
if condition == nil {
|
||||||
|
return func(slice BioSequenceSlice) (BioSequenceSlice, error) {
|
||||||
|
return slice, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f := func(input BioSequenceSlice) (BioSequenceSlice, error) {
|
||||||
|
output := MakeBioSequenceSlice(len(input))
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
|
||||||
|
for _, s := range input {
|
||||||
|
if condition(s) {
|
||||||
|
output[i] = s
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output[0:i], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return f
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// SeqToSliceConditionalWorker creates a new SeqSliceWorker that processes each sequence in a slice based on a condition. It takes a SequencePredicate and a worker function as arguments. The worker function is only applied to sequences that satisfy the condition.
|
// SeqToSliceConditionalWorker creates a new SeqSliceWorker that processes each sequence in a slice based on a condition. It takes a SequencePredicate and a worker function as arguments. The worker function is only applied to sequences that satisfy the condition.
|
||||||
// If `condition` is nil, this function just behaves like SeqToSliceWorker with the provided `worker`.
|
// If `condition` is nil, this function just behaves like SeqToSliceWorker with the provided `worker`.
|
||||||
// If `breakOnError` is true, the pipeline will stop and return an error if any sequence processing fails. Otherwise, it will log a warning message for each failed sequence.
|
// If `breakOnError` is true, the pipeline will stop and return an error if any sequence processing fails. Otherwise, it will log a warning message for each failed sequence.
|
||||||
@ -153,6 +181,10 @@ func SeqToSliceConditionalWorker(
|
|||||||
return SeqToSliceWorker(worker, breakOnError)
|
return SeqToSliceWorker(worker, breakOnError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if worker == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
f := func(input BioSequenceSlice) (BioSequenceSlice, error) {
|
f := func(input BioSequenceSlice) (BioSequenceSlice, error) {
|
||||||
output := MakeBioSequenceSlice(len(input))
|
output := MakeBioSequenceSlice(len(input))
|
||||||
|
|
||||||
@ -180,6 +212,9 @@ func SeqToSliceConditionalWorker(
|
|||||||
s.Id(), err)
|
s.Id(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
output[i] = s
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user