mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Add a reverse complement worker
This commit is contained in:
@ -196,3 +196,11 @@ func SliceWorkerPipe(worker SeqSliceWorker, sizes ...int) Pipeable {
|
|||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReverseComplementWorker(inplace bool) SeqWorker {
|
||||||
|
f := func(input *obiseq.BioSequence) *obiseq.BioSequence {
|
||||||
|
return input.ReverseComplement(inplace)
|
||||||
|
}
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package obiseq
|
package obiseq
|
||||||
|
|
||||||
// ".ABCDEFGHIJKLMNOPQRSTUVWXYZ#![]"
|
// ".ABCDEFGHIJKLMNOPQRSTUVWXYZ#![]"
|
||||||
var __revcmp_dna__ = []byte(".TVGHEFCDIJMLKNOPQYSAABWXRZ#!][")
|
var __revcmp_dna__ = []byte(".TVGHEFCDIJMLKNOPQYSAABWXRZ#!][")
|
||||||
|
|
||||||
// Reverse complements a DNA sequence.
|
// Reverse complements a DNA sequence.
|
||||||
@ -20,5 +20,13 @@ func (sequence *BioSequence) ReverseComplement(inplace bool) *BioSequence {
|
|||||||
j++
|
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
|
return sequence
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user