Patch a bug in obitag

This commit is contained in:
Eric Coissac
2025-06-04 14:47:28 +02:00
parent 6cb7a5a352
commit d31e677304
3 changed files with 10 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import (
// corresponds to the last commit, and not the one when the file will be // corresponds to the last commit, and not the one when the file will be
// commited // commited
var _Commit = "3424d30" var _Commit = "6cb7a5a"
var _Version = "Release 4.4.0" var _Version = "Release 4.4.0"
// Version returns the version of the obitools package. // Version returns the version of the obitools package.

View File

@ -56,8 +56,6 @@ func IndexSequence(seqidx int,
refs[pseq.Taxon(i).Node] = &temp refs[pseq.Taxon(i).Node] = &temp
} }
// log.Infof("%s length of path: %d", sequence.Id(), len(refs))
n := taxa.Len() n := taxa.Len()
lcaCache := make(map[*obitax.TaxNode]*obitax.TaxNode, n) lcaCache := make(map[*obitax.TaxNode]*obitax.TaxNode, n)
@ -89,10 +87,10 @@ func IndexSequence(seqidx int,
var matrix []uint64 var matrix []uint64
// obilog.Warnf("%s : %s", sequence.Id(), pseq.String()) // obilog.Warnf("%s : %s", sequence.Id(), pseq.String())
for idx_path := 1; idx_path < path_len; idx_path++ { for idx_path := 1; idx_path < path_len; idx_path++ {
mini := -1 mini := -1
seqidcs := refs[pseq.Taxon(idx_path).Node] seqidcs := refs[pseq.Taxon(idx_path).Node]
ns := len(*seqidcs) ns := len(*seqidcs)
if ns > 0 { if ns > 0 {
@ -167,7 +165,6 @@ func IndexSequence(seqidx int,
obitag_index := make(map[int]string, pseq.Len()) obitag_index := make(map[int]string, pseq.Len())
// obilog.Warnf("(%s,%s): %v", sequence.Id(), pseq.Taxon(0).String(), closest)
for i, d := range closest { for i, d := range closest {
if i < (len(closest)-1) && d < closest[i+1] { if i < (len(closest)-1) && d < closest[i+1] {
current_taxon := pseq.Taxon(i) current_taxon := pseq.Taxon(i)
@ -175,6 +172,10 @@ func IndexSequence(seqidx int,
} }
} }
if len(obitag_index) == 0 {
obitag_index[0] = pseq.Taxon(pseq.Len() - 1).String()
}
/* /*
log.Println(sequence.Id(), tseq.Taxid(), tseq.ScientificName(), tseq.Rank(), obitag_index) log.Println(sequence.Id(), tseq.Taxid(), tseq.ScientificName(), tseq.Rank(), obitag_index)
log.Println(sequence.Id(), tseq.Taxid(), tseq.ScientificName(), tseq.Rank(), nseq) log.Println(sequence.Id(), tseq.Taxid(), tseq.ScientificName(), tseq.Rank(), nseq)

View File

@ -213,6 +213,10 @@ func Identify(sequence *obiseq.BioSequence,
taxon = match_taxon taxon = match_taxon
} }
if taxon.IsRoot() {
break
}
} }
log.Debugln(sequence.Id(), "Best matches:", len(bests), "New index:", newidx) log.Debugln(sequence.Id(), "Best matches:", len(bests), "New index:", newidx)