Open tpoisot opened 2 years ago
And writing the actual comparison code is not too bad:
import Base: isless
hierarchy = [
NCBITaxonomy.RankSuperkingdom,
NCBITaxonomy.RankKingdom,
NCBITaxonomy.RankSubkingdom,
NCBITaxonomy.RankSuperphylum,
NCBITaxonomy.RankPhylum,
NCBITaxonomy.RankSubphylum,
NCBITaxonomy.RankSuperclass,
NCBITaxonomy.RankClass,
NCBITaxonomy.RankSubclass,
NCBITaxonomy.RankInfraclass,
NCBITaxonomy.RankSuperorder,
NCBITaxonomy.RankOrder,
NCBITaxonomy.RankSuborder,
NCBITaxonomy.RankInfraorder,
NCBITaxonomy.RankSuperfamily,
NCBITaxonomy.RankFamily,
NCBITaxonomy.RankSubfamily,
NCBITaxonomy.RankGenus,
NCBITaxonomy.RankSubgenus,
NCBITaxonomy.RankSpecies,
NCBITaxonomy.RankSubspecies,
]
for higherlevel_index in 1:(length(hierarchy)-1)
for lowerlevel_index in (higherlevel_index+1):length(hierarchy)
eval(quote
Base.isless(::Type{$(hierarchy[lowerlevel_index])}, ::Type{$(hierarchy[higherlevel_index])}) = true
Base.isless(::Type{$(hierarchy[higherlevel_index])}, ::Type{$(hierarchy[lowerlevel_index])}) = false
end)
end
end
But this is a good use-case for this package. If the types were defined in Taxonomies.jl
, we could use a standard set of ranks across the EcoJulia ecosystem, and then map the specific type to them.
One issue is that not all of these ranks have a hierarchical relationship, necessarilly
One issue is that not all of these ranks have a hierarchical relationship, necessarilly
That was part of my thinking when putting together FixedRank
vs FlexibleRank
taxonomy, might revisit this soon
So when trying to add comparisons to NCBITaxonomy, I ended up writing code like