Patch a bug in comparison of attibutes during sequence annotation merging

This commit is contained in:
2022-09-08 07:50:17 +02:00
parent 6b8f4490cf
commit 448f5f83fa

View File

@ -2,6 +2,7 @@ package obiseq
import (
"fmt"
"reflect"
"strings"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
@ -154,7 +155,19 @@ func (sequence *BioSequence) Merge(tomerge *BioSequence, na string, inplace bool
for k, va := range annotations {
if !strings.HasPrefix(k, "merged_") {
vm, ok := ma[k]
if !ok || vm != va {
if ok {
switch vm := vm.(type) {
case int, float64, string, bool:
if va != vm {
delete(annotations, k)
}
default:
if !reflect.DeepEqual(va, vm) {
delete(annotations, k)
}
}
} else {
delete(annotations, k)
}
}
@ -171,7 +184,9 @@ func (sequence *BioSequence) Merge(tomerge *BioSequence, na string, inplace bool
return sequence
}
/**
/*
*
Merges a set of sequence into a single sequence.
The function assumes that every sequence in the batch is