[Biopython-dev] [Bug 2561] SeqRecord format method to get a string in a given file format
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Sat Aug 2 08:51:49 EDT 2008
http://bugzilla.open-bio.org/show_bug.cgi?id=2561
------- Comment #9 from biopython-bugzilla at maubp.freeserve.co.uk 2008-08-02 08:51 EST -------
As a further remark on re-reading Jared's email and PEP 3101, given the string
class is getting a .format method which just calls the .__format__ method,
perhaps we should call our new method just "format" rather than "to_format" (or
"tostring" or any of the other options.
e.g.
from Bio import SeqIO
for record in SeqIO.read(open("ls_orchids.gbk"),"genbank") :
print record #uses __str__ method
print record.format("fasta")
print record.format("tab")
from Bio import AlignIO
align = AlignIO.read(open("example.aln"),"clustal")
print align #uses __str__ method
print align.format("fasta")
print align.format("nexus")
print align.format("clustal")
And, if using python 2.6 or 3.0 you could also do:
print format(record, "fasta") #uses __format__ method
print format(align, "clustal") #uses __format__ method
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list