A first version of obigrep. Normally fully functionnal, but not fully tested

This commit is contained in:
2022-02-25 07:29:52 +01:00
parent 0a36447e2a
commit 011898bd9d
11 changed files with 709 additions and 772 deletions

View File

@ -2,6 +2,8 @@ package obitax
import (
"regexp"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
)
type TaxNode struct {
@ -64,3 +66,23 @@ func (node *TaxNode) IsNameMatching(pattern *regexp.Regexp) bool {
return false
}
func (node *TaxNode) HasRankDefined(rank string) bool {
for node.rank != rank && node.parent != node.taxid {
node = node.pparent
}
return node.rank == rank
}
func HasRankDefined(taxonomy Taxonomy, rank string) obiseq.SequencePredicate {
f := func(sequence *obiseq.BioSequence) bool {
taxon, err := taxonomy.Taxon(sequence.Taxid())
return err == nil && taxon.HasRankDefined(rank)
}
return f
}