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

Add guessparse function #269

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakobnissen
Copy link
Member

This function is a quick-and-dirty parser function from AbstractString to LongSequence, with autodetection of the alphabet. It's meant to be used in ephemeral REPL work, and very clearly documented to be unstable and subject to change.

See #268

This is just a draft. The implementation is straightforward, but we might want to think about whether we want this, and what it should be called.
Preferably, the name should be:

  • Short, since it's meant to be used in the REPL
  • Very clear in that this function is based on guesswork, and is therefore not suitable for long-lasting code.

TODO:

  • Bikeshed the name and functionality
  • Tests
  • Update changelog
  • Update docs
  • More comments in the LUT table generation

This function is a quick-and-dirty parser function from `AbstractString` to
`LongSequence`, with autodetection of the alphabet.
It's meant to be used in ephemeral REPL work, and very clearly documented to
be unstable and subject to change.

See BioJulia#268
@jakobnissen jakobnissen linked an issue Feb 27, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Base: 91.20% // Head: 90.58% // Decreases project coverage by -0.63% ⚠️

Coverage data is based on head (fdbb494) compared to base (4a31474).
Patch coverage: 4.54% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #269      +/-   ##
==========================================
- Coverage   91.20%   90.58%   -0.63%     
==========================================
  Files          31       31              
  Lines        2400     2421      +21     
==========================================
+ Hits         2189     2193       +4     
- Misses        211      228      +17     
Flag Coverage Δ
unittests 90.58% <4.54%> (-0.63%) ⬇️

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

Impacted Files Coverage Δ
src/BioSequences.jl 100.00% <ø> (ø)
src/alphabet.jl 89.77% <0.00%> (+1.53%) ⬆️
src/longsequences/constructors.jl 71.87% <5.26%> (-28.13%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

possible_encodings(b::UInt8)::UInt8

Returns a `UInt8` with any of the 4 lower bits set:
* Bit 0: Valid `RNA`
Copy link
Contributor

Choose a reason for hiding this comment

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

Valid DNA?

@cjprybol
Copy link
Contributor

This looks great, thanks @jakobnissen! I like having both the guessparse and guess_alphabet functions, as you've done here.

This seems much more efficient than I was initially picturing (using regex or the tryparse approach), which is excellent.

@kescobo
Copy link
Member

kescobo commented Feb 28, 2023

I wonder if it would be worth looking at CSV.read() for inspiration here. There, the function goes through X lines and tries to guess the type of each column. X is user-selectable but has a sensible default.

I'm wondering if we want to always return a type, or throw an error if it's ambiguous... Maybe as an alternative the the later, offer an optional type to use as a default, like guessparse(seq, LongDNA{2})

For bikeshedding, I quite liked swagparse, but that's not very discoverable... then again, might be worth being silly if we want to signal that this is experimental/unstable

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.

Record type inference
3 participants