skbio.sequence.DNASequence.to_fasta

DNASequence.to_fasta(field_delimiter=' ', terminal_character='n')[source]

Return the sequence as a fasta-formatted string

Note

Deprecated in scikit-bio 0.2.0-dev to_fasta will be removed in scikit-bio 0.3.0. It is replaced by write, which is a more general method for serializing FASTA-formatted files. write supports multiple file formats by taking advantage of scikit-bio’s I/O registry system. See skbio.io for more details.

Parameters:

field_delimiter : str, optional

The character(s) to use on the header line between the self.id and self.description.

terminal_character : str, optional

The last character to be included in the result (if you don’t want a trailing newline or other character in the result, you can pass terminal_character="").

Returns:

str

The BiologicalSequence as a fasta-formatted string.

Examples

>>> from skbio.sequence import BiologicalSequence
>>> s = BiologicalSequence('ACACGACGTT')
>>> print(s.to_fasta(terminal_character=""))
>
ACACGACGTT
>>> t = BiologicalSequence('ACA',id='my-seq',description='h')
>>> print(t.to_fasta(terminal_character=""))
>my-seq h
ACA