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

Document read!(::Reader, ::Record) #94

Open
jonathanBieler opened this issue Feb 8, 2023 · 4 comments
Open

Document read!(::Reader, ::Record) #94

jonathanBieler opened this issue Feb 8, 2023 · 4 comments

Comments

@jonathanBieler
Copy link

jonathanBieler commented Feb 8, 2023

Sorry, I'm a bit confused by the doc (or lack thereof), is that one correct way one has to read a fastq file, say if I want to read N reads (I could use while next !== nothing too) ? I think adding an example in the docs would be good.

reader = FASTQ.Reader(GzipDecompressorStream(open(file)) ; copy=false)

r = first(reader)

for k = 1:N

    # do something here

    next = iterate(reader)
    isnothing(next) && break
    r = next[1]
end

close(reader)

Also the old read!(reader, r) doesn't crash but does nothing, it should be an error now, no ?

@jonathanBieler
Copy link
Author

jonathanBieler commented Feb 9, 2023

Ha, I though I needed it to go trough paired files at once, but I can use for (r1,r2) in zip(reader1,reader2). Would still be good to document it though.

@jakobnissen
Copy link
Member

Dear @jonathanBieler

Indeed, read! is a bug (see #95), which will be fixed in a few hours.
Readers are like any other iterators. To get N elements from an iterator, you can use Iterators.take, or use zip(1:N, reader), or use a normal for loop.

@jonathanBieler
Copy link
Author

Thanks, so the read! API is not deprecated ? might be worth mentioning it in the docs then. It was nice to have the same API for XAM, FASTX and VariantCallFormat, so one could write generic code for those.

@jakobnissen
Copy link
Member

Hm... I've not deprecated it yet. I don't think it should be deprecated. You're right, it should be in the docs.

@jakobnissen jakobnissen reopened this Feb 16, 2023
@jakobnissen jakobnissen changed the title Reading with the iteration protocole in 2.0 Document read!(::Reader, ::Record) Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants