Remove prefix remove suffix
-
[X] I hereby agree to dual licence this and any previous contributions under both the Biopython License Agreement AND the BSD 3-Clause License.
-
[X] I have read the
CONTRIBUTING.rstfile, have runpre-commitlocally, and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit tests and style checks pass with these changes. -
[X] I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listed already, or do not wish to be listed. (This acknowledgement is optional.)
Closes #3299
Adds new python 3.9 str functions to Seq object, removeprefix and remove suffix
New Functionality
>>> from Bio.Seq import Seq
>>> my_seq = Seq("ATGGTGTGTGT")
>>> my_seq
Seq('ATGGTGTGTGT')
>>> my_seq.removeprefix('ATG')
Seq('GTGTGTGT')
New functions can also take argument at a Seq Object
>>> from Bio.Seq import Seq
>>> my_seq = Seq("GTGTGTGTTAG")
>>> my_seq
Seq('GTGTGTGTTAG')
>>> stop_codon = Seq("TAG")
>>> my_seq.removesuffix(stop_codon)
Seq('GTGTGTGT')
Unit Tests are added to confirm this functionality
Thanks for looking at my first pull request here 👋 im looking forward to contributing more, Benedict
Codecov Report
Patch coverage: 55.17% and project coverage change: +82.31 :tada:
Comparison is base (
9fa14fa) 0.00% compared to head (5a4b731) 82.31%.
:exclamation: Current head 5a4b731 differs from pull request most recent head 9255ea4. Consider uploading reports for the commit 9255ea4 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #3335 +/- ##
===========================================
+ Coverage 0 82.31% +82.31%
===========================================
Files 0 300 +300
Lines 0 50796 +50796
===========================================
+ Hits 0 41811 +41811
- Misses 0 8985 +8985
| Impacted Files | Coverage Δ | |
|---|---|---|
| Bio/Seq.py | 92.82% <55.17%> (ø) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
One remaining small tweak aside (remove two now redundant calls to str(...), see code comments), this looks good to me.
@mdehoon could you review, and can we merge this before #3333?
@mdehoon could you review, and can we merge this before #3333?
This code will change after #3333 gets in, so it makes more sense to do #3333 first.
This will need updating now that bytes are used internally.
@Benedict-Carling do you need help updating this for the recent bytes changes? Or should one of us update the pull request (we'll still credit you of course)?
I've rebased this and attempted to update it for the major Seq objects changes.
TravisCI was failing (some kind of time out), but in any case we've since migrated to GitHub Actions.
Any reason not to rebase this and see how the tests look now?
Reopened, rebased, more tests, and now considers UnknownSeq explicitly.
CI failed on Linux due to #3834
This would need updating again since UnknownSeq was removed.
@mdehoon could you review this please (recently updated to the master branch by me)?
Thank you both, merging...