mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
rename goutils to obiutils
Former-commit-id: 2147f53db972bba571dfdae30c51b62d3e69cec5
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@ func (s *BioSequence) HasAttribute(key string) bool {
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// A method that returns the value of the key in the annotation map.
|
||||
func (s *BioSequence) GetAttribute(key string) (interface{}, bool) {
|
||||
var val interface{}
|
||||
@@ -43,7 +44,7 @@ func (s *BioSequence) GetIntAttribute(key string) (int, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
|
||||
if ok {
|
||||
val, err = goutils.InterfaceToInt(v)
|
||||
val, err = obiutils.InterfaceToInt(v)
|
||||
ok = err == nil
|
||||
}
|
||||
|
||||
@@ -52,15 +53,15 @@ func (s *BioSequence) GetIntAttribute(key string) (int, bool) {
|
||||
|
||||
// Deleting the key from the annotation map.
|
||||
func (s *BioSequence) DeleteAttribute(key string) {
|
||||
delete(s.Annotations(),key)
|
||||
delete(s.Annotations(), key)
|
||||
}
|
||||
|
||||
|
||||
// Renaming the key in the annotation map.
|
||||
func (s *BioSequence) RenameAttribute(newName, oldName string) {
|
||||
val,ok := s.GetAttribute(oldName)
|
||||
val, ok := s.GetAttribute(oldName)
|
||||
|
||||
if (ok) {
|
||||
s.SetAttribute(newName,val)
|
||||
if ok {
|
||||
s.SetAttribute(newName, val)
|
||||
s.DeleteAttribute(oldName)
|
||||
}
|
||||
}
|
||||
@@ -73,14 +74,13 @@ func (s *BioSequence) GetNumericAttribute(key string) (float64, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
|
||||
if ok {
|
||||
val, err = goutils.InterfaceToFloat64(v)
|
||||
val, err = obiutils.InterfaceToFloat64(v)
|
||||
ok = err == nil
|
||||
}
|
||||
|
||||
return val, ok
|
||||
}
|
||||
|
||||
|
||||
// A method that returns the value of the key in the annotation map.
|
||||
func (s *BioSequence) GetStringAttribute(key string) (string, bool) {
|
||||
var val string
|
||||
@@ -101,7 +101,7 @@ func (s *BioSequence) GetBoolAttribute(key string) (bool, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
|
||||
if ok {
|
||||
val, err = goutils.InterfaceToBool(v)
|
||||
val, err = obiutils.InterfaceToBool(v)
|
||||
ok = err == nil
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (s *BioSequence) GetIntMap(key string) (map[string]int, bool) {
|
||||
v, ok := s.GetAttribute(key)
|
||||
|
||||
if ok {
|
||||
val, err = goutils.InterfaceToIntMap(v)
|
||||
val, err = obiutils.InterfaceToIntMap(v)
|
||||
ok = err == nil
|
||||
}
|
||||
|
||||
@@ -139,7 +139,6 @@ func (s *BioSequence) SetCount(count int) {
|
||||
annot["count"] = count
|
||||
}
|
||||
|
||||
|
||||
// Returning the taxid of the sequence.
|
||||
func (s *BioSequence) Taxid() int {
|
||||
taxid, ok := s.GetIntAttribute("taxid")
|
||||
@@ -157,7 +156,6 @@ func (s *BioSequence) SetTaxid(taxid int) {
|
||||
annot["taxid"] = taxid
|
||||
}
|
||||
|
||||
|
||||
func (s *BioSequence) OBITagRefIndex() map[int]string {
|
||||
|
||||
var val map[int]string
|
||||
@@ -179,7 +177,7 @@ func (s *BioSequence) OBITagRefIndex() map[int]string {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
val[score], err = goutils.InterfaceToString(v)
|
||||
val[score], err = obiutils.InterfaceToString(v)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -135,7 +135,7 @@ func DualAnnotationClassifier(key1, key2 string, na string) *BioSequenceClassifi
|
||||
locke.Lock()
|
||||
defer locke.Unlock()
|
||||
|
||||
jb, _ := goutils.JsonMarshal([2]string{val1, val2})
|
||||
jb, _ := obiutils.JsonMarshal([2]string{val1, val2})
|
||||
json := string(jb)
|
||||
k, ok := encode[json]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
"github.com/PaesslerAG/gval"
|
||||
)
|
||||
|
||||
@@ -136,11 +136,11 @@ func minFloatMap(values map[string]float64) float64 {
|
||||
var OBILang = gval.NewLanguage(
|
||||
gval.Full(),
|
||||
gval.Function("len", func(args ...interface{}) (interface{}, error) {
|
||||
length := goutils.Len(args[0])
|
||||
length := obiutils.Len(args[0])
|
||||
return (float64)(length), nil
|
||||
}),
|
||||
gval.Function("ismap", func(args ...interface{}) (interface{}, error) {
|
||||
ismap := goutils.IsAMap(args[0])
|
||||
ismap := obiutils.IsAMap(args[0])
|
||||
return ismap, nil
|
||||
}),
|
||||
gval.Function("printf", func(args ...interface{}) (interface{}, error) {
|
||||
@@ -152,7 +152,7 @@ var OBILang = gval.NewLanguage(
|
||||
return text, nil
|
||||
}),
|
||||
gval.Function("int", func(args ...interface{}) (interface{}, error) {
|
||||
val, err := goutils.InterfaceToInt(args[0])
|
||||
val, err := obiutils.InterfaceToInt(args[0])
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%v cannot be converted to an integer value", args[0])
|
||||
@@ -160,7 +160,7 @@ var OBILang = gval.NewLanguage(
|
||||
return val, nil
|
||||
}),
|
||||
gval.Function("numeric", func(args ...interface{}) (interface{}, error) {
|
||||
val, err := goutils.InterfaceToFloat64(args[0])
|
||||
val, err := obiutils.InterfaceToFloat64(args[0])
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%v cannot be converted to a numeric value", args[0])
|
||||
@@ -168,7 +168,7 @@ var OBILang = gval.NewLanguage(
|
||||
return val, nil
|
||||
}),
|
||||
gval.Function("bool", func(args ...interface{}) (interface{}, error) {
|
||||
val, err := goutils.InterfaceToBool(args[0])
|
||||
val, err := obiutils.InterfaceToBool(args[0])
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("%v cannot be converted to a boolan value", args[0])
|
||||
@@ -189,4 +189,3 @@ var OBILang = gval.NewLanguage(
|
||||
gval.Function("composition", func(args ...interface{}) (interface{}, error) {
|
||||
return (args[0].(*BioSequence)).Composition(), nil
|
||||
}))
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -53,7 +53,7 @@ func (sequence *BioSequence) StatsOn(key string, na string) StatsOnValues {
|
||||
newstat = false
|
||||
var err error
|
||||
for k, v := range istat {
|
||||
stats[k], err = goutils.InterfaceToInt(v)
|
||||
stats[k], err = obiutils.InterfaceToInt(v)
|
||||
if err != nil {
|
||||
log.Panicf("In sequence %s : %s stat tag not only containing integer values %s",
|
||||
sequence.Id(), mkey, istat)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
)
|
||||
|
||||
var _BioSequenceByteSlicePool = sync.Pool{
|
||||
@@ -72,7 +72,7 @@ func GetAnnotation(values ...Annotation) Annotation {
|
||||
}
|
||||
|
||||
if len(values) > 0 {
|
||||
goutils.MustFillMap(a, values[0])
|
||||
obiutils.MustFillMap(a, values[0])
|
||||
}
|
||||
|
||||
return a
|
||||
|
||||
Reference in New Issue
Block a user