[Biopython] convert to interleaved nexus

Peter Cock p.j.a.cock at googlemail.com
Wed Mar 27 11:52:15 UTC 2013


On Wed, Mar 27, 2013 at 12:07 AM, natassa <natassa_g_2000 at yahoo.com> wrote:
> Hi Peter,
> There is a single call to write_nexus_data within the call, the second one
> is quoted out. But it is within an if block-do you mean this is incorrect?

If your alignment had 100 sequences, and the write_nexus_data call
was inside the loop, it would be called 100 times. It should be outside
the loop and called once only.

> I can't really tell if there is a specific need for interleaved versus
> sequential nexus, I use the file for a MrBayes analysis and the error
> message i got when running it with a sequential nexus had  something to do
> with max characters per line , similarly to what was discussed here:
> http://biopython.org/pipermail/biopython-dev/2010-December/008480.html
> I thus decided to go for an interleaved format.

If your sequences are very long then yes, in order to use MrBayes
is does seem you must use interleaved NEXUS format.

> But it would be good if NexusIO supports more formats or in general, that
> the functionalities of the write_nexus_data were more easily accessible
> compared to the 'workaround' that I did here. I am not a biopython expert to
> assess this though :-)
> Thanks,
> Natassa

How about we make AlignIO default to writing interleaved Nexus if the
sequences are very long (say over 1000 bases)? That way for small
alignments we continue to produce non-interleaved Nexus as now
(which has proved reliable) and automatically interleave when is it
more likely that parsers with fixed buffers like MrBayes would fail.

Peter



More information about the Biopython mailing list