Add a reverse complement worker

This commit is contained in:
2022-10-05 09:41:59 +02:00
parent 935fc31982
commit d9c18ab0b5
2 changed files with 17 additions and 1 deletions

View File

@ -196,3 +196,11 @@ func SliceWorkerPipe(worker SeqSliceWorker, sizes ...int) Pipeable {
return f
}
func ReverseComplementWorker(inplace bool) SeqWorker {
f := func(input *obiseq.BioSequence) *obiseq.BioSequence {
return input.ReverseComplement(inplace)
}
return f
}

View File

@ -20,5 +20,13 @@ func (sequence *BioSequence) ReverseComplement(inplace bool) *BioSequence {
j++
}
if sequence.HasQualities() {
s := sequence.qualities
for i, j := sequence.Length()-1, 0; i >= j; i-- {
s[j], s[i] = s[i], s[j]
j++
}
}
return sequence
}