[Biopython-dev] [Bug 2778] Efficiency improvement in function Bio.SeqUtils.GC()

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu Mar 5 10:56:39 UTC 2009


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


biopython-bugzilla at maubp.freeserve.co.uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from biopython-bugzilla at maubp.freeserve.co.uk  2009-03-05 05:56 EST -------
I've checked that in, but with the existing code to catch a zero length
sequence and return 0 instead of raising a ZeroDivisionError.

def GC(seq):
    """Calculates G+C content, ..."""
    gc=sum(map(seq.count,['G','C','g','c','S','s']))
    if gc == 0: return 0
    return gc*100.0/len(seq)


The old code had been modified several times - it originally calculated the GC%
as the CG count divided by the ATCG count, thus it had to count all the bases. 
You are right, this is much cleaner.

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