[Biopython-dev] [Bug 2227] Writing Nexus files with Bio.SeqIO
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Thu Jul 3 14:13:38 UTC 2008
http://bugzilla.open-bio.org/show_bug.cgi?id=2227
------- Comment #4 from biopython-bugzilla at maubp.freeserve.co.uk 2008-07-03 10:13 EST -------
Created an attachment (id=965)
--> (http://bugzilla.open-bio.org/attachment.cgi?id=965&action=view)
Bio/Nexus/Nexus.py handle support in write_nexus_data()
With Bio/Nexus/Nexus.py revision 1.16 from CVS, it is now possible to create an
empty Nexus object and add sequences to it:
#Read in an alignment object, e.g. with Bio.AlignIO
from Bio import AlignIO
alignment = AlignIO.read(open("example.aln"), "clustal")
#Make a Nexus object
from Bio.Nexus import Nexus
handle = open("test.nex", "w")
n = Nexus.Nexus()
n.alphabet = alignment._alphabet
for record in alignment :
n.add_sequence(record.id, record.seq.tostring())
n.write_nexus_data(handle)
handle.close()
There are two problems with write_nexus_data(), firstly it doesn't accept a
StringIO handle (see also Bug 2454).
Secondly, if given a handle it closes it. This would break the above code, or
how I typically use StringIO.
This patch addresses these points.
Frank, are you happy for me to commit this change?
--
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