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

25
pkg/obitax/lca.go Normal file
View File

@ -0,0 +1,25 @@
package obitax
func (t1 *TaxNode) LCA(t2 *TaxNode) (*TaxNode, error) {
p1, err1 := t1.Path()
if err1 != nil {
return nil, err1
}
p2, err2 := t2.Path()
if err2 != nil {
return nil, err2
}
i1 := len(*p1) - 1
i2 := len(*p2) - 1
for i1 >= 0 && i2 >= 0 && (*p1)[i1].taxid == (*p2)[i2].taxid {
i1--
i2--
}
return (*p1)[i1+1], nil
}