[BioPython] RecordFile.py

Brad Chapman chapmanb at uga.edu
Tue May 4 12:44:21 EDT 2004


Hi Chunlei;

>             I just tried "RecordFile.py", but it failed for both fasta 
> file and genbank file I tested.
> 
> >>> rec_h=RecordFile.RecordFile(open(r"gb_test.txt" ),'LOCUS','\\')
> or
> >>> rec_h=RecordFile.RecordFile(open(r"gb_test.txt" ),'>','')
> 
> both returned the same error:

Thanks for the report -- it does look like RecordFile is really code
that is not completely finished. I think the best course of action
is to deprecate this module, which is not really used inside of
Biopython. Mostly it might be useful for building up parsers, but we
are currently encouraging the use of Martel for this.

> Actually, I wrote a simply script before using Bio.File's UndoHandle for 
> the same purpose. It looks much simpler, maybe not as powerful as 
> RecordFile.py, but it does works for me.  I post it here and hope it is 
> worth sharing with you.

Thanks for the code. In many ways, I think both RecordFile and this
kind of duplicate the functionality that already exists in
Biopython. You can get a text record iterator of Fasta and GenBank
files using:

from Bio import Fasta
handle = open("your_file.fasta")
iterator = Fasta.Iterator(handle)
for rec in iterator:
   # do something with your text record

That is -- if you don't pass a parser then you get back the text.

Thanks for the report! Hope this helps
Brad


More information about the BioPython mailing list