biopython icon indicating copy to clipboard operation
biopython copied to clipboard

Remove prefix remove suffix

Open Benedict-Carling opened this issue 5 years ago • 9 comments

  • [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.rst file, have run pre-commit locally, 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.rst and CONTRIB.rst as 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

Benedict-Carling avatar Nov 03 '20 11:11 Benedict-Carling

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%> (ø)

... and 299 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Nov 03 '20 16:11 codecov[bot]

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?

peterjc avatar Nov 03 '20 17:11 peterjc

@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.

mdehoon avatar Nov 04 '20 05:11 mdehoon

This will need updating now that bytes are used internally.

peterjc avatar Nov 27 '20 12:11 peterjc

@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)?

peterjc avatar Dec 03 '20 14:12 peterjc

I've rebased this and attempted to update it for the major Seq objects changes.

peterjc avatar Jun 08 '21 09:06 peterjc

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?

peterjc avatar Nov 02 '21 11:11 peterjc

Reopened, rebased, more tests, and now considers UnknownSeq explicitly.

peterjc avatar Jan 06 '22 12:01 peterjc

CI failed on Linux due to #3834

peterjc avatar Jan 06 '22 12:01 peterjc

This would need updating again since UnknownSeq was removed.

peterjc avatar May 19 '23 09:05 peterjc

@mdehoon could you review this please (recently updated to the master branch by me)?

peterjc avatar May 19 '23 11:05 peterjc

Thank you both, merging...

peterjc avatar May 22 '23 11:05 peterjc