[Biopython-dev] [Bug 2227] Writing Nexus files with Bio.SeqIO

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jul 4 08:39:35 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2227





------- Comment #6 from fkauff at biologie.uni-kl.de  2008-07-04 04:39 EST -------
(In reply to comment #4)
> Created an attachment (id=965)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=965&action=view) [details]
> 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:
> ...

> 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?
> 

Very nice. Go for it :-)

Cheers,
Frank
(In reply to comment #4)
> Created an attachment (id=965)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=965&action=view) [details]
> 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