This is a test version of Biostars. For the public version, visit https://www.biostars.org.
convert GenBank formatted sequence file to FASTA format

how to Write a python program that asks the user for a sequence in GenBank format and convert the GenBank formatted sequence into FASTA format then Write the FASTA formatted sequence to a file.

fasta python genback

sounds like a homework. What did you write so far ?

1 answer

Biopython is great for working with sequence data in python. Taken almost verbatim from their documentation (https://biopython.org/wiki/SeqIO):

from Bio import SeqIO
import sys

count = SeqIO.convert(sys.argv[1], "genbank", sys.argv[2], "fasta")
print("Converted %i records" % count)

Save as anything, e.g. script.py, then:

python3 script.py example.gb example.fasta

Log in to answer this question.