Skip to content

Use new BioGenerics macros#111

Draft
jakobnissen wants to merge 6 commits intoBioJulia:masterfrom
jakobnissen:highlevel
Draft

Use new BioGenerics macros#111
jakobnissen wants to merge 6 commits intoBioJulia:masterfrom
jakobnissen:highlevel

Conversation

@jakobnissen
Copy link
Copy Markdown
Member

@jakobnissen jakobnissen commented Sep 22, 2023

The new BioGenerics @rdr_str and @wtr_str macros, as well as the defer keyword has been a longstanding FASTX todo.
This change adds this new functionality.

TODO:

Comment thread Project.toml
TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"

[weakdeps]
BioSequences = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, great use of this functionality

Comment thread docs/Project.toml
BioSequences = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FASTX = "c2308a5c-f048-11e8-3e8a-31650f418d12"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need CodecZlib here as well? Might be nice if we want doctests for compression

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea.
Actually, maby of the examples are not doctested because it requires a compressed file to be present. I should just add a few small dummy files for test purposes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test dep on BioFormatSpecimens? That's what it's there for

Comment thread docs/src/files.md
### Readers and writers - basics
A `Reader` and a `Writer` are structs that wrap an IO, and allows efficient reading/writing of FASTX `Record`s.
For FASTA, use `FASTA.Reader` and `FASTA.Writer`, and for FASTQ - well I'm sure you've guessed it.
For FASTA, use `FASTAReader` and `FASTAWriter`, and for FASTQ - well I'm sure you've guessed it.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these changes are duplicates from #113 . If you branched from there, just be on the lookout for merge conflicts.

Comment thread docs/src/files.md Outdated
FASTAReader(GzipDecompressorStream(open("seqs.fna.gz"; lock=false)))
```

To use rdr `rdr` and `wtr` macros with `do`-syntax, use the `defer` function.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we married to defer? Might be something useful to bikeshed. I agree we shouldn't use with given the new use in Base, but defer doesn't seem intuitive from a user perspective (though I understand where it's coming from).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm completely open to suggestions. I like defer because it's short, but it's a little opaque.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my mind, I really want to be able to use existing stuff rather than introducing a new function name. If we do need a new function name, the only thing better I can think of is apply, but it's not much better.

The primary reason not to just make these iterables so they one can use eg map and foreach is the need to close the handle, right?

How does Base.eachline handle this? It allows you to pass a file name, iterates through lines without needing an explicit open, and doesn't need to be closed. But I guess that's only reading, not writing.

To be clear, I don't think any of this should be blocking. defer is probably fine, and as-is this is a really big increase in usability. I don't want the perfect to be the enemy of the really good here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really want to be able to use existing stuff rather than introducing a new function name
I agree. Not sure what it should be, though.

Base.eachline closes the handle when the iterator is exhausted. This is quite elegant, but only works for readers, not for writers. We could auto-close readers, but I'm a bit wary of guiding users towards not closing their readers, when they really do need to close their writers.

Mention the most important things first in the documentation: How to read and
write files.
The new BioGenerics `@rdr_str` and `@wtr_str` macros, as well as the `defer`
keyword has been a longstanding FASTX todo.
This change adds this new functionality.
@jakobnissen jakobnissen changed the title Bump to BioGenerics 0.2 and use new BioGenerics macros Use new BioGenerics macros Sep 27, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 27, 2023

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.52%. Comparing base (53784f9) to head (7eaea5b).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/FASTX.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
- Coverage   89.78%   89.52%   -0.26%     
==========================================
  Files          15       15              
  Lines         695      697       +2     
==========================================
  Hits          624      624              
- Misses         71       73       +2     
Flag Coverage Δ
unittests 89.52% <0.00%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

2 participants