[Biopython] Unable to convert alignment to nexus format

Peter Cock p.j.a.cock at googlemail.com
Thu Aug 11 14:04:50 UTC 2011


On Thu, Aug 11, 2011 at 1:40 PM, Morten Kjeldgaard <mok at bioxray.dk> wrote:
> Hi,
>
> I am getting an exception when trying to output an alignment in nexus
> format:
>
>  ValueError: Need a DNA, RNA or Protein alphabet
>
> The alignment is read by AlignIO.read() in fasta format from an output
> file written by Muscle, and so the alphabet specified in the sequences
> is IUPACProtein.

Yes, but it was written out as a FASTA file which does not record
the alphabet. Biopython does not try to guess this, you must be
explicit.

> Apparently, NexusIO checks for ProteinAlphabet and thus
> fails. I am using BioPython 1.56.

As Brad described, when you parse the FASTA alignment, tell
Biopython it is protein.

Peter




More information about the Biopython mailing list