Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Sep 27, 2023
1 parent c403439 commit 66c7007
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/src/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ The macro call `rdr"seqs.fna.gz"` expands to
FASTAReader(GzipDecompressorStream(open("seqs.fna.gz"; lock=false)))
```

To use rdr `rdr` and `wtr` macros with `do`-syntax, use the `defer` function.
The only purpose of the defer function is to enable `do`-syntax:
Even though the reader (or writer) is already opened, you can still use the ordinary `open(x) do f`
pattern to automatically close the reader when done:

```jldoctest
julia> using CodecZlib # for gzip files
julia> defer(rdr"../test/data/test.fasta") do reader
julia> open(rdr"../test/data/test.fasta") do reader
println(identifier(first(reader)))
end
abc
julia> defer(wtr"seqs.fna.gz") do writer
julia> open(wtr"seqs.fna.gz") do writer
write(writer, FASTARecord("my_header", "TAGAG"))
end
17
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ julia> FASTQWriter(GzipCompressorStream(open(tempname(), "w"))) do writer

For added convenience, you can also use the reader and writer macros `rdr""` and `wtr""`.
These macros use the file extensions to determine the biological sequence reader or writer type, and any file compresion.
To use these macros with the `do`-syntax, you can use the `defer` function. Hence, the above code block can also be written in the following equivalent way:
To use these macros with the `do`-syntax, you can use `open` as normal. Hence, the above code block can also be written in the following equivalent way:

```jldoctest
julia> using CodecZlib
julia> defer(rdr"../test/data/seqs.fna.gz") do reader
julia> open(rdr"../test/data/seqs.fna.gz") do reader
for record in reader
println(identifier(record))
end
Expand Down
3 changes: 1 addition & 2 deletions src/FASTX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module FASTX

using StringViews: StringView
using Automa: Automa
using BioGenerics: BioGenerics, defer, @rdr_str, @wtr_str
using BioGenerics: BioGenerics, @rdr_str, @wtr_str

"""
identifier(record::Record)::AbstractString
Expand Down Expand Up @@ -258,7 +258,6 @@ export
seekrecord,

# Re-export from BioGenerics
defer,
@rdr_str,
@wtr_str

Expand Down

0 comments on commit 66c7007

Please sign in to comment.