Package Bio :: Package writers :: Package SeqRecord :: Module fasta
[hide private]
[frames] | no frames]

Source Code for Module Bio.writers.SeqRecord.fasta

 1  from Bio import Writer 
 2   
3 -class WriteFasta(Writer.Writer):
4 - def __init__(self, outfile, seqwidth = 72):
5 Writer.Writer.__init__(self, outfile) 6 assert seqwidth > 0, seqwidth 7 self.seqwidth = seqwidth
8
9 - def write(self, record):
10 self.outfile.write(">%s %s\n" % (record.id, record.description)) 11 seq = record.seq 12 assert seq.alphabet.size == 1, "cannot handle alphabet of size %d" % \ 13 seq.alphabet.size 14 seq = seq.data 15 seqwidth = self.seqwidth 16 for i in range(0, len(seq), seqwidth): 17 self.outfile.write(seq[i:i+seqwidth]) 18 self.outfile.write("\n")
19 20 make_writer = WriteFasta 21