skbio.format.sequences.fasta_from_alignment

skbio.format.sequences.fasta_from_alignment(aln, make_seqlabel=None, line_wrap=None, sort=True)[source]

Returns a FASTA string given an alignment object

Parameters:

aln : Alignment, dict

alignment or dictionary where the keys are the sequence ids and the values are the sequences themselves.

make_seqlabel : function, optional

callback function that takes the seq object and returns a label str. If None is passed, the following attributes will try to be retrieved in this order and the first to exist will be used: id, Label or Name. In any other case an integer with the position of the sequence object will be used.

line_wrap : int, optional

line_wrap: a integer for maximum line width, if None is passed the full sequence will be used.

sort : bool, optional

Whether or not the sequences should be sorted by their sequence id, default value is True.

Returns:

str

FASTA formatted string composed of the objects passed in via seqs.

Examples

Formatting a sequence alignment object into a FASTA file.

>>> from skbio.alignment import Alignment
>>> from skbio.sequence import DNA
>>> from skbio.format.sequences import fasta_from_alignment
>>> seqs = [DNA("ACC--G-GGTA..", id="seq1"),
...         DNA("TCC--G-GGCA..", id="seqs2")]
>>> a1 = Alignment(seqs)
>>> print fasta_from_alignment(a1)
>seq1
ACC--G-GGTA..
>seqs2
TCC--G-GGCA..