Repository navigation
Fixes for mid-line comments and multiline text blocks in mmCIF files - #1445
Conversation
This commit fixes the MMCIF2Dict class to be more in line with the CIF spec. Semicolon-delimited blocks are now parsed correctly: leading whitespace is preserved, as are all newlines except the final.
This commit allows mid-line (e.g. `^foo bar # comment`) comments in mmCIF files rather than just beginning-of-line comments (`^# comment`).
Codecov Report
@@ Coverage Diff @@
## master #1445 +/- ##
==========================================
- Coverage 84.78% 83.41% -1.38%
==========================================
Files 321 320 -1
Lines 49270 49224 -46
==========================================
- Hits 41775 41058 -717
- Misses 7495 8166 +671
Continue to review full report at Codecov.
|
|
|
||
| from Bio.PDB.MMCIF2Dict import MMCIF2Dict | ||
|
|
||
| import io |
There was a problem hiding this comment.
Using io.StringIO makes Python 2 and 3 at once tricky, which would explain why you needed the explicit unicode strings later.
Why we normally use from Bio._py3k import StringIO which does from StringIO import StringIO under Python 2 or from io import StringIO under Python 3.
Either was seems fine (and the difference only matters under Python 2 anyway which will eventually go away).
There was a problem hiding this comment.
Ah-ha! I thought there might be something like that available, but missed Bio._py3k. I don't develop on Python 2, but the build bot did its job nicely and let me know there was a problem. I don't mind switching to Bio._py3k if you consider that more idiomatic for biopython.
There was a problem hiding this comment.
Sure - my guess is you can use from Bio._py3k import StringIO and remove the u prefixes.
Note that in general I would recommend using the third-party library six for this kind of compatibility shim, but we wanted to keep the Biopython dependencies to a minimum and have a few other more project specific hacks under Bio._py3k anyway.
|
I'd like @jgreener64 to take a look at the code, but from a technical perspective it looks nicely done with tests. Good job. Would you like to add yourself to the Note the names are sorted alphabetically (see comment at top of the contributors file, this is checked by TravisCI). Alternatively I can do that by adding a commit to your branch. |
|
Ah - I missed you were already in the |
|
Thanks Peter. I'm already listed correctly in |
|
Having looked at the code I am happy with it, nice one @StefansM. |
|
Thank you both :) |
Original author Thomas Hamelryck and all the contributors since as tracked with version control have agreed: - Brian Osborne (@bosborne) biopython#898 (comment) - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Chris Rands (@chris-rands) biopython#1301 - Eric Talevich (@etal) biopython#898 (comment) - Fábio Madeira (@biomadeira) biopython#898 (comment) - Francesco Gastaldello (@Gasta88) biopython#1063 - Joe Greener (@jgreener64) biopython#1393 - Lenna Peterson (@lennax) biopython#898 (comment) - Maximilian Peters (@Ashafix) biopython#898 (comment) - Michiel de Hoon (@mdehoon) biopython#898 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Sunhwan Jo (@sunhwan) biopython#898 (comment) - Sergei Lebedev (@superbobry) biopython#898 (comment) - Stefans Mezulis (@StefansM) biopython#1445 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
Original author Lenna X. Peterson (and Thomas Hamelryck on whose Bio.PDB tests this was in part based), and all the contributors since as tracked with version control have agreed: - Carlos Pena (@carlosp420) biopython#898 (comment) - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Fábio Madeira (@biomadeira) biopython#898 (comment) - Francesco Gastaldello (@Gasta88) biopython#1063 - João Rodrigues (@JoaoRodrigues) biopython#898 (comment) - Lenna Peterson (@lennax) biopython#898 (comment) - Michiel de Hoon (@mdehoon) biopython#898 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Konstantin Vdovkin (@rtf-const) biopython#1767 - Stefans Mezulis (@StefansM) biopython#1445 - Sunhwan Jo (@sunhwan) biopython#898 (comment) - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
Original author Thomas Hamelryck and all the contributors since as tracked with version control have agreed: - Brian Osborne (@bosborne) #898 (comment) - Christian Brueffer (@cbrueffer) #898 (comment) - Chris Rands (@chris-rands) #1301 - Eric Talevich (@etal) #898 (comment) - Fábio Madeira (@biomadeira) #898 (comment) - Francesco Gastaldello (@Gasta88) #1063 - Joe Greener (@jgreener64) #1393 - Lenna Peterson (@lennax) #898 (comment) - Maximilian Peters (@Ashafix) #898 (comment) - Michiel de Hoon (@mdehoon) #898 (comment) - Peter Cock (@peterjc) #898 (comment) - Sunhwan Jo (@sunhwan) #898 (comment) - Sergei Lebedev (@superbobry) #898 (comment) - Stefans Mezulis (@StefansM) #1445 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
Original author Lenna X. Peterson (and Thomas Hamelryck on whose Bio.PDB tests this was in part based), and all the contributors since as tracked with version control have agreed: - Carlos Pena (@carlosp420) #898 (comment) - Christian Brueffer (@cbrueffer) #898 (comment) - Fábio Madeira (@biomadeira) #898 (comment) - Francesco Gastaldello (@Gasta88) #1063 - João Rodrigues (@JoaoRodrigues) #898 (comment) - Lenna Peterson (@lennax) #898 (comment) - Michiel de Hoon (@mdehoon) #898 (comment) - Peter Cock (@peterjc) #898 (comment) - Konstantin Vdovkin (@rtf-const) #1767 - Stefans Mezulis (@StefansM) #1445 - Sunhwan Jo (@sunhwan) #898 (comment) - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
Original authors Thomas Hamelryck and Eric Talevich (for the unittest conversion), and the contributors as tracked with version control have agreed: - Andrew Guy (@andrewguy) biopython#2212 (comment) - Ben Reynwar (@benreynwar) biopython#898 (comment) - Bernhard C. Thiel (@Bernhard10) biopython#968 - Carlos Pena (@carlosp420) biopython#898 (comment) - Chris Rands (@chris-rands) biopython#1301 - Christian Brueffer (@cbrueffer) biopython#898 (comment) - Eric Talevich (@etal) biopython#898 (comment) - Francesco Gastaldello (@Gasta88) biopython#1063 - Gokcen Eraslan (@gokceneraslan) biopython#898 (comment) - Jack Twilley (@mathuin) biopython#1049 (comment) - Jeroen Van Goey (@BioGeek) biopython#898 (comment) - Joe Greener (@jgreener64) biopython#1393 - Joerg Schaarschmidt (@schaarj) biopython#1567 - João Rodrigues (@JoaoRodrigues) biopython#898 (comment) - Kian Ho (@kianho) biopython#898 (comment) - Kristian Davidsen (@krdav) biopython#898 (comment) - Kristian Rother (@krother) biopython#898 (comment) - Lenna Peterson (@lennax) biopython#898 (comment) - Markus Piotrowski (@MarkusPiotrowski) biopython#898 (comment) - Milind Luthra (@milindl) biopython#1020 - Nick Negretti (@nimne) biopython#1768 (comment) - Peter Cock (@peterjc) biopython#898 (comment) - Rasmus Fonseca (@RasmusFonseca) biopython#1171 (comment) - Siong Kong (@siongkong) biopython#1516 - Stefans Mezulis (@StefansM) biopython#1445 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
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 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)
Original authors Thomas Hamelryck and Eric Talevich (for the unittest conversion), and the contributors as tracked with version control have agreed: - Andrew Guy (@andrewguy) #2212 (comment) - Ben Reynwar (@benreynwar) #898 (comment) - Bernhard C. Thiel (@Bernhard10) #968 - Carlos Pena (@carlosp420) #898 (comment) - Chris Rands (@chris-rands) #1301 - Christian Brueffer (@cbrueffer) #898 (comment) - Eric Talevich (@etal) #898 (comment) - Francesco Gastaldello (@Gasta88) #1063 - Gokcen Eraslan (@gokceneraslan) #898 (comment) - Jack Twilley (@mathuin) #1049 (comment) - Jeroen Van Goey (@BioGeek) #898 (comment) - Joe Greener (@jgreener64) #1393 - Joerg Schaarschmidt (@schaarj) #1567 - João Rodrigues (@JoaoRodrigues) #898 (comment) - Kian Ho (@kianho) #898 (comment) - Kristian Davidsen (@krdav) #898 (comment) - Kristian Rother (@krother) #898 (comment) - Lenna Peterson (@lennax) #898 (comment) - Markus Piotrowski (@MarkusPiotrowski) #898 (comment) - Milind Luthra (@milindl) #1020 - Nick Negretti (@nimne) #1768 (comment) - Peter Cock (@peterjc) #898 (comment) - Rasmus Fonseca (@RasmusFonseca) #1171 (comment) - Siong Kong (@siongkong) #1516 - Stefans Mezulis (@StefansM) #1445 - Thomas Hamelryck (CVS username nisse) https://mailman.open-bio.org/pipermail/biopython/2018-September/016546.html
This pull request addresses issue #1441.
The changes to lines 36–41 of
test_PDB_MMCIF2Dict.pywere necessary to correct the test. The field_struct_ref.pdbx_seq_one_letter_codeshould include the newlines, but the test previously accepted the concatenated result as correct.The test could do with some cleanup (line 35 is over 6,000 characters long), but that doesn't fall within the scope of this pull request.
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I am happy to be thanked by name in the
NEWS.rstandCONTRIB.rstfiles.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.