Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate sequence #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,19 @@ struct Record
meta :: String
end

name(r::Record) = isempty(r.meta) ? r.name : r.name * " " * r.meta
name(r::Record) = isempty(r.meta) ? r.name : r.name * " " * r.meta

NL = '\n'
Base.show(io::IO, rec::Record) = print(io, ">$(rec.name) $(rec.meta)$(NL)$(String(rec.seq[1:40]))...$(String(rec.seq[end-40:end]))")

function validate(dna::Array{UInt8})
if sum(wcpair[nuc+1] == 0 for nuc in dna) > 0
error("invalid sequence inside fasta")
end

return dna
end

"""
read_fasta(io::IO)

Expand All @@ -555,7 +563,7 @@ function read_fasta(io::IO)
write(buf,rstrip(line))
line=readline(io)
end
put!(chan, Record(take!(buf), name, meta))
put!(chan, Record(buf |> take! |> validate, name, meta))
end

close(buf)
Expand Down