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_dir/<sample_id>/<sample_id>.<ext>.

Use fasta or fasta-int output, because the transposed sequences are unaligned.

Install PySEGUL using pip if you haven’t done it yet

Terminal window
pip install pysegul

Create a new Python script, import the library, and write python code.

import pysegul
def transpose_sequences():
input_dir = 'tests/align-data'
input_format = 'nexus'
datatype = 'dna'
output_dir = 'tests/output'
transpose = pysegul.SequenceTranspose(
input_format,
datatype,
output_dir,
# Optional. Default: 'fasta'
output_fmt='fasta',
)
transpose.from_dir(input_dir)

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'])