Bio.Align.nexus module

Bio.Align support for the “nexus” file format.

You are expected to use this module via the Bio.Align functions.

See also the Bio.Nexus module (which this code calls internally), as this offers more than just accessing the alignment or its sequences as SeqRecord objects.

class Bio.Align.nexus.AlignmentWriter(target, mode='w')

Bases: Bio.Align.interfaces.AlignmentWriter

Nexus alignment writer.

Note that Nexus files are only expected to hold ONE alignment matrix.

You are expected to call this class via Bio.Align.write().

write_file(alignments)

Write a file with the alignments, and return the number of alignments.

alignments - A list or iterator returning Alignment objects

write_header(alignments)

Use this to write the file header.

format_alignment(alignment, interleave=None)

Return a string with a single alignment in the Nexus format.

Creates an empty Nexus object, adds the sequences and then gets Nexus to prepare the output. Default interleave behavior: Interleave if columns > 1000 –> Override with interleave=[True/False]

class Bio.Align.nexus.AlignmentIterator(source)

Bases: Bio.Align.interfaces.AlignmentIterator

Nexus alignment iterator.

__init__(source)

Create an AlignmentIterator object.

Arguments:
  • source - input data or file name

__abstractmethods__ = frozenset({})