diff --git a/pkg/obioptions/version.go b/pkg/obioptions/version.go index 4bb7230..51e3ef7 100644 --- a/pkg/obioptions/version.go +++ b/pkg/obioptions/version.go @@ -8,7 +8,7 @@ import ( // corresponds to the last commit, and not the one when the file will be // commited -var _Commit = "8a2bb1f" +var _Commit = "9965370" var _Version = "Release 4.4.0" // Version returns the version of the obitools package. diff --git a/pkg/obiseq/merge.go b/pkg/obiseq/merge.go index 5d2bcc0..5fb9d67 100644 --- a/pkg/obiseq/merge.go +++ b/pkg/obiseq/merge.go @@ -7,6 +7,7 @@ import ( "strings" "sync" + "git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiutils" "github.com/goccy/go-json" log "github.com/sirupsen/logrus" @@ -109,6 +110,24 @@ func (sov *StatsOnValues) Map() map[string]int { return sov.counts } +func (sov *StatsOnValues) Max() int { + data, err := obiutils.Max(sov.counts) + if err != nil { + return -1 + } + + return data.(int) +} + +func (sov *StatsOnValues) Min() int { + data, err := obiutils.Min(sov.counts) + if err != nil { + return -1 + } + + return data.(int) +} + func (sov *StatsOnValues) Set(key string, value int) { if sov == nil { return diff --git a/pkg/obiutils/minmax.go b/pkg/obiutils/minmax.go index f6b0e40..b01dfc1 100644 --- a/pkg/obiutils/minmax.go +++ b/pkg/obiutils/minmax.go @@ -78,6 +78,12 @@ func MinMap[K comparable, T constraints.Ordered](values map[K]T) (K, T, error) { // Returns an error if the container is empty or the type is unsupported. func Min(data interface{}) (interface{}, error) { v := reflect.ValueOf(data) + method := v.MethodByName("Min") + if method.IsValid() { + result := method.Call(nil)[0].Interface() + return result, nil + } + switch v.Kind() { case reflect.Slice, reflect.Array: if v.Len() == 0 { @@ -103,6 +109,13 @@ func Min(data interface{}) (interface{}, error) { // Returns an error if the container is empty or the type is unsupported. func Max(data interface{}) (interface{}, error) { v := reflect.ValueOf(data) + + method := v.MethodByName("Max") + if method.IsValid() { + result := method.Call(nil)[0].Interface() + return result, nil + } + switch v.Kind() { case reflect.Slice, reflect.Array: if v.Len() == 0 {