Repository navigation
minimal meme support - #1734
minimal meme support #1734
Conversation
| record = meme.read(handle) | ||
| return record | ||
| elif format == "minimal": | ||
| from Bio.motifs import meme_minimal |
There was a problem hiding this comment.
Shouldn't this be
from Bio.motifs import minimal
aralap
left a comment
There was a problem hiding this comment.
Corrected "meme_minimal" to "minimal" in init.py
Codecov Report
@@ Coverage Diff @@
## master #1734 +/- ##
==========================================
+ Coverage 85.46% 85.55% +0.09%
==========================================
Files 301 302 +1
Lines 49300 49784 +484
==========================================
+ Hits 42133 42593 +460
- Misses 7167 7191 +24
Continue to review full report at Codecov.
|
|
|
||
| def read(handle): | ||
| """Parses the text output of the MEME program into a meme.Record object. | ||
| Example: |
There was a problem hiding this comment.
You need a blank line after the one-line summary of the docstring, see PEP257
| def read(handle): | ||
| """Parses the text output of the MEME program into a meme.Record object. | ||
| Example: | ||
| >>> from Bio.motifs import meme |
There was a problem hiding this comment.
I think you will need a blank line between "Example:" and the doctest, this will probably be triggering an RST validation failure in our TravisCI style checks.
| >>> from Bio.motifs import meme | ||
| >>> with open("meme.output.txt") as f: | ||
| ... record = meme.read(f) | ||
| >>> for motif in record: |
There was a problem hiding this comment.
Since I'm asking you to edit this docstring anyway, could you include the next line of three dots only (as you would see if typing this in at the Python prompt)?
| >>> for motif in record: | ||
| ... for instance in motif.instances: | ||
| ... print(instance.motif_name, instance.sequence_name, instance.strand, instance.pvalue) | ||
| """ |
There was a problem hiding this comment.
Again, cosmetic, but missing the tree dots to close the for loop.
| __read_background(record, handle) | ||
|
|
||
| while True: | ||
| for line in handle: |
There was a problem hiding this comment.
Your indentation looks wrong here - please use multiple of four spaces.
| else : | ||
| return record | ||
| name = line.split()[1] | ||
| motif_number +=1 |
There was a problem hiding this comment.
Please include white space before and after the += operator - this will be failing the flake8 style checks under TravisCI.
|
|
||
|
|
||
| class Record(list): | ||
| """A class for holding the results of a minimal MEME run. """ |
There was a problem hiding this comment.
Can you remove the trailing whitespace after the full stop please? This will be failing one of the flake8 docstring checks we run on TravisCI as part of our style checks.
|
|
||
| # Everything below is private | ||
|
|
||
| def __read_background(record, handle): |
There was a problem hiding this comment.
Why do you have two leading underscores, rather than just one?
There was a problem hiding this comment.
No particular reason, could go with just one.
|
Good news: Module owner @mdehoon is happy. Bad news: We need you to fix the style issues (indentation etc) reported by flake8 under TravisCI. If you want to run these checks on your own machine, please see our Also, before this gets merged, I would want to see at least one test case parsing a minimal MEME file. Finally, you would be welcome to include your name in the |
aralap
left a comment
There was a problem hiding this comment.
Corrected the style issues.
|
|
||
| # Everything below is private | ||
|
|
||
| def __read_background(record, handle): |
There was a problem hiding this comment.
No particular reason, could go with just one.
aralap
left a comment
There was a problem hiding this comment.
Corrected the style issues
| @@ -0,0 +1,158 @@ | |||
| # By Ariel Aptekmann 2017 | |||
| # Adapted from Bio.motifs 2008 by Bartek Wilczynski | |||
| # Adapted from Bio.MEME.Parser by Jason A. Hackney. All rights reserved. | |||
There was a problem hiding this comment.
What do you mean by Bio.MEME.Parser? There isn't such a namespace in Biopython (at least currently), so what code from Jason A. Hackney are you referring to?
(Depending on the answer to this comes more questions about licensing, including can we make this new file dual licensed under the 3-clause BSD license as well).
There was a problem hiding this comment.
I don't know if this header is still applicable to this code, the full parser with other functions was inspired in parts by this http://biopython.org/DIST/docs/api/Bio.motifs.mast-pysrc.html
Since this was already of Biopython, is there a conflict?
There was a problem hiding this comment.
Ah. That makes more sense now. Thanks.
If your code is heavily based on the older code, we're fine for using it in Biopython but only under our traditional license. However, it is a bit of a problem, as I don't think we've got Jason's permission to dual license their contributions yet: #898 (comment)
i.e. This may be a problem for Bio/motifs/mast.py, and by extension also for your new code.
If however all you've done is based the code structure/style on Bartek's to follow the style approach, I think you can remove this comment in the header and the licensing worry. Just use our new standard dual licensing standard header. Thanks.
|
You've still got lots of flake8 style violations reported on TravisCI - mainly in On AppVeyor for Windows testing we skip the style checks and go straight to the unit tests - and these are failing here: That isn't just a rounding error - it is seven orders of magnitude out. Any ideas? |
|
|
||
| def parse(handle, format): | ||
| """Parse an output file from a motif finding program. | ||
|
|
There was a problem hiding this comment.
Please restore this blank line, expected under PEP257, which is causing this style check failure:
Bio/motifs/__init__.py:26:1: D205 1 blank line required between summary line and description
| - TRANSFAC: TRANSFAC database file format | ||
| - pfm: JASPAR-style position-frequency matrix | ||
| - jaspar: JASPAR-style multiple PFM format | ||
| - sites: JASPAR-style sites file |
There was a problem hiding this comment.
The indentation change is breaking the RST validation,
Bio/motifs/__init__.py:29:1: RST301 Unexpected indentation.
Can you go back to the original indentation here please (while adding the bullet point about MINIMAL MEME);
aralap
left a comment
There was a problem hiding this comment.
Restored blank line on 28, and indentation on header of motifs/init.py
|
|
||
|
|
||
| def parse(handle, format): | ||
|
|
There was a problem hiding this comment.
That's the wrong place for the blank line. It should be inside the docstring,
def parse(handle, format):
"""Parse an output file from a motif finding program.
Currently supported formats (case is ignored):
...There was a problem hiding this comment.
This is why you still have the D205 error, and a new D201 error. Also it seems this is not really a blank line, but has some spaces - triggering the W293 warning as well:
Bio/motifs/__init__.py:26:1: D205 1 blank line required between summary line and description
Bio/motifs/__init__.py:26:1: D201 No blank lines allowed before function docstring
Bio/motifs/__init__.py:27:1: W293 blank line contains whitespace
|
You are making progress :) AppVeyor is now failing here: Meanwhile on TravisCI, there are still style issues: I recommend trying out the command line tool See also https://github.com/biopython/biopython/blob/master/CONTRIBUTING.rst for running flake8 to do the style checks on your own computer - it is much easier that waiting for TravisCI to do it. |
|
Excellent, the automated tests on Windows now pass via AppVeyor, and the |
| def parse(handle, format): | ||
| """Parse an output file from a motif finding program. | ||
| """ | ||
| Parse an output file from a motif finding program. |
There was a problem hiding this comment.
Please leave the triple-quote and the first line of the docstring on the same line:
def parse(handle, format):
"""Parse an output file from a motif finding program.| - TRANSFAC: TRANSFAC database file format | ||
| - pfm: JASPAR-style position-frequency matrix | ||
| - jaspar: JASPAR-style multiple PFM format | ||
| - sites: JASPAR-style sites file |
There was a problem hiding this comment.
You've not yet fixed the indentation - this is breaking the bullet point RST rendering, at least as rendered on rst.nija.org which is an easy to use online renderer.
aralap
left a comment
There was a problem hiding this comment.
Changed the comparison on line 1488 of test_motifs.py, to a multiple comparison not sure why it was giving an error. Hopefully this has no error (on local test, i had none )
|
@aralap Do you really need the precision of 17 digits? I.e. can't you do some rounding? I think there is often a chance that floats have small rounding errors. They are very small, but if you compare 17 digits after the decimal separator there is a good chance to run into problems. |
|
|
||
|
|
||
| def __read_lpm(line, handle): | ||
| counts = [[], [], [], []] |
There was a problem hiding this comment.
The indentation looks strange here - it would normally be four spaces.
| if not line.startswith('ALPHABET'): | ||
| raise ValueError("Line does not start with 'ALPHABET':\n%s" % line) | ||
| line = line.strip() | ||
| line = line.replace('ALPHABET= ', '') |
There was a problem hiding this comment.
You could shorten these two lines to just one,
line = line.strip().replace('ALPHABET= ', '')| break | ||
| else: | ||
| raise ValueError("Unexpected end of stream: Expected to find line starting with 'ALPHABET'") | ||
| if not line.startswith('ALPHABET'): |
There was a problem hiding this comment.
Given the check later for "ALPHABET=" should the equals sign always be present?
There was a problem hiding this comment.
Changed it for 'ALPHABET= '.
|
Thanks @MarkusPiotrowski and @peterjc , i think it is acceptable now. |
|
I think we'll need to do a git rebase due to the merge conflicts, I'll try that now... |
Directs to new minimal parser. Includes tests.
|
AppVeyor got stuck, re-starting |
|
Merged, thank you everyone who worked on this - especially @aralap |
Original authors Bartek Wilczynski (CVS username bartek, on GitHub as @barwil) and Jeff Chang (CVS username jchang, on GitHub as @jefftc) and other contributors since have agreed: - Antony Lee (@anntzer) #898 (comment) - Ariel Aptekmann (@aralap) #1734 - bartek (@barwil) http://mailman.open-bio.org/pipermail/biopython/2018-August/016533.html - Bertrand Néron (@bneron) #898 (comment) - Wibowo Arindrarto (@bow) #898 (comment) - Christian Brueffer (@cbrueffer) #898 (comment) - Gert Hulselmans (@ghuls) #898 (comment) - Jared Andrews (@j-andrews7) #898 (comment) - Jeff Chang (@jefftc) #898 (comment) - Michiel de Hoon (@mdehoon) #898 (comment) - Peter Cock (@peterjc) #898 (comment) - Zaid Ur-Rehman (@zaidurrehman) #867
Original authors Bartek Wilczynski and Michiel de Hoon and other contributors tracked by version control have all agreed: - Adhemar Zerlotini (@azneto) biopython#1412 (comment) - Andrey Raspopov (@Andrey-Raspopov) biopython#2444 - Antony Lee (@anntzer) biopython#898 (comment) - Ariel Aptekmann (@aralap) biopython#1734 - Bartek Wilczynski (@barwil) http://mailman.open-bio.org/pipermail/biopython/2018-August/016533.html - Carlos Pena (@carlosp420) biopython#898 (comment) - Chris Rands (@chris-rands) biopython#1301 - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Gert Hulselmans (@ghuls) biopython#898 (comment) - Lenna Peterson (@lennax) biopython#898 (comment) - Michiel de Hoon (@mdehoon) biopython#898 (comment) - @morrme biopython#1172 (comment) - Nader Morshed (@naderm) biopython#898 (comment) - Nick Negretti (@nimne) biopython#1768 (comment) - Nicolas Fontrodona (@NFontrodona) biopython#1407 - Peter Cock (@peterjc) biopython#898 (comment) - Sergio Valqui (@svalqui) biopython#1749 - Sujan Dulal (@Dsujan) biopython#2430 - Travis Wrightsman (@twrightsman) biopython#898 (comment) - Victor Lin (@victorlin) biopython#1986 - Wibowo Arindrarto (@bow) biopython#898 (comment)
Original authors Bartek Wilczynski and Michiel de Hoon and other contributors tracked by version control have all agreed: - Adhemar Zerlotini (@azneto) #1412 (comment) - Andrey Raspopov (@Andrey-Raspopov) #2444 - Antony Lee (@anntzer) #898 (comment) - Ariel Aptekmann (@aralap) #1734 - Bartek Wilczynski (@barwil) http://mailman.open-bio.org/pipermail/biopython/2018-August/016533.html - Carlos Pena (@carlosp420) #898 (comment) - Chris Rands (@chris-rands) #1301 - Christian Brueffer (@cbrueffer) #898 (comment) - Gert Hulselmans (@ghuls) #898 (comment) - Lenna Peterson (@lennax) #898 (comment) - Michiel de Hoon (@mdehoon) #898 (comment) - @morrme #1172 (comment) - Nader Morshed (@naderm) #898 (comment) - Nick Negretti (@nimne) #1768 (comment) - Nicolas Fontrodona (@NFontrodona) #1407 - Peter Cock (@peterjc) #898 (comment) - Sergio Valqui (@svalqui) #1749 - Sujan Dulal (@Dsujan) #2430 - Travis Wrightsman (@twrightsman) #898 (comment) - Victor Lin (@victorlin) #1986 - Wibowo Arindrarto (@bow) #898 (comment)
This pull request addresses issue #...
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.)