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 findall method #218

Merged
merged 4 commits into from
Jan 16, 2022
Merged

Conversation

CiaranOMara
Copy link
Member

I reckon this PR fulfils the findall method requirements.

The findall method delegates to a Search iterator in the implementation. Let me know whether this approach suits and I'll add some docstrings.

Closes #217.

@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #218 (7a16f9d) into master (8d0080a) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   88.45%   88.57%   +0.12%     
==========================================
  Files          31       31              
  Lines        2408     2425      +17     
==========================================
+ Hits         2130     2148      +18     
+ Misses        278      277       -1     
Flag Coverage Δ
unittests 88.57% <100.00%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
src/BioSequences.jl 94.11% <100.00%> (+94.11%) ⬆️
src/longsequences/seqview.jl 100.00% <100.00%> (ø)
src/biosequence/find.jl 61.29% <0.00%> (+3.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d0080a...7a16f9d. Read the comment docs.

@CiaranOMara CiaranOMara force-pushed the feature/findall branch 2 times, most recently from 4ff0244 to 6243900 Compare January 10, 2022 13:47
Copy link
Member

@jakobnissen jakobnissen left a comment

Choose a reason for hiding this comment

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

Great, thanks for contributing. Not sure about the signature though, it doesn't match Base. What signature would you prefer?

src/BioSequences.jl Outdated Show resolved Hide resolved
src/BioSequences.jl Outdated Show resolved Hide resolved
src/BioSequences.jl Outdated Show resolved Hide resolved
src/BioSequences.jl Outdated Show resolved Hide resolved
src/BioSequences.jl Outdated Show resolved Hide resolved
src/BioSequences.jl Outdated Show resolved Hide resolved
Co-authored-by: Jakob Nybo Nissen <jakobnybonissen@gmail.com>
@CiaranOMara CiaranOMara force-pushed the feature/findall branch 3 times, most recently from 3e24fb2 to fd0f57f Compare January 10, 2022 22:20
@CiaranOMara
Copy link
Member Author

This PR is ready for another review pass.

I've added a convenience method that uses a view to limit the search range and map indices back to a parent. If it's not worthwhile, it can be removed.

function Base.findall(pat, seq::BioSequence, rng::UnitRange{Int}; overlap::Bool = DEFAULT_OVERLAP)
v = view(seq, rng)
itr = search(pat, v; overlap)
return map(x->parentindices(v)[1][x], itr)
end

Also, is the PR code positioned where you'd like it to be within the project?

CiaranOMara and others added 2 commits January 11, 2022 09:33
Co-authored-by: Jakob Nybo Nissen <jakobnybonissen@gmail.com>
- Provides a convenience `findall` method that maps indices back to the parent sequence.
@jakobnissen
Copy link
Member

I think everything looks good now.

@TransGirlCodes
Copy link
Member

Looking good! Did you want to add some docstrings and or a paragraph in the search section of the manual? No immediate pressure as they can always be added before a release.

@CiaranOMara
Copy link
Member Author

I reckon I can add some docstrings to this over the next couple of days.

@jakobnissen jakobnissen merged commit d3d8fc4 into BioJulia:master Jan 16, 2022
@jakobnissen
Copy link
Member

I'll just merge this, and then we can always add some docs later.

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.

Implement findall
3 participants