Skip to content

Alignment Filtering

Filter alignments by length, parsimony informative sites, taxon completeness, or missing data. PySEGUL writes the alignments that pass the filter, or concatenates them.

Set the input with input_dir or input_files, then call a filtering method. Each method runs the filter.

import pysegul
def filter_alignments():
filter = pysegul.AlignmentFiltering(
input_fmt='nexus',
datatype='dna',
output_path='tests/output',
output_fmt='nexus',
)
filter.input_dir = 'tests/align-data'
# Or use a list of files:
# filter.input_files = ['tests/align-data/locus1.nex']
filter.minimal_taxa(0.5)

To concatenate the filtered alignments, set is_concat with a prefix and a partition format:

filter = pysegul.AlignmentFiltering(
'nexus',
'dna',
'tests/output',
'nexus',
is_concat=True,
prefix='filtered_concat',
partition_fmt='raxml',
)
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'
is_concatFalseConcatenate the alignments that pass the filter
prefixNoneName of the concatenated alignment. Required with is_concat
partition_fmtNone'charset', 'nexus', 'raxml', or a -codon version. Required with is_concat
AttributeDescription
input_dirDirectory of input alignments
input_filesList of input alignment files
MethodKeep alignments that
minimal_taxa(percent_taxa)have at least percent_taxa (0.0–1.0) of all taxa
minimal_length(min_length)are at least min_length sites long
minimal_parsimony_inf(min_parsimony)have at least min_parsimony parsimony informative sites
percent_informative(percent_informative)have at least percent_informative (0.0–1.0) parsimony informative sites
contain_taxa(taxon_id)contain all of the taxa in the list
minimal_taxa_count(min_taxa) (beta)have at least min_taxa taxa
maximal_length(max_length) (beta)are at most max_length sites long
maximal_parsimony_inf(max_parsimony) (beta)have at most max_parsimony parsimony informative sites
missing_data(max_missing) (beta)have at most max_missing (0.0–1.0) missing data (gaps and ?)

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.