[BioPython] re: question regarding writing SeqRecord objects in Fasta format

Ann Loraine loraine at loraine.net
Mon Jul 18 20:04:55 EDT 2005


Hello,

To answer your question - I read in the fasta records like so:

    from Bio import Fasta	
    fh = gzip.Gzipfile('seqs.fa.gz').open()
    parser = Fasta.RecordParser()
    iterator = Fasta.Iterator(fh,parser)
    curr_record = iterator.next()

I was following the example in this tutorial Web page:

http://www.biopython.org/docs/tutorial/Tutorial003.html#toc7


"Let's make all of this talk more concrete by using the Iterator and 
Record interfaces to do what we did before -- extract a unique list of 
all species in our FASTA file. First we need to set up our parser and 
iterator:
 >>> from Bio import Fasta
 >>> parser = Fasta.RecordParser()
 >>> file = open("ls_orchid.fasta")
 >>> iterator = Fasta.Iterator(file, parser)"

Should I be using the SeqIO method instead to read fasta records if I 
want to write some of them out to a fasta format file?

-Ann


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1032 bytes
Desc: not available
Url : http://portal.open-bio.org/pipermail/biopython/attachments/20050718/57e79660/attachment.bin


More information about the BioPython mailing list