Skip to content

Sequence Transpose

Transpose locus alignments into one sequence file per sample. Each output file contains all loci for one sample, labeled by the locus (input file name) they come from. Gaps and missing data are removed. PySEGUL writes each sample to <output_path>/<sample_id>/<sample_id>.<ext>.

import pysegul
def transpose_sequences():
transpose = pysegul.SequenceTranspose(
input_fmt='nexus',
datatype='dna',
output_path='tests/output',
)
transpose.from_dir('tests/align-data')

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

transpose.from_files(['tests/align-data/locus1.nex', 'tests/align-data/locus2.nex'])
OptionDefaultDescription
input_fmtRequired'auto', 'fasta', 'nexus', 'phylip'
datatypeRequired'dna', 'aa', 'ignore'
output_pathRequiredOutput directory
output_fmt'fasta''fasta' or interleaved 'fasta-int'. Transposed sequences are unaligned
MethodDescription
from_dir(input_dir)Transpose the alignments in a directory
from_files(input_files)Transpose 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.