diff --git a/pkg/obioptions/version.go b/pkg/obioptions/version.go index 762836d..390efe2 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 = "add9d89" +var _Commit = "27fa984" var _Version = "Release 4.4.0" // Version returns the version of the obitools package. diff --git a/pkg/obitools/obisummary/obisummary.go b/pkg/obitools/obisummary/obisummary.go index 6e47afa..605bee5 100644 --- a/pkg/obitools/obisummary/obisummary.go +++ b/pkg/obitools/obisummary/obisummary.go @@ -139,7 +139,10 @@ func (data *DataSummary) Update(s *obiseq.BioSequence) *DataSummary { } for k, v := range s.Annotations() { + _, isSov := v.(*obiseq.StatsOnValues) switch { + case isSov: + plusOneUpdateIntMap(data.map_tags, k) case obiutils.IsAMap(v): plusOneUpdateIntMap(data.map_tags, k) case obiutils.IsASlice(v): diff --git a/pkg/obiutils/cast_interface.go b/pkg/obiutils/cast_interface.go index 7184f45..0218ffd 100644 --- a/pkg/obiutils/cast_interface.go +++ b/pkg/obiutils/cast_interface.go @@ -2,6 +2,7 @@ package obiutils import ( "fmt" + "maps" "reflect" "strconv" "strings" @@ -90,7 +91,21 @@ func InterfaceToBool(i interface{}) (val bool, err error) { // It returns a map[string]interface{} which is the converted map. If the input map is not of type map[string]interface{}, // it panics and logs an error message. func MapToMapInterface(m interface{}) map[string]interface{} { - if IsAMap(m) { + type hasMap interface { + Map() map[string]int + RLock() + RUnlock() + Len() int + } + + if v, ok := m.(hasMap); ok { + val := make(map[string]interface{}, v.Len()) + v.RLock() + defer v.RUnlock() + for k, v := range v.Map() { + val[k] = v + } + } else if IsAMap(m) { reflectMap := reflect.ValueOf(m) keys := reflectMap.MapKeys() val := make(map[string]interface{}, len(keys)) @@ -193,9 +208,19 @@ func InterfaceToFloat64(i interface{}) (val float64, err error) { func InterfaceToIntMap(i interface{}) (val map[string]int, err error) { err = nil + type hasMap interface { + Map() map[string]int + RLock() + RUnlock() + } + switch i := i.(type) { case map[string]int: val = i + case hasMap: + i.RLock() + defer i.RUnlock() + val = maps.Clone(i.Map()) case map[string]interface{}: val = make(map[string]int, len(i)) for k, v := range i { @@ -219,9 +244,23 @@ func InterfaceToIntMap(i interface{}) (val map[string]int, err error) { func InterfaceToStringMap(i interface{}) (val map[string]string, err error) { err = nil + type hasMap interface { + Map() map[string]int + RLock() + RUnlock() + Len() int + } + switch i := i.(type) { case map[string]string: val = i + case hasMap: + val = make(map[string]string, i.Len()) + i.RLock() + defer i.RUnlock() + for k, v := range i.Map() { + val[k] = strconv.Itoa(v) + } case map[string]interface{}: val = make(map[string]string, len(i)) for k, v := range i {