Skip to content

Alignment Concatenation

Parts of a SEGUL commandThe command segul align concat --dir alignments/ --output aln-concat has five parts: the program segul, the command align for the task group, the subcommand concat for the task, the input --dir alignments/ (folder or files), and the option --output aln-concat (optional).segulProgramalignCommandtask groupconcatSubcommandtask--dir alignments/Inputfolder or files--output aln-concatOptionsoptional

SEGUL CLI provides an easy way to concatenate multiple alignments and generate the partition setting simultaneously.

Terminal window
segul align concat <input-argument> [input-path] --input-format [sequence-format]

For example, we will concat all the alignments in this folder:

Terminal window
alignments/
├── locus_1.nexus
├── locus_2.nexus
└── locus_3.nexus

We can do it in two ways. First, use --dir argument to input alignment files:

Terminal window
segul align concat --dir alignments/

Second, we can use the --input argument to input the alignment files. We will rely on Wildcard (*) and the OS to find all the alignment files.

Terminal window
segul align concat --input alignments/*.nexus

segul will generate two files saved in the Align-Concat directory, consisting of the concatenated alignments and the partition settings:

Terminal window
Align-Concat/
├── Align-Concat.nex
└── Align-Concat_partition.nex

To specify the name of the output directory, use the --output or -o option. Below, we will name our output directory aln-concat.

Terminal window
segul align concat --input alignments/*.nexus --output aln-concat

To specify the prefix of the file names, use the --prefix option. Below, our output filenames will start with concat:

Terminal window
segul align concat --input alignments/*.nexus --output aln-concat --prefix concat

The resulting output directory will contain the files below:

Terminal window
aln-concat/
├── concat.nex
└── concat_partition.nex

By default, the partition format is in nexus:

#nexus
begin sets;
charset 'locus-1' = 1-666;
charset 'locus-2' = 667-1473;
charset 'locus-3' = 1474-2000;
end;

You can specify the partition format using the --partition-format or -p option.

For example, to use RaXML format:

Terminal window
segul align concat --input alignments/*.nexus --output concat --prefix concat --partition-format raxml

The resulting partition will be formatted in RaXML style:

DNA, locus_1 = 1-666
DNA, locus_2 = 667-1473
DNA, locus_3 = 1474-2000

If the input is amino acid sequences, the partition will not contain the datatype:

locus_1 = 1-666
locus_2 = 667-1473
locus_3 = 1474-2000

You can also use charset format. In this format, the partition will be written at the end of the sequence and only available for the nexus output. This format is usually required for phylogenetic programs, such as PAUP and BEAST. To use charset format:

Terminal window
segul align concat --input alignments/*.nexus --output concat --prefix concat --partition-format charset

You can also write the partition to a codon model format using the flag --codon. You may not need this option for genomic datasets. We reserve this function for Sanger datasets.

To sort the sequences in the output by their IDs, add the --sort flag.

OptionDescription
-d, --dirDirectory with alignments
-i, --inputAlignment files. Allows wildcards
-f, --input-formatInput format: auto (default), fasta, nexus, or phylip
--datatypeData type: dna (default), aa, or ignore
-F, --output-formatOutput format: nexus (default), phylip, fasta, nexus-int, phylip-int, or fasta-int
-p, --partition-formatPartition format: nexus (default), charset, or raxml
--codonWrite the partition as a codon model
--sortSort sequences by ID
-o, --outputOutput directory. Default: Align-Concat
--prefixPrefix of the output files. Default: Align-Concat
--forceOverwrite an existing output directory
--logLog file path. Default: segul.log

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.