[Biopython-dev] Bioformat module
Andrew Dalke
adalke at mindspring.com
Sun Dec 30 08:37:12 EST 2001
Hey all,
Here's the first go at a module based off the set of emails
I wrote last week. It's at
http://www.biopython.org/~dalke/Bioformat-0.1.tar.gz
No setup.py or anything fancy like that. Though you do
need the lastest version of CVS Martel. (List of changes
in the next email.)
In theory this provides a platform for:
- automatic format recognition
- using the format information to build a data structure
- writing that data structure to another format
For example, these parts can be put together for simple,
generic file conversion, as in:
from Bio import SeqRecord
writer = SeqRecord.io.make_writer(sys.stdout, "fasta")
writer.writeHeader() # needed for some formats
for record in SeqRecord.io.read(open("file.unknown")):
writer.write(record)
writer.writeFooter() # needed for some formats
(Actually, with the code as-is, this is done with
from Bioformat import IO
IO.io.convert(infile = open("file.unknown"), output_format = "fasta")
:)
The README includes some examples of how to use this module.
Please take a look.
More after I have a chance to get some sleep. This project
was harder than I thought it would be. OTOH, it's something
that should be very exciting for the O'Reilly conference.
Andrew
dalke at dalkescientific.com
More information about the Biopython-dev
mailing list