Add a first version of obitag the successor of ecotag

This commit is contained in:
2022-10-26 13:16:56 +02:00
parent e17d1fbca6
commit 8aa323dad5
17 changed files with 884 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ package obiseq
import (
"crypto/md5"
"fmt"
"strconv"
"sync/atomic"
log "github.com/sirupsen/logrus"
@@ -298,6 +299,49 @@ func (s *BioSequence) Taxid() int {
return taxid
}
func (s *BioSequence) EcotagRefIndex() map[int]string {
var val map[int]string
i, ok := s.GetAttribute("ecotag_ref_index")
if !ok {
return nil
}
switch i := i.(type) {
case map[int]string:
val = i
case map[string]interface{}:
val = make(map[int]string, len(i))
for k, v := range i {
score, err := strconv.Atoi(k)
if err != nil {
log.Panicln(err)
}
val[score], err = goutils.InterfaceToString(v)
if err != nil {
log.Panicln(err)
}
}
case map[string]string:
val = make(map[int]string, len(i))
for k, v := range i {
score, err := strconv.Atoi(k)
if err != nil {
log.Panicln(err)
}
val[score] = v
}
default:
log.Panicln("value of attribute ecotag_ref_index cannot be casted to a map[int]string")
}
return val
}
func (s *BioSequence) SetTaxid(taxid int) {
annot := s.Annotations()
annot["taxid"] = taxid