mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Patch an aligment bug on obipairing
This commit is contained in:
@ -5,6 +5,10 @@ type SeqAnnotator func(*BioSequence)
|
||||
type SeqWorker func(*BioSequence) *BioSequence
|
||||
type SeqSliceWorker func(BioSequenceSlice) BioSequenceSlice
|
||||
|
||||
func NilSeqWorker(seq *BioSequence) *BioSequence {
|
||||
return seq
|
||||
}
|
||||
|
||||
func AnnotatorToSeqWorker(function SeqAnnotator) SeqWorker {
|
||||
f := func(seq *BioSequence) *BioSequence {
|
||||
function(seq)
|
||||
@ -14,14 +18,57 @@ func AnnotatorToSeqWorker(function SeqAnnotator) SeqWorker {
|
||||
}
|
||||
|
||||
func SeqToSliceWorker(worker SeqWorker, inplace bool) SeqSliceWorker {
|
||||
f := func(input BioSequenceSlice) BioSequenceSlice {
|
||||
output := input
|
||||
if (! inplace) {
|
||||
output = MakeBioSequenceSlice()
|
||||
var f SeqSliceWorker
|
||||
|
||||
if worker == nil {
|
||||
if inplace {
|
||||
f = func(input BioSequenceSlice) BioSequenceSlice {
|
||||
return input
|
||||
}
|
||||
} else {
|
||||
f = func(input BioSequenceSlice) BioSequenceSlice {
|
||||
output := MakeBioSequenceSlice(len(input))
|
||||
copy(output,input)
|
||||
return output
|
||||
}
|
||||
}
|
||||
for i,s := range(input) {
|
||||
} else {
|
||||
f = func(input BioSequenceSlice) BioSequenceSlice {
|
||||
output := input
|
||||
if !inplace {
|
||||
output = MakeBioSequenceSlice(len(input))
|
||||
}
|
||||
for i, s := range input {
|
||||
output[i] = worker(s)
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func SeqToSliceConditionalWorker(worker SeqWorker,
|
||||
condition SequencePredicate,
|
||||
inplace bool) SeqSliceWorker {
|
||||
|
||||
if condition == nil {
|
||||
return SeqToSliceWorker(worker,inplace)
|
||||
}
|
||||
|
||||
f := func(input BioSequenceSlice) BioSequenceSlice {
|
||||
output := input
|
||||
if !inplace {
|
||||
output = MakeBioSequenceSlice(len(input))
|
||||
}
|
||||
for i, s := range input {
|
||||
if condition(s) {
|
||||
output[i] = worker(s)
|
||||
} else {
|
||||
output[i] = s
|
||||
}
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
@ -29,3 +76,18 @@ func SeqToSliceWorker(worker SeqWorker, inplace bool) SeqSliceWorker {
|
||||
return f
|
||||
}
|
||||
|
||||
func (worker SeqWorker) ChainWorkers(next SeqWorker) SeqWorker {
|
||||
if worker == nil {
|
||||
return next
|
||||
} else {
|
||||
if next == nil {
|
||||
return worker
|
||||
}
|
||||
}
|
||||
|
||||
f := func(seq *BioSequence) *BioSequence {
|
||||
return next(worker(seq))
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
Reference in New Issue
Block a user