mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Changes to be committed:
modified: cmd/obitools/obitag/main.go modified: cmd/obitools/obitag2/main.go modified: go.mod modified: go.sum modified: pkg/obiformats/ncbitaxdump/read.go modified: pkg/obioptions/version.go modified: pkg/obiseq/attributes.go modified: pkg/obiseq/taxonomy_lca.go modified: pkg/obiseq/taxonomy_methods.go modified: pkg/obiseq/taxonomy_predicate.go modified: pkg/obitax/inner.go modified: pkg/obitax/lca.go new file: pkg/obitax/taxid.go modified: pkg/obitax/taxon.go modified: pkg/obitax/taxonomy.go modified: pkg/obitax/taxonslice.go modified: pkg/obitools/obicleandb/obicleandb.go modified: pkg/obitools/obigrep/options.go modified: pkg/obitools/obilandmark/obilandmark.go modified: pkg/obitools/obilandmark/options.go modified: pkg/obitools/obirefidx/famlilyindexing.go modified: pkg/obitools/obirefidx/geomindexing.go modified: pkg/obitools/obirefidx/obirefidx.go modified: pkg/obitools/obirefidx/options.go modified: pkg/obitools/obitag/obigeomtag.go modified: pkg/obitools/obitag/obitag.go modified: pkg/obitools/obitag/options.go modified: pkg/obiutils/strings.go
This commit is contained in:
@ -389,18 +389,6 @@ func (s *BioSequence) SetCount(count int) {
|
||||
s.SetAttribute("count", count)
|
||||
}
|
||||
|
||||
// SetTaxid sets the taxid for the BioSequence.
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// taxid - the taxid to set.
|
||||
func (s *BioSequence) SetTaxid(taxid string) {
|
||||
if taxid == "" {
|
||||
taxid = "NA"
|
||||
}
|
||||
s.SetAttribute("taxid", taxid)
|
||||
}
|
||||
|
||||
func (s *BioSequence) OBITagRefIndex(slot ...string) map[int]string {
|
||||
key := "obitag_ref_index"
|
||||
|
||||
|
@ -123,7 +123,6 @@ func AddLCAWorker(taxonomy *obitax.Taxonomy, slot_name string, threshold float64
|
||||
sequence.SetAttribute(slot_name, lca.String())
|
||||
sequence.SetAttribute(lca_name, lca.ScientificName())
|
||||
sequence.SetAttribute(lca_error, math.Round((1-rans)*1000)/1000)
|
||||
|
||||
return BioSequenceSlice{sequence}, nil
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
package obiseq
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitax"
|
||||
)
|
||||
|
||||
@ -12,6 +16,23 @@ func (s *BioSequence) Taxon(taxonomy *obitax.Taxonomy) *obitax.Taxon {
|
||||
return taxonomy.Taxon(taxid)
|
||||
}
|
||||
|
||||
// SetTaxid sets the taxid for the BioSequence.
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// taxid - the taxid to set.
|
||||
func (s *BioSequence) SetTaxid(taxid string) {
|
||||
if taxid == "" {
|
||||
taxid = "NA"
|
||||
}
|
||||
s.SetAttribute("taxid", taxid)
|
||||
}
|
||||
|
||||
func (s *BioSequence) SetTaxon(taxon *obitax.Taxon) {
|
||||
taxid := taxon.String()
|
||||
s.SetTaxid(taxid)
|
||||
}
|
||||
|
||||
// Taxid returns the taxonomic ID associated with the BioSequence.
|
||||
//
|
||||
// It retrieves the "taxid" attribute from the BioSequence's attributes map.
|
||||
@ -25,7 +46,20 @@ func (s *BioSequence) Taxid() (taxid string) {
|
||||
taxid = s.taxon.String()
|
||||
ok = true
|
||||
} else {
|
||||
taxid, ok = s.GetStringAttribute("taxid")
|
||||
var ta interface{}
|
||||
ta, ok = s.GetAttribute("taxid")
|
||||
if ok {
|
||||
switch tv := ta.(type) {
|
||||
case string:
|
||||
taxid = tv
|
||||
case int:
|
||||
taxid = fmt.Sprintf("%d", tv)
|
||||
case float64:
|
||||
taxid = fmt.Sprintf("%d", int(tv))
|
||||
default:
|
||||
log.Fatalf("Taxid: %v is not a string or an integer (%T)", ta, ta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
|
@ -47,14 +47,7 @@ func IsAValidTaxon(taxonomy *obitax.Taxonomy, withAutoCorrection ...bool) Sequen
|
||||
|
||||
// A function that takes a taxonomy and a taxid as arguments and returns a function that takes a
|
||||
// pointer to a BioSequence as an argument and returns a boolean.
|
||||
func IsSubCladeOf(taxonomy *obitax.Taxonomy, taxid string) SequencePredicate {
|
||||
parent := taxonomy.Taxon(taxid)
|
||||
|
||||
if parent == nil {
|
||||
log.Fatalf("Cannot find taxon : %s in taxonomy %s",
|
||||
taxid,
|
||||
taxonomy.Name())
|
||||
}
|
||||
func IsSubCladeOf(taxonomy *obitax.Taxonomy, parent *obitax.Taxon) SequencePredicate {
|
||||
|
||||
f := func(sequence *BioSequence) bool {
|
||||
taxon := sequence.Taxon(taxonomy)
|
||||
|
Reference in New Issue
Block a user