diff --git a/src/fasta/readrecord.jl b/src/fasta/readrecord.jl index 7f84c6c..de2eb63 100644 --- a/src/fasta/readrecord.jl +++ b/src/fasta/readrecord.jl @@ -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] @@ -117,4 +117,4 @@ Automa.Stream.generate_reader( initcode = initcode, loopcode = loopcode, returncode = returncode -) |> eval \ No newline at end of file +) |> eval diff --git a/src/fastq/readrecord.jl b/src/fastq/readrecord.jl index 8cbd53f..5471c6a 100644 --- a/src/fastq/readrecord.jl +++ b/src/fastq/readrecord.jl @@ -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]*" diff --git a/test/runtests.jl b/test/runtests.jl index 84b9c09..6836077 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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() @@ -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"]