Repository navigation
fixed doctest for Bio.SubsMat - #2042
Conversation
|
Since you are working on this, could you fix up the reStructuredText markup too please? e.g. http://rst.ninjs.org can be used online. Things like bullet point lists for the four bases etc. |
| >>> ftab = FreqTable.read_count(f_count) | ||
| >>> nucleobases = list(ftab.keys()) | ||
| >>> nucleobases.sort() | ||
| >>> for nb in nucleobases: |
There was a problem hiding this comment.
How about replacing those three lines with:
>>> for nb in sorted(ftab):If we're lucky this will also fix the Python 2 problem which I have not looked closely at.
|
The test is breaking on Python 2, unclear why - that is worth exploring. I noted an alternative style for that bit of code anyway which might fix the test. |
|
should work under Python 2 and Python 3. |
Codecov Report
@@ Coverage Diff @@
## master #2042 +/- ##
=========================================
- Coverage 84.92% 84.62% -0.3%
=========================================
Files 315 315
Lines 50543 50541 -2
=========================================
- Hits 42923 42772 -151
- Misses 7620 7769 +149
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #2042 +/- ##
=======================================
Coverage 84.92% 84.92%
=======================================
Files 315 315
Lines 50545 50545
=======================================
Hits 42924 42924
Misses 7621 7621
Continue to review full report at Codecov.
|
|
Thank you for the Tips, I have updated the code, it runs on Python3; in terms of the reStructureText no sure if that's all what is needed, let me know. |
|
Regarding the RST markup, copy-and-paste the main docstring, i.e. this: into http://rst.ninjs.org/ or your favourite RST editor (the four space indentation does not seem to matter). Notice that the functions and attribute lists are not displaying clearly. Again, bullet points would seem simplest - see e.g. Bio/SeqRecord.py (We've talked about moving towards the NumPy docstring style, but that is a bigger effort) You can see how it look as of our last release here, not great: http://biopython.org/DIST/docs/api/Bio.SubsMat.FreqTable-module.html |
|
Regarding RST markup: This is an example for a reStructured docstring (you can use it as it is, just copy&paste): A class to handle frequency tables or letter count files.
Example files for a DNA alphabet:
A count file (whitespace separated)::
A 50
C 37
G 23
T 58
The same info as a frequency file::
A 0.2976
C 0.2202
G 0.1369
T 0.3452
Functions:
:read_count(f): read a count file from stream f. Then convert to
frequencies
:read_freq(f): read a frequency data file from stream f. Of course, we then
don't have the counts, but it is usually the letter frquencies
which are interesting.
Methods:
(all internal)
Attributes:
:alphabet: The IUPAC alphabet set (or any other) whose letters you are using.
Common sets are: ``IUPAC.protein`` (20-letter protein), ``IUPAC.unambiguous_dna``
(4-letter DNA). See ``Bio.Alphabet`` for more.
:data: Frequency dictionary.
:count: Count dictionary. Empty if no counts are provided.
Example of use:
>>> import io
>>> from Bio.SubsMat import FreqTable
>>> f_count = io.StringIO(u"A 50\nC 37\nG 23\nT 58")
>>> ftab = FreqTable.read_count(f_count)
>>> for nb in sorted(ftab):
... print("%s %0.4f" %(nb, ftab[nb]))
...
A 0.2976
C 0.2202
G 0.1369
T 0.3452
|
|
Thank you for that, that makes it more clear, amended. |
|
|
||
|
|
||
| def read_freq(f): | ||
| """Read a frequency data file f and load values to the Frequency Table""" |
There was a problem hiding this comment.
Missing full stop,
$ flake8 Bio/
Bio/SubsMat/FreqTable.py:102:1: D400 First line should end with a period
There was a problem hiding this comment.
flake has been a bit odd, not picking the missing DocStrings at first, so I haven't used on this file; anyway full stop added.
6ecff5d to
31b5c72
Compare
|
Rebased to fix the merge conflict in |
|
Thank you both, nice job 👍 |
Also updated the RST markup.
This pull request addresses issue #1902
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile and understand that AppVeyor andTravisCI will be used to confirm the Biopython unit tests and
flake8stylechecks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)