Skip to content

Commit

Permalink
fix internal of print_lineage
Browse files Browse the repository at this point in the history
  • Loading branch information
banhbio committed Nov 7, 2022
1 parent 0c43252 commit 9cd9d49
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/lineage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,18 @@ Print a formatted representation of the lineage to the given `IO` object.
* `skip::Bool = false` - If `true`, skip printing `UnclassifiedTaxon` and delimiter.
"""
function print_lineage(io::IO, lineage::Lineage; delim::AbstractString=";", fill::Bool=false, skip::Bool=false)
name_line = String[]
for taxon in lineage
if typeof(taxon) == UnclassifiedTaxon
if skip
continue
end
taxa = collect(lineage)
skip && filter!(taxon -> !(taxon isa UnclassifiedTaxon), taxa)

if fill
push!(name_line, name(taxon))
else
push!(name_line, "")
end
names = map(taxa) do taxon
if taxon isa UnclassifiedTaxon
fill ? name(taxon) : ""
else
push!(name_line, name(taxon))
name(taxon)
end
end

if isempty(name_line)
return nothing
end

l = foldl((x,y) -> x*delim*y, name_line)
l = join(names, delim)
print(io, l)
return nothing
end
Expand Down

0 comments on commit 9cd9d49

Please sign in to comment.