mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 00:30:27 +00:00
implementation de obilowmask
This commit is contained in:
23
pkg/obiseq/kmers.go
Normal file
23
pkg/obiseq/kmers.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package obiseq
|
||||
|
||||
import "iter"
|
||||
|
||||
func (seq *BioSequence) Kmers(k int) iter.Seq[[]byte] {
|
||||
return func(yield func([]byte) bool) {
|
||||
// Gérer les cas où k est invalide ou la séquence trop courte
|
||||
if k <= 0 || k > len(seq.sequence) {
|
||||
return
|
||||
}
|
||||
|
||||
// Itérer sur tous les k-mers possibles
|
||||
for i := 0; i <= len(seq.sequence)-k; i++ {
|
||||
// Extraire le k-mer actuel
|
||||
kmer := seq.sequence[i : i+k]
|
||||
|
||||
// Passer au consommateur et arrêter si demandé
|
||||
if !yield(kmer) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user