[Biopython-dev] [Bug 1944] Align.Generic adding iterator and more

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jul 27 12:51:10 UTC 2007


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





------- Comment #4 from biopython-bugzilla at maubp.freeserve.co.uk  2007-07-27 08:51 EST -------
Created an attachment (id=721)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=721&action=view)
Patch for Bio/Align/Generic.py to add __getitem__ method

This patch adds a __getitem__ method, a small "mini test" when running the
module directly, and updates the doc strings.  This gives SeqRecord iteration
"for free" (without an explicit __iter__ method).

As discussed on the mailing list, this allows an Alignment object to be treated
as a list of SeqRecord objects or as an array of character strings - plus
extract whole columns as strings.

Quoting the proposed __getitem__ doc string:

        Depending on the indices, you can get a SeqRecord objects
        (representing a single row), strings (for a single columns or
        single characters) or another alignment (representing some or
        part of the alignment).

        align[r,c] gives a single character as a string
        align[r] gives a SeqRecord
        align[:,c] gives a column as a string
        align[:] and align[:,:] give a copy of the alignment

        Anything else gives a sub alignment, e.g.
        align[0:2] or align[0:2,:] uses only row 0 and 1
        align[:,1:3] uses only columns 1 and 2
        align[0:2,1:3] uses only rows 0 & 1 and only cols 1 & 2

Feedback welcome - either here, or on the developers' mailing list.  Thanks


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