Bio.AlignIO.NexusIO module
Bio.AlignIO support for the “nexus” file format.
You are expected to use this module via the Bio.AlignIO functions (or the Bio.SeqIO functions if you want to work directly with the gapped sequences).
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.
- Bio.AlignIO.NexusIO.NexusIterator(handle: IO[str], seq_count: int | None = None) Iterator[MultipleSeqAlignment]
Return SeqRecord objects from a Nexus file.
Thus uses the Bio.Nexus module to do the hard work.
You are expected to call this function via Bio.SeqIO or Bio.AlignIO (and not use it directly).
NOTE - We only expect ONE alignment matrix per Nexus file, meaning this iterator will only yield one MultipleSeqAlignment.
- class Bio.AlignIO.NexusIO.NexusWriter(handle)
Bases:
AlignmentWriter
Nexus alignment writer.
Note that Nexus files are only expected to hold ONE alignment matrix.
You are expected to call this class via the Bio.AlignIO.write() or Bio.SeqIO.write() functions.
- write_file(alignments)
Use this to write an entire file containing the given alignments.
- Arguments:
alignments - A list or iterator returning MultipleSeqAlignment objects. This should hold ONE and only one alignment.
- write_alignment(alignment, interleave=None)
Write an alignment to file.
Creates an empty Nexus object, adds the sequences and then gets Nexus to prepare the output. Default interleave behaviour: Interleave if columns > 1000 –> Override with interleave=[True/False]