Skip to content

Small fix to gc skew - #1131

Merged
peterjc merged 7 commits into
biopython:masterfrom
sachalau:small_fix_GC_skew
Apr 7, 2017
Merged

peterjc merged 7 commits into
biopython:masterfrom
sachalau:small_fix_GC_skew

Conversation

@sachalau

@sachalau sachalau commented Apr 4, 2017 •

Copy link
Copy Markdown

In reference to issue #1107 I have add a check whether G and C are in same quantity and return 0 if so. And a unittest on a window with no G or C.

@peterjc

peterjc commented Apr 4, 2017

Copy link
Copy Markdown
Member

When g == c, the existing code didn't have any problem - it would already return ``0`.

I was expecting you to check if g + c == 0 to avoid a division by zero error?

@peterjc

peterjc commented Apr 4, 2017

Copy link
Copy Markdown
Member

One of the things we check with TravisCI is Python style, and that is failing:

$ flake8 Bio/
Bio/SeqUtils/__init__.py:97:1: W293 blank line contains whitespace
Bio/SeqUtils/__init__.py:99:1: W293 blank line contains whitespace

You can install flake8 using pip install flake8.

@peterjc

peterjc commented Apr 4, 2017 •

Copy link
Copy Markdown
Member

You'll need to import GC_skew at the top of test_SeqUtils.py in order to fix this error:

======================================================================
ERROR: test_GC_skew (test_SeqUtils.SeqUtilsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/biopython/biopython/Tests/test_SeqUtils.py", line 145, in test_GC_skew
    self.assertEqual(GC_skew(seq)[0], 0)
NameError: global name 'GC_skew' is not defined
----------------------------------------------------------------------

@sachalau

sachalau commented Apr 4, 2017 •

Copy link
Copy Markdown
Author

Yes sorry I got confused in my branches and I forgot the include in the one I sent.

I'll check the Python styles ASAP.

Regarding my fix, indeed it worked when g == c but I was just thinking that this would save one operation for the cases where G and Cs are present and equal. I could check g + c == 0 instead but I think the count function never returns negative values so my fix should be safe no ?

@peterjc

peterjc commented Apr 4, 2017

Copy link
Copy Markdown
Member

Yes, the counts should never be negative.

How about something like this?:

    try:
        skew = (g - c) / float(g + c)
    except ZeroDivisionError:
        skew = 0.0

@sachalau

sachalau commented Apr 4, 2017

Copy link
Copy Markdown
Author

Okay then :) It was also the way this was done for the GC function in the same file, I should have checked it before, sorry.

@codecov

codecov Bot commented Apr 4, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #1131 into master will increase coverage by 0.89%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1131      +/-   ##
==========================================
+ Coverage   78.69%   79.58%   +0.89%     
==========================================
  Files         322      322              
  Lines       51716    51004     -712     
==========================================
- Hits        40696    40594     -102     
+ Misses      11020    10410     -610
Impacted Files Coverage Δ
Bio/SeqUtils/__init__.py 58.9% <100%> (+4.56%) ⬆️
Bio/GA/Evolver.py 54.54% <0%> (-18.19%) ⬇️
Bio/DocSQL.py 38.62% <0%> (-0.16%) ⬇️
Bio/UniProt/GOA.py 26.77% <0%> (-0.11%) ⬇️
Bio/Pathway/Rep/Graph.py 37.79% <0%> (-0.1%) ⬇️
Bio/SeqIO/AbiIO.py 95.94% <0%> (-0.06%) ⬇️
Bio/NMR/xpktools.py 40.49% <0%> (+0.17%) ⬆️
Bio/Seq.py 98.35% <0%> (+0.17%) ⬆️
Bio/codonalign/codonseq.py 87.44% <0%> (+0.21%) ⬆️
Bio/GenBank/__init__.py 92.24% <0%> (+0.24%) ⬆️
... and 102 more

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 b2a52db...eb43c9d. Read the comment docs.

@peterjc

peterjc commented Apr 4, 2017

Copy link
Copy Markdown
Member

(The coverage report is a bit odd, but I was tinkering with coverage settings this afternoon)

Other than the docstring this looks good:

If the numbers of G and C are equal, returns 0. Fixes the issue when the window is devoid of G/Cs.

Something like this?:

If a window contains no G or C bases, a skew of zero is used.

Are you happy to dual licence your contributions under both the Biopython License Agreement AND the BSD 3-Clause License? See #898.

Also, are you happy to be thanked by name in the NEWS.rst and CONTRIB.rst files?

@sachalau

sachalau commented Apr 5, 2017

Copy link
Copy Markdown
Author

Yes I agree to all of this :)

@peterjc

peterjc commented Apr 7, 2017

Copy link
Copy Markdown
Member

I emailed your GMail account a few days ago: Would you prefer to be acknowledged under your real name, or just as Cashalow?

@peterjc
peterjc merged commit b62d09d into biopython:master Apr 7, 2017
peterjc added a commit that referenced this pull request Apr 7, 2017
See pull request #1131 for issue #1107.
@peterjc

peterjc commented Apr 7, 2017

Copy link
Copy Markdown
Member

Thank you - merged as the first pull request for what will be Biopython 1.70.

@sachalau
sachalau deleted the small_fix_GC_skew branch April 10, 2017 12:21
MarkusPiotrowski pushed a commit to MarkusPiotrowski/biopython that referenced this pull request Oct 31, 2017
MarkusPiotrowski pushed a commit to MarkusPiotrowski/biopython that referenced this pull request Oct 31, 2017
@peterjc

peterjc commented Sep 20, 2018

Copy link
Copy Markdown
Member

@sachalau Hi again Sacha. Are you happy to dual licence your contributions under both the Biopython License Agreement AND the BSD 3-Clause License? See #898. Thank you.

@sachalau

sachalau commented Sep 20, 2018 via email

Copy link
Copy Markdown
Author

@peterjc

peterjc commented Sep 20, 2018

Copy link
Copy Markdown
Member

Thank you - We still need one more author's agreement before we can dual license Bio/SeqUtils/__init__.py but this is progress.

peterjc added a commit to peterjc/biopython that referenced this pull request Sep 21, 2018
peterjc added a commit to peterjc/biopython that referenced this pull request Sep 21, 2018
The original authors back when this file was Bio/sequtils.py
(Thomas Sicheritz-Ponten and Cecilia Alsmark) and all the
recorded contributors since have agreed:

 - Anders Pitman (@anderspitman)
   biopython#898 (comment)
 - Carlos Pena (@carlosp420)
   biopython#898 (comment)
 - Cecilia Alsmark
   http://mailman.open-bio.org/pipermail/biopython/2018-September/016542.html
 - Christian Brueffer (@cbrueffer)
   biopython#898 (comment)
 - Brad Chapman (@chapmanb)
   http://mailman.open-bio.org/pipermail/biopython-dev/2013-July/019903.html
 - Connor McCoy (@cmccoy)
   biopython#898 (comment)
 - Jeff Chang (@jefftc)
   biopython#898 (comment)
 - Lenna Peterson (@lennax)
   biopython#898 (comment)
 - Markus Piotrowski (@MarkusPiotrowski)
   biopython#898 (comment)
 - Michiel de Hoon (@mdehoon)
   biopython#898 (comment)
 - Peter Cock (@peterjc)
   biopython#898 (comment)
 - Cashalow (@sachalau)
   biopython#1131 (comment)
 - Sergei Lebedev (@superbobry)
   biopython#898 (comment)
 - Thomas Sicheritz-Ponten
   http://mailman.open-bio.org/pipermail/biopython/2018-April/016427.html
 - Travis Wrightsman (@twrightsman)
   biopython#898 (comment)
 - Wibowo Arindrarto (@bow)
   biopython#898 (comment)
peterjc added a commit that referenced this pull request Sep 24, 2018
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.

2 participants