mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-06-24 01:31:00 +00:00
feat: support map and slice types in OBI attributes
Extends OBI header parsing to recognize and deserialize JSON-like arrays and objects. Introduces safe conversion utilities in `obiutils` to cast generic interface values into typed maps, and exposes them via new `BioSequence` methods. Header values are now marshaled, quote-normalized, and formatted for map and slice types.
This commit is contained in:
@@ -364,6 +364,24 @@ func (s *BioSequence) GetIntSlice(key string) ([]int, bool) {
|
||||
return val, ok
|
||||
}
|
||||
|
||||
func (s *BioSequence) GetMapOfIntSlice(key string) (map[string][]int, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
val, err := obiutils.InterfaceToMapOfIntSlice(v)
|
||||
return val, err == nil
|
||||
}
|
||||
|
||||
func (s *BioSequence) GetMapOfStringSlice(key string) (map[string][]string, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
val, err := obiutils.InterfaceToMapOfStringSlice(v)
|
||||
return val, err == nil
|
||||
}
|
||||
|
||||
// Count returns the value of the "count" attribute of the BioSequence.
|
||||
//
|
||||
// The count of a sequence is the number of times it has been observed in the dataset.
|
||||
|
||||
Reference in New Issue
Block a user