Skip to content

genbank_to_fasta() ​

Write the sequences of a GenBank file to a FASTA file.

Each record becomes a FASTA record with the header >VERSION DEFINITION and the sequence of ORIGIN in capitals. A record without a VERSION is named by its ACCESSION, else its LOCUS name, else the file name; without a DEFINITION the header is the name only.

Usage ​

python
from geneviewer import genbank_to_fasta

genbank_to_fasta(path, output_dir=tempfile.gettempdir())

Arguments ​

ArgumentTypeDescription
pathstr or path-likeThe GenBank file.
output_dirstr or path-like or None, optionalThe folder of the FASTA file, which gets the input's name with the extension .fasta. By default the temporary folder; None writes it next to the input.

Value ​

pathlib.Path: The FASTA file.

Errors ​

ErrorWhen
FileNotFoundErrorWhen the file does not exist.
ValueErrorWhen the file has no sequence, or its records do not end in //.