Repository navigation
Consistent error messages for empty file parsing in SeqIO - #1845
Conversation
|
Does it make sense to raise a similar error for the other formats to maintain consistency? |
| from Bio.File import UndoHandle | ||
| undo_handle = UndoHandle(handle) | ||
| firstline = undo_handle.peekline() | ||
| if undo_handle.readlines() == []: |
There was a problem hiding this comment.
Probably you should use if not line: here?
There was a problem hiding this comment.
Yeah I ended up using if peekline() == '' and it seems to work perfectly.
|
|
||
| buffer.seek(0) | ||
| mmcif_dict = MMCIF2Dict(buffer) | ||
| if mmcif_dict == {}: |
There was a problem hiding this comment.
Can you check if the buffer object is empty directly? You could then do this two lines up, before ever calling MMCIF2Dict.
| skip_parsing_errors = True --> if parsing errors are found, skip to next entry | ||
| """ | ||
| # check if file is empty | ||
| from Bio.File import UndoHandle |
There was a problem hiding this comment.
Can you do this without using the UndoHandle?
|
It looks like AppVeyor got confused, I've restarted that. @etal - do the PDB SeqIO changes look fine to you too? If so, I think this is ready for a squash-merge. |
|
@DevangThakkar you are also welcome to add your name to the |
Codecov Report
@@ Coverage Diff @@
## master #1845 +/- ##
==========================================
+ Coverage 82.43% 85.45% +3.02%
==========================================
Files 300 301 +1
Lines 49264 49314 +50
==========================================
+ Hits 40609 42142 +1533
+ Misses 8655 7172 -1483
Continue to review full report at Codecov.
|
|
AppVeyor looks fine - it just got stuck after the tests trying to update the coverage results. If there are no objections, I think this can be merged at the end of the week. Thank you! |
|
Thank you for your help! I'm looking forward to contributing more to biopython. |
raised 'Empty file.' error messages on encountering an empty file instead of the current non standard errors. Formats affected are as follows: cif-atom, pdb-atom, uniprot-xml.
|
I'm going to have to rebase this to deal with a trivial merge conflict in the NEWS.rst file (another name was added this morning), and then apply this pull request... |
7450aac to
b8e12fc
Compare
|
Merged, thank you Devang 👍 |
Original author Andrea Pierleoni and contributors since as tracked by version control have all agreed: - Adhemar Zerlotini (@azneto) biopython#1412 (comment) - Andrea Pierleoni (@apierleoni) biopython#898 (comment) - Carlos Pena (@carlosp420) biopython#898 (comment) - Chris Rands (@chris-rands) biopython#1301 - chrismit (@Chris7) biopython#898 (comment) - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Devang Thakkar (@DevangThakkar) biopython#1845 - Francesco Gastaldello (@Gasta88) biopython#1063 - @morrme biopython#1172 (comment) - Oscar G. Garcia (@OscarMaestre) biopython#898 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Uri Laserson (@laserson) biopython#898 (comment) - Vincent Davis (@vincentdavis) biopython#898 (comment)
Original author Eric Talevich and the contributors since as tracked with version control have all agreed: - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Devang Thakkar (@DevangThakkar) biopython#1845 - Eric Talevich (@etal) biopython#898 (comment) - Francesco Gastaldello (@Gasta88) biopython#1063 - Kiran Mukhyala (@mukhyala) biopython#2215 - Matsuyuki Shirota (@matsu3shiro) biopython#2244 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Stefans Mezulis (@StefansM) biopython#1445 - Wayne Decatur (@fomightez) biopython#898 (comment) - Wibowo Arindrarto (@bow) biopython#898 (comment)
Original author Andrea Pierleoni and contributors since as tracked by version control have all agreed: - Adhemar Zerlotini (@azneto) #1412 (comment) - Andrea Pierleoni (@apierleoni) #898 (comment) - Carlos Pena (@carlosp420) #898 (comment) - Chris Rands (@chris-rands) #1301 - chrismit (@Chris7) #898 (comment) - Christian Brueffer (@cbrueffer) #898 (comment) - Devang Thakkar (@DevangThakkar) #1845 - Francesco Gastaldello (@Gasta88) #1063 - @morrme #1172 (comment) - Oscar G. Garcia (@OscarMaestre) #898 (comment) - Peter Cock (@peterjc) #898 (comment) - Uri Laserson (@laserson) #898 (comment) - Vincent Davis (@vincentdavis) #898 (comment)
Original author Eric Talevich and the contributors since as tracked with version control have all agreed: - Christian Brueffer (@cbrueffer) #898 (comment) - Devang Thakkar (@DevangThakkar) #1845 - Eric Talevich (@etal) #898 (comment) - Francesco Gastaldello (@Gasta88) #1063 - Kiran Mukhyala (@mukhyala) #2215 - Matsuyuki Shirota (@matsu3shiro) #2244 (comment) - Peter Cock (@peterjc) #898 (comment) - Stefans Mezulis (@StefansM) #1445 - Wayne Decatur (@fomightez) #898 (comment) - Wibowo Arindrarto (@bow) #898 (comment)
This pull request addresses Issue #1838. Current SeqIO code does not optimally handle empty files for certain formats. This pull request raises a standard
ValueError("Empty file.")error message on encountering an empty file instead of the current non standard errors. Formats worked on are asfollows: cif-atom, pdb-atom, uniprot-xml. The other formats either do not print anything thing or raise a
ValueError("Empty file.")error message.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.)