[Biopython] Unable to convert alignment to nexus format

Morten Kjeldgaard mok at bioxray.dk
Thu Aug 11 12:40:57 UTC 2011


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. Apparently, NexusIO checks for ProteinAlphabet and thus
fails. I am using BioPython 1.56.

Here is a 4-line test program generating the exception:

from Bio import AlignIO
alignment = AlignIO.read(open("aln.muscle"), "fasta")
g = open("aln.nexus", "w")
g.write (alignment.format("nexus"))


Any (safe) workarounds here?
Cheers,

Morten


-- 
Morten Kjeldgaard, asc. professor, MSc, PhD
BiRC - Bioinformatics Research Center, Aarhus University
C.F. Møllers Alle, Building 1110, DK-8000 Aarhus C, Denmark.
Lab +45 8942 3130 * Mobile: +45 5186 0147 * Home +45 8618 8180





More information about the Biopython mailing list