Skip to content

Commit

Permalink
Merge pull request #38 from jakobnissen/fixdescrparse
Browse files Browse the repository at this point in the history
Fix description newline bug
  • Loading branch information
jakobnissen authored Feb 22, 2021
2 parents ff646a0 + ced3d8b commit b1a8ecb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/fasta/readrecord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ machine = (function ()
identifier.actions[:enter] = [:pos]
identifier.actions[:exit] = [:identifier]

description = re.cat(re.any() \ hspace, re"[^\r\n]*")
description = re.cat(re.any() \ re.space(), re"[^\n\r]*")
description.actions[:enter] = [:pos]
description.actions[:exit] = [:description]
header = re.cat('>', identifier, re.opt(re.cat(re.rep1(hspace), description)))

header = re">" * identifier * re.opt(re.rep1(hspace) * re.opt(description))
header.actions[:enter] = [:mark]
header.actions[:exit] = [:header]

Expand Down Expand Up @@ -117,4 +117,4 @@ Automa.Stream.generate_reader(
initcode = initcode,
loopcode = loopcode,
returncode = returncode
) |> eval
) |> eval
4 changes: 2 additions & 2 deletions src/fastq/readrecord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ machine = (function ()
identifier.actions[:enter] = [:pos]
identifier.actions[:exit] = [:header1_identifier]

description = re.cat(re.any() \ hspace, re"[^\r\n]*")
description = re.cat(re.any() \ re.space(), re"[^\r\n]*")
description.actions[:enter] = [:pos]
description.actions[:exit] = [:header1_description]

re.cat('@', identifier, re.opt(re.cat(re.rep1(hspace), description)))
re.cat('@', identifier, re.opt(re.cat(re.rep1(hspace), re.opt(description))))
end

sequence = re"[A-z]*"
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ import BioSequences:
@test FASTA.header(record) == "CYS1_DICDI fragment"
@test FASTA.sequence(record) == aa"SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE"
@test FASTA.sequence(record, 10:15) == aa"NVEGQH"

# PR 37
s = ">A \nTAG\n"
rec = first(iterate(FASTA.Reader(IOBuffer(s))))
@test isempty(rec.description)
end

output = IOBuffer()
Expand Down Expand Up @@ -291,6 +296,11 @@ end
+2 high quality
IJN
"""

# PR 37
s = "@A \nTAG\n+\nJJJ\n"
rec = first(iterate(FASTQ.Reader(IOBuffer(s))))
@test isempty(rec.description)

# Test issue 25
lines = ["@A", "A", "+", "F", "@B", "CA", "+", "CF"]
Expand Down

0 comments on commit b1a8ecb

Please sign in to comment.