-
Notifications
You must be signed in to change notification settings - Fork 48
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 tryparse(::BioSequence, s::AbstractString) or similar #224
Comments
I don't understand the Maybe facilitating something like the following would provide a more productive upfront test? symbols = unique(itr)
if issubset(symbols, alphabet)
# do something
end |
@CiaranOMara Right, so this is a complicated topic, and while I'm pretty sure I don't have any final, ideal solutions, I'm convinced that moving the thrown errors into an For a longer discussion on this, see JuliaLang/julia#43773 . The core issue is that there are 2 problems with throwing errors in cases where you actually expect an error could happen:
The advantage of That being said, in this particular case, maybe you're right that an option of checking the alphabet with an explicit
Instead of
One additional issue with |
To summarise, the proposed I prefer the idea of returning an error instead of nothing, as it is more likely that downstream code that doesn't handle a returned error will fail fast. If I'm not mistaken, for the return
You can still choose to handle your own errors and otherwise rethrow. for seqtype in [LongDNA{2}, LongAA]
seq = try
parse(LongDNA{2}, myseq)
catch e
if e isa ParseError
return nothing
end
rethrow()
end
if seq isa seqtype
... However, I can see that the boilerplate for your suggestion is preferable. |
Since we have
parse
, it would be nice to havetryparse
. This would also enable e.g. users of FASTX to check if a record conformed to an Alphabet without throwing and catching errors.The text was updated successfully, but these errors were encountered: