fhcrc / seqmagick

An imagemagick-like frontend to Biopython SeqIO

Home Page:http://seqmagick.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FastaWriter for line wrap control broken in Biopython 1.77?

ressy opened this issue · comments

I was trying to use my favorite --line-wrap 0 seqmagick option today (seqmagick 0.8.4, Biopython 1.77) and got this error:

AttributeError: 'FastaWriter' object has no attribute '_header_written'

Tracing it back in seqmagick it happens in convert.py around line 310 with this write_file call:

    with destination_file:
        writer = FastaIO.FastaWriter(
            destination_file, wrap=arguments.line_wrap)
        writer.write_file(records)

That eventually gets to write_record where it crashes. In Biopython 1.77, FastaWriter's write_record calls assert self._header_written:

https://github.com/biopython/biopython/blob/biopython-177/Bio/SeqIO/FastaIO.py#L305

...and it's true, instances of FastaWriter don't have a _header_written attribute. That only comes with child classes of SequentialSequenceWriter, not SequenceWriter.

So it seems like a Biopython bug, and I would have gone straight to Biopython with this issue, but then I see that FastaWriter is labeled obsolete and in any case that assertion is removed in 1.78. Is line wrap control broken until migration to newer Biopython, then? This is somewhat related to #87... and I also want to apologize for bringing up another boring bug :)

@ressy we had to update the code in multiple places for which biopython 1.77 is going to break down. We've listed biopython>=1.78 as a requirement for seqmagik>=0.8.3.

Huh, you're right! I have biopython 1.77 installed despite seqmagick 0.8.4's >= 1.78 requirement because of bioconda's package metadata (which conflicts with seqmagick's setup.py). I'll go nag bioconda instead. Thanks.