Fisrt step in the obitax rewriting

This commit is contained in:
Eric Coissac
2024-11-08 09:48:16 +01:00
parent 422f11cceb
commit 9471fedfa1
16 changed files with 801 additions and 756 deletions

View File

@@ -1,21 +1,22 @@
package obitax
func (taxon *TaxNode) IsSubCladeOf(parent *TaxNode) bool {
import "log"
for taxon.taxid != parent.taxid && taxon.parent != taxon.taxid {
taxon = taxon.pparent
func (taxon *Taxon) IsSubCladeOf(parent *Taxon) bool {
if taxon.Taxonomy != parent.Taxonomy {
log.Fatalf(
"Both taxa %s and %s must belong to the same taxonomy",
taxon.String(),
parent.String(),
)
}
return taxon.taxid == parent.taxid
}
func (taxon *TaxNode) IsBelongingSubclades(clades *TaxonSet) bool {
_, ok := (*clades)[taxon.taxid]
for !ok && taxon.parent != taxon.taxid {
taxon = taxon.pparent
_, ok = (*clades)[taxon.taxid]
for t := range taxon.IPath() {
if t.Node.Id() == parent.Node.Id() {
return true
}
}
return ok
return false
}