Skip to content

Fixes for mid-line comments and multiline text blocks in mmCIF files - #1445

Merged
peterjc merged 4 commits into
biopython:masterfrom
StefansM:mmcif-fixes
Nov 9, 2017
Merged

peterjc merged 4 commits into
biopython:masterfrom
StefansM:mmcif-fixes

Conversation

@StefansM

@StefansM StefansM commented Nov 7, 2017

Copy link
Copy Markdown
Contributor

This pull request addresses issue #1441.

The changes to lines 36–41 of test_PDB_MMCIF2Dict.py were necessary to correct the test. The field _struct_ref.pdbx_seq_one_letter_code should 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.rst and
CONTRIB.rst files.

I have read the CONTRIBUTING.rst file and understand that AppVeyor and
TravisCI will be used to confirm the Biopython unit tests and flake8 style
checks pass with these changes.

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`).
@StefansM StefansM changed the title Mmcif fixes Fixes for mid-line comments and multiline text blocks in mmCIF files Nov 7, 2017
@codecov

codecov Bot commented Nov 7, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #1445 into master will decrease coverage by 1.37%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
Bio/PDB/MMCIF2Dict.py 100% <100%> (ø) ⬆️
Bio/Phylo/CDAOIO.py 5.42% <0%> (-80.1%) ⬇️
Bio/PDB/mmtf/__init__.py 29.41% <0%> (-58.83%) ⬇️
Bio/Phylo/CDAO.py 42.85% <0%> (-57.15%) ⬇️
Bio/PopGen/GenePop/EasyController.py 22.68% <0%> (-54.64%) ⬇️
Bio/PopGen/GenePop/Controller.py 10.42% <0%> (-54.25%) ⬇️
Bio/DocSQL.py 7.58% <0%> (-31.04%) ⬇️
Bio/Wise/__init__.py 50.87% <0%> (-29.83%) ⬇️
Bio/Phylo/Applications/_Phyml.py 71.42% <0%> (-28.58%) ⬇️
Bio/Wise/psw.py 48.05% <0%> (-22.08%) ⬇️
... and 18 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 d465649...1c88c81. Read the comment docs.


from Bio.PDB.MMCIF2Dict import MMCIF2Dict

import io

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@peterjc

peterjc commented Nov 8, 2017

Copy link
Copy Markdown
Member

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 NEWS.rst and CONTRIB.rst files? That lets you decide exactly how to list your name (which you do not currently openly disclose on your GitHub profile).

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.

@peterjc

peterjc commented Nov 8, 2017

Copy link
Copy Markdown
Member

Ah - I missed you were already in the CONTRIB.rst file. Thanks for your further contribution 👍

@StefansM

StefansM commented Nov 8, 2017

Copy link
Copy Markdown
Contributor Author

Thanks Peter. I'm already listed correctly in CONTRIB.rst, so I've just added myself to NEWS.rst.

@jgreener64

Copy link
Copy Markdown
Contributor

Having looked at the code I am happy with it, nice one @StefansM.

@peterjc
peterjc merged commit e41226c into biopython:master Nov 9, 2017
@peterjc

peterjc commented Nov 9, 2017

Copy link
Copy Markdown
Member

Thank you both :)

peterjc added a commit to peterjc/biopython that referenced this pull request Aug 14, 2019
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
peterjc added a commit to peterjc/biopython that referenced this pull request Aug 14, 2019
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
peterjc added a commit that referenced this pull request Aug 29, 2019
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
peterjc added a commit that referenced this pull request Aug 29, 2019
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
peterjc added a commit to peterjc/biopython that referenced this pull request Aug 30, 2019
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
peterjc added a commit to peterjc/biopython that referenced this pull request Sep 3, 2019
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)
peterjc added a commit that referenced this pull request Nov 4, 2019
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)
peterjc added a commit that referenced this pull request Nov 4, 2019
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
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.

3 participants