Skip to content

read_fasta() ​

Read FASTA files into one table, a row per sequence.

The keys of each header become columns: [key=value] pairs, as NCBI writes them, or key=value pairs, as in UniProt headers. A key repeated in one header keeps its values joined with ",". With a location key, the table gets start and end, the full span of the location, and strand: "complement" or "forward". Sequences without any key are left out, with a warning; a file that cannot be read is skipped, with a warning.

Usage ​

python
from geneviewer import read_fasta

read_fasta(fasta_path, sequence=True, keys=None, file_extension='fasta')

Arguments ​

ArgumentTypeDescription
fasta_pathstr or path-likeA FASTA file (also gzip-compressed), or a folder of them.
sequencebool, default TrueWhether to keep the sequences, in the column sequence.
keyssequence of str, optionalThe columns to keep.
file_extensionstr, default "fasta"The extension of the files read from a folder.

Value ​

pandas.DataFrame: One row per sequence, with cluster, the file's name without its extension.

Errors ​

ErrorWhen
FileNotFoundErrorWhen the path does not exist.