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

@@ -6,16 +6,16 @@ import (
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
)
// KmerSetGroup représente un vecteur de KmerSet
// Utilisé pour gérer plusieurs ensembles de k-mers (par exemple, par niveau de fréquence)
// KmerSetGroup represents a vector of KmerSet
// Used to manage multiple k-mer sets (for example, by frequency level)
type KmerSetGroup struct {
id string // Identifiant unique du KmerSetGroup
k int // Taille des k-mers (immutable)
sets []*KmerSet // Vecteur de KmerSet
Metadata map[string]interface{} // Métadonnées du groupe (pas des sets individuels)
id string // Unique identifier of the KmerSetGroup
k int // Size of k-mers (immutable)
sets []*KmerSet // Vector of KmerSet
Metadata map[string]interface{} // Group metadata (not individual sets)
}
// NewKmerSetGroup crée un nouveau groupe de n KmerSets
// NewKmerSetGroup creates a new group of n KmerSets
func NewKmerSetGroup(k int, n int) *KmerSetGroup {
if n < 1 {
panic("KmerSetGroup size must be >= 1")
@@ -33,18 +33,18 @@ func NewKmerSetGroup(k int, n int) *KmerSetGroup {
}
}
// K retourne la taille des k-mers (immutable)
// K returns the size of k-mers (immutable)
func (ksg *KmerSetGroup) K() int {
return ksg.k
}
// Size retourne le nombre de KmerSet dans le groupe
// Size returns the number of KmerSet in the group
func (ksg *KmerSetGroup) Size() int {
return len(ksg.sets)
}
// Get retourne le KmerSet à l'index donné
// Retourne nil si l'index est invalide
// Get returns the KmerSet at the given index
// Returns nil if the index is invalid
func (ksg *KmerSetGroup) Get(index int) *KmerSet {
if index < 0 || index >= len(ksg.sets) {
return nil
@@ -52,8 +52,8 @@ func (ksg *KmerSetGroup) Get(index int) *KmerSet {
return ksg.sets[index]
}
// Set remplace le KmerSet à l'index donné
// Panique si l'index est invalide ou si le k ne correspond pas
// Set replaces the KmerSet at the given index
// Panics if the index is invalid or if k does not match
func (ksg *KmerSetGroup) Set(index int, ks *KmerSet) {
if index < 0 || index >= len(ksg.sets) {
panic(fmt.Sprintf("Index out of bounds: %d (size: %d)", index, len(ksg.sets)))
@@ -64,16 +64,16 @@ func (ksg *KmerSetGroup) Set(index int, ks *KmerSet) {
ksg.sets[index] = ks
}
// Len retourne le nombre de k-mers dans un KmerSet spécifique
// Sans argument: retourne le nombre de k-mers dans le dernier KmerSet
// Avec argument index: retourne le nombre de k-mers dans le KmerSet à cet index
// Len returns the number of k-mers in a specific KmerSet
// Without argument: returns the number of k-mers in the last KmerSet
// With argument index: returns the number of k-mers in the KmerSet at this index
func (ksg *KmerSetGroup) Len(index ...int) uint64 {
if len(index) == 0 {
// Sans argument: dernier KmerSet
// Without argument: last KmerSet
return ksg.sets[len(ksg.sets)-1].Len()
}
// Avec argument: KmerSet spécifique
// With argument: specific KmerSet
idx := index[0]
if idx < 0 || idx >= len(ksg.sets) {
return 0
@@ -81,7 +81,7 @@ func (ksg *KmerSetGroup) Len(index ...int) uint64 {
return ksg.sets[idx].Len()
}
// MemoryUsage retourne l'utilisation mémoire totale en bytes
// MemoryUsage returns the total memory usage in bytes
func (ksg *KmerSetGroup) MemoryUsage() uint64 {
total := uint64(0)
for _, ks := range ksg.sets {
@@ -90,21 +90,21 @@ func (ksg *KmerSetGroup) MemoryUsage() uint64 {
return total
}
// Clear vide tous les KmerSet du groupe
// Clear empties all KmerSet in the group
func (ksg *KmerSetGroup) Clear() {
for _, ks := range ksg.sets {
ks.Clear()
}
}
// Copy crée une copie complète du groupe (cohérent avec BioSequence.Copy)
// Copy creates a complete copy of the group (consistent with BioSequence.Copy)
func (ksg *KmerSetGroup) Copy() *KmerSetGroup {
copiedSets := make([]*KmerSet, len(ksg.sets))
for i, ks := range ksg.sets {
copiedSets[i] = ks.Copy() // Copy chaque KmerSet avec ses métadonnées
copiedSets[i] = ks.Copy() // Copy each KmerSet with its metadata
}
// Copier les métadonnées du groupe
// Copy group metadata
groupMetadata := make(map[string]interface{}, len(ksg.Metadata))
for k, v := range ksg.Metadata {
groupMetadata[k] = v
@@ -118,17 +118,17 @@ func (ksg *KmerSetGroup) Copy() *KmerSetGroup {
}
}
// Id retourne l'identifiant du KmerSetGroup (cohérent avec BioSequence.Id)
// Id returns the identifier of the KmerSetGroup (consistent with BioSequence.Id)
func (ksg *KmerSetGroup) Id() string {
return ksg.id
}
// SetId définit l'identifiant du KmerSetGroup (cohérent avec BioSequence.SetId)
// SetId sets the identifier of the KmerSetGroup (consistent with BioSequence.SetId)
func (ksg *KmerSetGroup) SetId(id string) {
ksg.id = id
}
// AddSequence ajoute tous les k-mers d'une séquence à un KmerSet spécifique
// AddSequence adds all k-mers from a sequence to a specific KmerSet
func (ksg *KmerSetGroup) AddSequence(seq *obiseq.BioSequence, index int) {
if index < 0 || index >= len(ksg.sets) {
panic(fmt.Sprintf("Index out of bounds: %d (size: %d)", index, len(ksg.sets)))
@@ -136,7 +136,7 @@ func (ksg *KmerSetGroup) AddSequence(seq *obiseq.BioSequence, index int) {
ksg.sets[index].AddSequence(seq)
}
// AddSequences ajoute tous les k-mers de plusieurs séquences à un KmerSet spécifique
// AddSequences adds all k-mers from multiple sequences to a specific KmerSet
func (ksg *KmerSetGroup) AddSequences(sequences *obiseq.BioSequenceSlice, index int) {
if index < 0 || index >= len(ksg.sets) {
panic(fmt.Sprintf("Index out of bounds: %d (size: %d)", index, len(ksg.sets)))
@@ -144,8 +144,8 @@ func (ksg *KmerSetGroup) AddSequences(sequences *obiseq.BioSequenceSlice, index
ksg.sets[index].AddSequences(sequences)
}
// Union retourne l'union de tous les KmerSet du groupe
// Optimisation: part du plus grand ensemble pour minimiser les opérations
// Union returns the union of all KmerSet in the group
// Optimization: starts from the largest set to minimize operations
func (ksg *KmerSetGroup) Union() *KmerSet {
if len(ksg.sets) == 0 {
return NewKmerSet(ksg.k)
@@ -155,7 +155,7 @@ func (ksg *KmerSetGroup) Union() *KmerSet {
return ksg.sets[0].Copy()
}
// Trouver l'index du plus grand ensemble (celui avec le plus de k-mers)
// Find the index of the largest set (the one with the most k-mers)
maxIdx := 0
maxCard := ksg.sets[0].Len()
for i := 1; i < len(ksg.sets); i++ {
@@ -166,7 +166,7 @@ func (ksg *KmerSetGroup) Union() *KmerSet {
}
}
// Copier le plus grand ensemble et faire les unions in-place
// Copy the largest set and perform unions in-place
result := ksg.sets[maxIdx].bitmap.Clone()
for i := 0; i < len(ksg.sets); i++ {
if i != maxIdx {
@@ -177,8 +177,8 @@ func (ksg *KmerSetGroup) Union() *KmerSet {
return NewKmerSetFromBitmap(ksg.k, result)
}
// Intersect retourne l'intersection de tous les KmerSet du groupe
// Optimisation: part du plus petit ensemble pour minimiser les opérations
// Intersect returns the intersection of all KmerSet in the group
// Optimization: starts from the smallest set to minimize operations
func (ksg *KmerSetGroup) Intersect() *KmerSet {
if len(ksg.sets) == 0 {
return NewKmerSet(ksg.k)
@@ -188,7 +188,7 @@ func (ksg *KmerSetGroup) Intersect() *KmerSet {
return ksg.sets[0].Copy()
}
// Trouver l'index du plus petit ensemble (celui avec le moins de k-mers)
// Find the index of the smallest set (the one with the fewest k-mers)
minIdx := 0
minCard := ksg.sets[0].Len()
for i := 1; i < len(ksg.sets); i++ {
@@ -199,7 +199,7 @@ func (ksg *KmerSetGroup) Intersect() *KmerSet {
}
}
// Copier le plus petit ensemble et faire les intersections in-place
// Copy the smallest set and perform intersections in-place
result := ksg.sets[minIdx].bitmap.Clone()
for i := 0; i < len(ksg.sets); i++ {
if i != minIdx {
@@ -210,18 +210,18 @@ func (ksg *KmerSetGroup) Intersect() *KmerSet {
return NewKmerSetFromBitmap(ksg.k, result)
}
// Stats retourne des statistiques pour chaque KmerSet du groupe
// Stats returns statistics for each KmerSet in the group
type KmerSetGroupStats struct {
K int
Size int // Nombre de KmerSet
TotalBytes uint64 // Mémoire totale utilisée
Sets []KmerSetStats // Stats de chaque KmerSet
Size int // Number of KmerSet
TotalBytes uint64 // Total memory used
Sets []KmerSetStats // Stats of each KmerSet
}
type KmerSetStats struct {
Index int // Index du KmerSet dans le groupe
Len uint64 // Nombre de k-mers
SizeBytes uint64 // Taille en bytes
Index int // Index of the KmerSet in the group
Len uint64 // Number of k-mers
SizeBytes uint64 // Size in bytes
}
func (ksg *KmerSetGroup) Stats() KmerSetGroupStats {