API Reference
Public
Taxonomy.Lineage
— TypeLineage{T<:AbstractTaxon} <: AbstractVector{T}
A type that stores lineage information in Vector
-like format. T
represents element types, Taxon
or UnclassifiedTaxon
.
getindex
is overloaded to getTaxon
values.Symbol
s such as:superkingdom
,:family
,:genus
,:species
inCanonicalRanks
can be used. Also,Between
,From
,Until
,Cols
andAll
selectors can be used in more complex rank selection scenarios.- Once reformatted, it cannot be reformatted again. The status can be checked using
isreformatted(lineage)
.
Taxonomy.Rank
— TypeRank(sym::Symbol)
Return CanonicalRank(sym)
if sym is in CanonicalRanks
. Return UnCanonicalRank(sym)
if not. CanonicalRank(sym)
can be used for isless
comparison.
Taxonomy.Rank
— MethodRank(taxon::Taxon)
Return CanonicalRank
made from rank(taxon)
if rank(taxon)
is in CanonicalRanks
. Return UnCanonicalRank(rank)
if not. CanonicalRank(taxon)
can be used for isless
comparison.
Taxonomy.Taxon
— TypeTaxon(taxid::Int, db::Taxonomy.DB)
Taxon(taxid::Int)
Construct a Taxon
from its taxid
. Omitting db
automatically calls current_db()
, which is usually the database that was last created.
AbstractTrees.children
— Methodchildren(taxon::Taxon)
Return the vector of Taxon
objects that are children of the given Taxon
object.
AbstractTrees.isdescendant
— Methodisdescendant(descendant::Taxon, ancestor::Taxon)
Return true
if the former taxon is a descendant of the latter taxon.
AbstractTrees.parent
— MethodAbstractTrees.parent(taxon::Taxon)
Return the Taxon
object that is the parent of the given Taxon
object.
Base.get
— Methodget(db::Taxonomy.DB, idx::Union{Int,Symbol}, default)
Return the Taxon object stored for the given taxid or rank (i.e. :phylum), or the given default value if no mapping for the taxid is present.
Base.get
— Methodget(db::Taxonomy.DB, taxid::Int, default)
Return the Taxon
object stored for the given taxid, or the given default value if no mapping for the taxid is present.
Base.get
— Methodget(db::Taxonomy.DB, name::String, default)
Return the Taxon
object stored for the given name, or the given default value if no mapping for the name is present.
Taxonomy.current_db!
— Methodcurrent_db!(db::Taxonomy.DB)
Set db
as the current active database.
Taxonomy.current_db
— Methodcurrent_db()
Return the current active database or the last database that got created.
Taxonomy.isancestor
— Methodisancestor(ancestor::Taxon, descendant::Taxon)
Return true
if the former taxon is an ancestor of the latter taxon.
Taxonomy.isreformatted
— Methodisreformatted(lineage::Lineage)
Return true
if lineage
is already reformatted.
Taxonomy.lca
— Methodlca(taxa::Vector{Taxon})
lca(taxa::Taxon...)
Return the Taxon
object that is the lowest common ancestor of the given set of Taxon
s.
Taxonomy.name
— Methodname(taxon::AbstractTaxon)
Return the name of the given Taxon
object. It also works for an UnclassifiedTaxon
object.
Taxonomy.name2taxids
— Methodname2taxids(name::AbstractString, db::Taxonomy.DB)
name2taxids(name::AbstractString)
Return a Vector
of taxid from its name
. name
must match to the scientific name exactly. If multiple hits are found, return a multi-element Vector
. If not, 1- or 0-element Vector
. Omitting db
automatically calls current_db()
, which is usually the database that was last created.
Taxonomy.namedtuple
— Methodnamedtuple(lineage::Lineage; kwargs...)
Return a NamedTuple whose filednames is ranks (in the CanonicalRanks
) of the lineage
. This function is useful for converting Lineage
to DataFrame
, for example.
Arguments
fill_by_missing::Bool = false
- Iftrue
, fills missing instead ofUnclassifiedTaxon
.
Taxonomy.print_lineage
— Methodprint_lineage(lineage::Lineage; kwargs...)
print_lineage(io::IO, lineage::Lineage; kwargs...)
Print a formatted representation of the lineage to the given IO
object.
Arguments
delim::AbstractString = ";"
- The delimiter between taxon fields.fill::Bool = false
- Iftrue
, printsUnclassifiedTaxon
. only availavle when skip is false.skip::Bool = false
- Iftrue
, skip printingUnclassifiedTaxon
and delimiter.
Taxonomy.rank
— Methodrank(taxon::AbstractTaxon)
Return the rank of the given Taxon
object. It also works for an UnclassifiedTaxon
object.
Taxonomy.reformat
— Methodreformat(l::Lineage, ranks::Vector{Symbol})
Return the Lineage
object reformatted according to the given ranks. If there is no corresponding taxon in the lineage to the rank, UnclassifiedTaxon
will be stored. Once a Lineage
is reformatted, it cannot be reformatted again.
Taxonomy.similarnames
— Methodsimilarnames(query::AbstractString, db::Taxonomy.DB; distance::StringDistances.StringDistance=StringDistances.Levenshtein(), threshold::Float64=0.8)
similarnames(query::AbstractString; distance::StringDistances.StringDistance=StringDistances.Levenshtein(), threshold::Float64=0.8)
Find names similar to the query
and return a Vector
of NamedTuple
s with taxid, name, and similarity. The similarities are calculated by the Lavenshtein distance by default. It can also be changed to other distances defined in StringDistaces
package by specifying it in the distance argument. Omitting db
automatically calls current_db()
, which is usually the database that was last created.
Taxonomy.taxid
— Methodtaxid(taxon::Taxon)
Return the taxid of the given Taxon
object.
Internal
Taxonomy.DB
— TypeTaxonomy.DB
Constructors
DB(nodes_dmp::String, names_dmp::String)
Create DB(taxonomy database) object from nodes.dmp and names.dmp files.
Base.isless
— Methodisless(taxon::AbstractTaxon, rank::CanonicalRank)
Example
julia> Taxon(9606 , db) < Rank(:genus)
true
Return true
if the rank of the former Taxon
is less than the later rank.