Skip to content

Alignment Conversion

Convert alignments from one format to another. Optimized for converting many alignments in parallel without the limitation for Python's GIL.

import pysegul
def convert_alignments():
convert = pysegul.AlignmentConversion(
input_fmt='nexus',
datatype='dna',
output_path='tests/output',
output_fmt='fasta',
sort_sequence=True,
)
convert.from_dir('tests/align-data')

To use a list of files, call from_files instead of from_dir:

convert.from_files(['tests/align-data/alignment1.nex', 'tests/align-data/alignment2.nex'])
OptionDefaultDescription
input_fmtRequired'auto', 'fasta', 'nexus', 'phylip'
datatypeRequired'dna', 'aa', 'ignore'
output_pathRequiredOutput directory
output_fmtRequired'fasta', 'nexus', 'phylip', or interleaved 'fasta-int', 'nexus-int', 'phylip-int'
sort_sequenceFalseSort sequences by ID
MethodDescription
from_dir(input_dir)Convert the alignments in a directory
from_files(input_files)Convert a list of alignment files

This material is based upon work supported by the National Science Foundation under grant numbers: DEB-1754393 and DEB-2244754. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.