mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
A first version of obigrep. Normally fully functionnal, but not fully tested
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user