docs: translate comments to English

This commit translates all French comments in the kmer filtering and set management code to English, improving code readability and maintainability for international collaborators.
This commit is contained in:
Eric Coissac
2026-02-05 16:35:38 +01:00
parent 12ca62b06a
commit a43e6258be
5 changed files with 122 additions and 122 deletions

View File

@@ -7,16 +7,16 @@ import (
"github.com/RoaringBitmap/roaring/roaring64"
)
// KmerSet encapsule un ensemble de k-mers stockés dans un Roaring Bitmap
// Fournit des méthodes utilitaires pour manipuler des ensembles de k-mers
// KmerSet wraps a set of k-mers stored in a Roaring Bitmap
// Provides utility methods for manipulating k-mer sets
type KmerSet struct {
id string // Identifiant unique du KmerSet
k int // Taille des k-mers (immutable)
bitmap *roaring64.Bitmap // Bitmap contenant les k-mers
Metadata map[string]interface{} // Métadonnées utilisateur (clé=valeur atomique)
id string // Unique identifier of the KmerSet
k int // Size of k-mers (immutable)
bitmap *roaring64.Bitmap // Bitmap containing the k-mers
Metadata map[string]interface{} // User metadata (key=atomic value)
}
// NewKmerSet crée un nouveau KmerSet vide
// NewKmerSet creates a new empty KmerSet
func NewKmerSet(k int) *KmerSet {
return &KmerSet{
k: k,
@@ -25,7 +25,7 @@ func NewKmerSet(k int) *KmerSet {
}
}
// NewKmerSetFromBitmap crée un KmerSet à partir d'un bitmap existant
// NewKmerSetFromBitmap creates a KmerSet from an existing bitmap
func NewKmerSetFromBitmap(k int, bitmap *roaring64.Bitmap) *KmerSet {
return &KmerSet{
k: k,
@@ -34,40 +34,40 @@ func NewKmerSetFromBitmap(k int, bitmap *roaring64.Bitmap) *KmerSet {
}
}
// K retourne la taille des k-mers (immutable)
// K returns the size of k-mers (immutable)
func (ks *KmerSet) K() int {
return ks.k
}
// AddKmerCode ajoute un k-mer encodé à l'ensemble
// AddKmerCode adds an encoded k-mer to the set
func (ks *KmerSet) AddKmerCode(kmer uint64) {
ks.bitmap.Add(kmer)
}
// AddCanonicalKmerCode ajoute un k-mer encodé canonique à l'ensemble
// AddCanonicalKmerCode adds an encoded canonical k-mer to the set
func (ks *KmerSet) AddCanonicalKmerCode(kmer uint64) {
canonical := CanonicalKmer(kmer, ks.k)
ks.bitmap.Add(canonical)
}
// AddKmer ajoute un k-mer à l'ensemble en encodant la séquence
// La séquence doit avoir exactement k nucléotides
// Zero-allocation: encode directement sans créer de slice intermédiaire
// AddKmer adds a k-mer to the set by encoding the sequence
// The sequence must have exactly k nucleotides
// Zero-allocation: encodes directly without creating an intermediate slice
func (ks *KmerSet) AddKmer(seq []byte) {
kmer := EncodeKmer(seq, ks.k)
ks.bitmap.Add(kmer)
}
// AddCanonicalKmer ajoute un k-mer canonique à l'ensemble en encodant la séquence
// La séquence doit avoir exactement k nucléotides
// Zero-allocation: encode directement en forme canonique sans créer de slice intermédiaire
// AddCanonicalKmer adds a canonical k-mer to the set by encoding the sequence
// The sequence must have exactly k nucleotides
// Zero-allocation: encodes directly in canonical form without creating an intermediate slice
func (ks *KmerSet) AddCanonicalKmer(seq []byte) {
canonical := EncodeCanonicalKmer(seq, ks.k)
ks.bitmap.Add(canonical)
}
// AddSequence ajoute tous les k-mers d'une séquence à l'ensemble
// Utilise un itérateur pour éviter l'allocation d'un vecteur intermédiaire
// AddSequence adds all k-mers from a sequence to the set
// Uses an iterator to avoid allocating an intermediate vector
func (ks *KmerSet) AddSequence(seq *obiseq.BioSequence) {
rawSeq := seq.Sequence()
for canonical := range IterCanonicalKmers(rawSeq, ks.k) {
@@ -75,36 +75,36 @@ func (ks *KmerSet) AddSequence(seq *obiseq.BioSequence) {
}
}
// AddSequences ajoute tous les k-mers de plusieurs séquences en batch
// AddSequences adds all k-mers from multiple sequences in batch
func (ks *KmerSet) AddSequences(sequences *obiseq.BioSequenceSlice) {
for _, seq := range *sequences {
ks.AddSequence(seq)
}
}
// Contains vérifie si un k-mer est dans l'ensemble
// Contains checks if a k-mer is in the set
func (ks *KmerSet) Contains(kmer uint64) bool {
return ks.bitmap.Contains(kmer)
}
// Len retourne le nombre de k-mers dans l'ensemble
// Len returns the number of k-mers in the set
func (ks *KmerSet) Len() uint64 {
return ks.bitmap.GetCardinality()
}
// MemoryUsage retourne l'utilisation mémoire en bytes
// MemoryUsage returns memory usage in bytes
func (ks *KmerSet) MemoryUsage() uint64 {
return ks.bitmap.GetSizeInBytes()
}
// Clear vide l'ensemble
// Clear empties the set
func (ks *KmerSet) Clear() {
ks.bitmap.Clear()
}
// Copy crée une copie de l'ensemble (cohérent avec BioSequence.Copy)
// Copy creates a copy of the set (consistent with BioSequence.Copy)
func (ks *KmerSet) Copy() *KmerSet {
// Copier les métadonnées
// Copy metadata
metadata := make(map[string]interface{}, len(ks.Metadata))
for k, v := range ks.Metadata {
metadata[k] = v
@@ -118,17 +118,17 @@ func (ks *KmerSet) Copy() *KmerSet {
}
}
// Id retourne l'identifiant du KmerSet (cohérent avec BioSequence.Id)
// Id returns the identifier of the KmerSet (consistent with BioSequence.Id)
func (ks *KmerSet) Id() string {
return ks.id
}
// SetId définit l'identifiant du KmerSet (cohérent avec BioSequence.SetId)
// SetId sets the identifier of the KmerSet (consistent with BioSequence.SetId)
func (ks *KmerSet) SetId(id string) {
ks.id = id
}
// Union retourne l'union de cet ensemble avec un autre
// Union returns the union of this set with another
func (ks *KmerSet) Union(other *KmerSet) *KmerSet {
if ks.k != other.k {
panic(fmt.Sprintf("Cannot union KmerSets with different k values: %d vs %d", ks.k, other.k))
@@ -138,7 +138,7 @@ func (ks *KmerSet) Union(other *KmerSet) *KmerSet {
return NewKmerSetFromBitmap(ks.k, result)
}
// Intersect retourne l'intersection de cet ensemble avec un autre
// Intersect returns the intersection of this set with another
func (ks *KmerSet) Intersect(other *KmerSet) *KmerSet {
if ks.k != other.k {
panic(fmt.Sprintf("Cannot intersect KmerSets with different k values: %d vs %d", ks.k, other.k))
@@ -148,7 +148,7 @@ func (ks *KmerSet) Intersect(other *KmerSet) *KmerSet {
return NewKmerSetFromBitmap(ks.k, result)
}
// Difference retourne la différence de cet ensemble avec un autre (this - other)
// Difference returns the difference of this set with another (this - other)
func (ks *KmerSet) Difference(other *KmerSet) *KmerSet {
if ks.k != other.k {
panic(fmt.Sprintf("Cannot subtract KmerSets with different k values: %d vs %d", ks.k, other.k))
@@ -158,12 +158,12 @@ func (ks *KmerSet) Difference(other *KmerSet) *KmerSet {
return NewKmerSetFromBitmap(ks.k, result)
}
// Iterator retourne un itérateur sur tous les k-mers de l'ensemble
// Iterator returns an iterator over all k-mers in the set
func (ks *KmerSet) Iterator() roaring64.IntIterable64 {
return ks.bitmap.Iterator()
}
// Bitmap retourne le bitmap sous-jacent (pour compatibilité)
// Bitmap returns the underlying bitmap (for compatibility)
func (ks *KmerSet) Bitmap() *roaring64.Bitmap {
return ks.bitmap
}