-
Notifications
You must be signed in to change notification settings - Fork 46
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 sequence view #120
Add sequence view #120
Conversation
Codecov Report
@@ Coverage Diff @@
## master #120 +/- ##
==========================================
- Coverage 83.21% 83.04% -0.17%
==========================================
Files 44 45 +1
Lines 2949 3061 +112
==========================================
+ Hits 2454 2542 +88
- Misses 495 519 +24
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Is editing a |
Yes, the view is completely unsafe. In theory it could even segfault if the underlying array is truncated. Perhaps I could add another boundscheck when accessing a view that the underlying buffer must be long enough? That would slow down boundschecked access just a little. An alternative is for the view to contain not a reference to the vector, but a reference to the longsequence itself. Edit. On third thought, the views of Base do not bounds check this way, so let's just keep the unsafe behaviour. |
Ok, I'm happy with whatever behaviour closest resembles what julians already expect from a view, since that will be most consistent. We'll just make sure to document any pitfalls properly. |
@CiaranOMara @benjward As far as I can see, this PR is ready to go. I'll leave this PR up for a few months if you want to give it a test run. Maybe there are some convenient constructors I've forgotten to implement, or a well-hidden bug or whatever. |
I think it’s fair to say that each BioSequence would have their view counterpart. To setup a consistent naming pattern for other views and to be more specific about what view SeqView provides, what about renaming SeqView as SubLongSequence? This name would also be more in line with Julia’s naming of SubArray. |
That's a good point. Perhaps my name is too generic. We probably will never need views for e.g. kmers, but surely there are other sequence types than LongSequence. So yeah, we should rename it |
I was proposing "Sub" as a prefix convention. |
I think this has been hanging around long enough - I'm merging this now, and will begin using |
This adds a sequence view
SeqView
as discussed in #102 .Because a
LongSequence
andSeqView
share the same underlying encoding, many of the oldLongSequence
methods has been changed to now take aSeqOrView
(which is justUnion{LongSequence, SeqView}
)You can construct a view with
SeqView(s::LongSequence, ::UnitRange)
@view my_seq[1:5]
SeqView(::Vector{UInt64}, ::UnitRange)
(this one doesn't boundscheck)Mutating methods that change the length of the view are intentionally not implemented, such as
filter!
map!
resize!
ungap!