@@ -281,6 +281,26 @@ This function is useful for converting `Lineage` to `DataFrame`, for example.
281281# Arguments
282282
283283* `fill_by_missing::Bool = false` - If `true`, fills missing instead of `UnclassifiedTaxon`.
284+
285+ # Examples
286+
287+ ```jldoctest
288+ julia> ranks = [:domain, :phylum, :class, :order, :family, :genus, :species];
289+
290+ julia> lineage = reformat(Lineage(Taxon(9606)), ranks);
291+
292+ julia> nt = namedtuple(lineage);
293+
294+ julia> nt.species
295+ 9606 [species] Homo sapiens
296+
297+ julia> incomplete = reformat(Lineage(Taxon(9443)), ranks);
298+
299+ julia> nt = namedtuple(incomplete; fill_by_missing=true);
300+
301+ julia> ismissing(nt.species)
302+ true
303+ ```
284304"""
285305function namedtuple (l:: Lineage ; fill_by_missing:: Bool = false )
286306 ranks = l. ranks
@@ -304,6 +324,23 @@ Print a formatted representation of the lineage to the given `IO` object.
304324* `delim::AbstractString = ";"` - The delimiter between taxon fields.
305325* `fill::Bool = false` - If `true`, prints `UnclassifiedTaxon`. only availavle when skip is false.
306326* `skip::Bool = false` - If `true`, skip printing `UnclassifiedTaxon` and delimiter.
327+
328+ # Examples
329+
330+ ```jldoctest
331+ julia> ranks = [:domain, :phylum, :class, :order, :family, :genus, :species];
332+
333+ julia> lineage = reformat(Lineage(Taxon(9443)), ranks);
334+
335+ julia> sprint(io -> print_lineage(io, lineage))
336+ "Eukaryota;Chordata;Mammalia;Primates;;;"
337+
338+ julia> sprint(io -> print_lineage(io, lineage; skip=true))
339+ "Eukaryota;Chordata;Mammalia;Primates"
340+
341+ julia> sprint(io -> print_lineage(io, lineage; fill=true))
342+ "Eukaryota;Chordata;Mammalia;Primates;unclassified Primates family;unclassified Primates genus;unclassified Primates species"
343+ ```
307344"""
308345function print_lineage (io:: IO , lineage:: Lineage ; delim:: AbstractString = " ;" , fill:: Bool = false , skip:: Bool = false )
309346 taxa = collect (lineage)
0 commit comments