From 66c70073990bc3b3f7cf735028751b1727e0bc51 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Wed, 27 Sep 2023 19:29:06 +0200 Subject: [PATCH] Update --- docs/src/files.md | 8 ++++---- docs/src/index.md | 4 ++-- src/FASTX.jl | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/src/files.md b/docs/src/files.md index a10b197..691068a 100644 --- a/docs/src/files.md +++ b/docs/src/files.md @@ -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 diff --git a/docs/src/index.md b/docs/src/index.md index 07389df..33c0614 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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 diff --git a/src/FASTX.jl b/src/FASTX.jl index 6055ef4..d084083 100644 --- a/src/FASTX.jl +++ b/src/FASTX.jl @@ -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 @@ -258,7 +258,6 @@ export seekrecord, # Re-export from BioGenerics - defer, @rdr_str, @wtr_str