from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
fh = open('NC2033.txt')
f_out = open('NC2033.fasta','w')
rawseq = fh.read().replace('\n','')
#record = [SeqRecord(Seq(rawseq),'NC2033.txt','','')]
record = (SeqRecord(Seq(rawseq),'NC2033.txt','',''),)
SeqIO.write(record, f_out,'fasta')
f_out.close()
fh.close()

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.