Script to convert gb to fasta


In [26]:
from glob import iglob
from Bio import SeqIO
from gzip import open as gopen

for filename in iglob("Baculo/*.gb"):
    print filename
    gb = SeqIO.read(open(filename, "rb"), "genbank")
    gb.id = gb.name
    gb.description = ""
    with gopen(filename.split(".")[0]+".fa.gz", "wb") as fasta:
         fasta.write(gb.format("fasta"))


Baculo/Bacmid_WT.gb
Baculo/pSR_CAPrh10 (R2Crh10).gb
Baculo/pFB_AAV_GFP_p2.gb
Baculo/pSR660 (R2C8).gb

In [ ]: