Skip to content

add fasta-nowrap to SeqIO.write API - #1450

Merged
peterjc merged 10 commits into
biopython:masterfrom
Zsailer:fasta-nowrap
Dec 28, 2017
Merged

peterjc merged 10 commits into
biopython:masterfrom
Zsailer:fasta-nowrap

Conversation

@Zsailer

@Zsailer Zsailer commented Nov 9, 2017 •

Copy link
Copy Markdown
Contributor

This pull request addresses issue #666. pinging @peterjc for review.

It extends the SeqIO.write API to allow writing to fasta format without line wrapping by adding a fasta-nowrap option to the format list.

To implement this, I subclassed FastaWriter to FastaNoWrapWriter and set wrap=None in super. Not sure if this is the best way to do this. I'm happy to change it.

This doesn't update the Docs. I wanted to make sure the logic works before changing the docs.

Contributing stuff

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.

@Zsailer

Zsailer commented Nov 10, 2017

Copy link
Copy Markdown
Contributor Author

Oops, should have ran tests before submitting. Sorry.

Looks like the tests are written such that SeqIO.parse must be symmetric to SeqIO.write. That means the parsing formats must also have a "fasta-nowrap" option. Should I just use the standard fasta parser as a place holder to start?

@peterjc

peterjc commented Nov 10, 2017

Copy link
Copy Markdown
Member

The place holder makes sense - up until now all the output formats have had a parser, so the tests reflect that. You could instead try adding a special case to the tests?

@peterjc

peterjc commented Nov 28, 2017

Copy link
Copy Markdown
Member

I think to fix the test, you'd need to update this line

https://github.com/biopython/biopython/blob/biopython-170/Tests/test_SeqIO.py#L433

    elif format == "fasta":

to:

    elif format in ["fasta", "fasta-nowrap"]:

@Zsailer

Zsailer commented Nov 28, 2017

Copy link
Copy Markdown
Contributor Author

That helped fix some of the test.

I'm breaking some new tests. Looks like I need to add a bunch of "expected output" lines to output.test_SeqIO.

@Zsailer

Zsailer commented Nov 28, 2017

Copy link
Copy Markdown
Contributor Author

Ok, all tests are passing now.

@codecov

codecov Bot commented Nov 28, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #1450 into master will increase coverage by 0.02%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1450      +/-   ##
=========================================
+ Coverage   84.77%   84.8%   +0.02%     
=========================================
  Files         321     323       +2     
  Lines       49316   49393      +77     
=========================================
+ Hits        41810   41886      +76     
- Misses       7506    7507       +1
Impacted Files Coverage Δ
Bio/SeqIO/__init__.py 84.43% <ø> (ø) ⬆️
Bio/SeqIO/FastaIO.py 90.09% <77.77%> (-3.15%) ⬇️
Bio/PDB/PDBList.py 16.66% <0%> (-0.79%) ⬇️
Bio/SeqUtils/__init__.py 59.72% <0%> (ø) ⬆️
Bio/Compass/__init__.py 84.56% <0%> (ø) ⬆️
Bio/Nexus/Nexus.py 72.46% <0%> (ø) ⬆️
Bio/Alphabet/__init__.py 88.02% <0%> (ø) ⬆️
Bio/Blast/NCBIWWW.py 12.04% <0%> (ø) ⬆️
Bio/SeqUtils/ProtParam.py 96.29% <0%> (ø) ⬆️
Bio/SeqUtils/ProtParamData.py 100% <0%> (ø) ⬆️
... and 13 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 0a0348c...7af1cfc. Read the comment docs.

@peterjc

peterjc commented Nov 29, 2017

Copy link
Copy Markdown
Member

I hope you spotted run_test.py -g test_SeqIO.py (see the testing chapter in the tutorial), but anyway - you got there :)

Would you like to add yourself to the NEWS.rst and CONTRIB.rst files too (sorted alphabetically)?

@Zsailer

Zsailer commented Nov 29, 2017

Copy link
Copy Markdown
Contributor Author

Oh wow, I totally missed that. 🤦‍♂️

Thanks for the review! I've added myself to NEWS.rst and CONTRIB.rst. If you need anything else from me, let me know. :)

@peterjc

peterjc commented Dec 4, 2017

Copy link
Copy Markdown
Member

(The TravisCI Python 2.7 test failed in the KD Tree code, looks like a stochastic failure and I have re-run that)

@Zsailer

Zsailer commented Dec 4, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @peterjc. Looks like the tests passed this time!

@peterjc

peterjc commented Dec 11, 2017

Copy link
Copy Markdown
Member

See #666 (comment) where perhaps fasta-2line would be better than fasta-nowrap (important for parsing).

@peterjc

peterjc commented Dec 11, 2017

Copy link
Copy Markdown
Member

(Hang on, I've had a rebase glitch while adding the parser on top of your branch...)

@peterjc

peterjc commented Dec 11, 2017

Copy link
Copy Markdown
Member

I had to do a git rebase and git push --force to sort out my initial glitch which pulled some unrelated commits onto this pull request.

Anyway, how does this look @Zsailer?

There is scope for also implementing SeqIO indexing for the new FASTA variant as well.

@peterjc

peterjc commented Dec 11, 2017 •

Copy link
Copy Markdown
Member

Updated again since master branch now enforces pydocstyle check D301:

$ flake8 Bio/SeqIO/FastaIO.py
Bio/SeqIO/FastaIO.py:76:1: D301 Use r""" if any backslashes in a docstring

I revised my doctest to avoid needing a \t for tab.

@Zsailer

Zsailer commented Dec 11, 2017

Copy link
Copy Markdown
Contributor Author

@peterjc, this looks good! Thanks for pushing this forward!

@peterjc

peterjc commented Dec 11, 2017

Copy link
Copy Markdown
Member

Great, thanks. Once the tests have passed on this, I'll apply it.

(The stricter docstring checking is fairly recent, it will make life harder for a few of the already open pull requests)

@peterjc

peterjc commented Dec 13, 2017

Copy link
Copy Markdown
Member

@bow Does this look good to you? We could add more on the tests side, and perhaps implement direct indexing of two-line-per-record FASTA as well - but this seems a useful unit of work now.

@bow

bow commented Dec 15, 2017

Copy link
Copy Markdown
Member

@peterjc this looks good ~ and @Zsailer thanks for the PR! My only small question is about the writer: is there a reason it is called FastaNoWrap... while the iterator is FastaTwoLine.. and the proposed format name is fasta-2line?

@peterjc

peterjc commented Dec 18, 2017

Copy link
Copy Markdown
Member

Good catch on the write class name - I agree with you. I'll fix that before merging this.

Suggested by Bow while reviewing pull request biopython#1450
@peterjc
peterjc merged commit 4e359e2 into biopython:master Dec 28, 2017
peterjc added a commit that referenced this pull request Sep 19, 2018
As the original author I have agreed, as have the contributors
since as per the git commit logs:

 - Olivier Morelle (@Oli4)
   #898 (comment)
 - Zachary Sailer (@Zsailer)
   #1450
 - Bertrand Néron (@bneron)
   #898 (comment)
 - Wibowo Arindrarto (@bow)
   #898 (comment)
 - Carlos Pena (@carlosp420)
   #898 (comment)
 - Christian Brueffer (@cbrueffer)
   #898 (comment)
 - Brad Chapman (@chapmanb)
   http://mailman.open-bio.org/pipermail/biopython-dev/2013-July/019903.html
 - Connor McCoy (@cmccoy)
   #898 (comment)
 - Eric Talevich (@etal)
   #898 (comment)
 - Wayne Decatur (@fomightez)
   #898 (comment)
 - Bertrand Néron (@freeh4cker)
   #898 (comment)
 - FGastaldello (@Gasta88)
   #1063
 - jchang (@jefftc)
   #898 (comment)
 - Uri Laserson (@laserson)
   #898 (comment)
 - Lenna Peterson (@lennax)
   #898 (comment)
 - Michiel de Hoon (@mdehoon)
   #898 (comment)
 - @morrme
   #1172 (comment)
 - Nick Negretti (@nimne)
   #1768 (comment)
 - Peter Cock (@peterjc)
   #898 (comment)
 - Shuichiro MAKIGAKI (@shuichiro-makigaki)
   #1370
 - Travis Wrightsman (@twrightsman)
   #898 (comment)
 - Thomas Schmitt (@wurstbonbon)
   #898 (comment)
peterjc added a commit to peterjc/biopython that referenced this pull request Aug 30, 2019
As original author I agree, as have all the named contributors since
as tracked by version control (with one exception discussed below):

 - Carlos Pena (@carlosp420)
   biopython#898 (comment)
 - Chris Rands (@chris-rands)
   biopython#1301
 - Christian Brueffer (@cbrueffer)
   biopython#898 (comment)
 - Connor McCoy (@cmccoy)
   biopython#898 (comment)
 - Dominik Luntzer (@stanti)
   biopython#898 (comment)
 - Francesco Gastaldello (@Gasta88)
   biopython#1063
 - Jeroen Van Goey (@BioGeek)
   biopython#898 (comment)
 - lasher (@gotgenes)
   biopython#898 (comment)
 - @morrme
   biopython#1172 (comment)
 - Peter Cock (@peterjc)
   biopython#898 (comment)
 - Sergei Lebedev (@superbobry)
   biopython#898 (comment)
 - Zachary Sailer (@Zsailer)
   biopython#1450

The exception is Lucas Sinclair (@xapple), but their contribution was
removing one line in a docstring, where the code example has since been
updated.
peterjc added a commit that referenced this pull request Nov 4, 2019
As original author I agree, as have all the named contributors since
as tracked by version control (with one exception discussed below):

 - Carlos Pena (@carlosp420)
   #898 (comment)
 - Chris Rands (@chris-rands)
   #1301
 - Christian Brueffer (@cbrueffer)
   #898 (comment)
 - Connor McCoy (@cmccoy)
   #898 (comment)
 - Dominik Luntzer (@stanti)
   #898 (comment)
 - Francesco Gastaldello (@Gasta88)
   #1063
 - Jeroen Van Goey (@BioGeek)
   #898 (comment)
 - lasher (@gotgenes)
   #898 (comment)
 - @morrme
   #1172 (comment)
 - Peter Cock (@peterjc)
   #898 (comment)
 - Sergei Lebedev (@superbobry)
   #898 (comment)
 - Zachary Sailer (@Zsailer)
   #1450

The exception is Lucas Sinclair (@xapple), but their contribution was
removing one line in a docstring, where the code example has since been
updated.
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