[Biopython-dev] [Bug 2628] New: Have Bio.SeqIO.write(...) and Bio.AlignIO.write(...) return number of records

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Oct 24 14:51:00 UTC 2008


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

           Summary: Have Bio.SeqIO.write(...) and Bio.AlignIO.write(...)
                    return number of records
           Product: Biopython
           Version: Not Applicable
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Main Distribution
        AssignedTo: biopython-dev at biopython.org
        ReportedBy: biopython-bugzilla at maubp.freeserve.co.uk


Motivation: When creating a sequence (or alignment) file, It is sometimes
useful to know how many records (or alignments) were written out.  This is easy
if your records are in a list:

records = list(...)
SeqIO.write(records, handle, format)
print "Wrote %i records" % len(records)

If however your records are from a generator/iterator (e.g. a generator
expression, or some other iterator) you cannot use len(records).  You could
turn this into a list just to count them, but this wastes memory.

It would therefore be useful to have the count returned:

records = some_generator
count = SeqIO.write(records, handle, format)
print "Wrote %i records" % count

For a precedent, the BioSQL loader returns the number of records loaded into
the database.

Currently Bio.SeqIO.write(...) and Bio.AlignIO.write(...) have no return value,
so adding a return value is a backwards compatible enhancement.


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