[bip] mRNA lengths of all Human/Mouse refseqs (tutorial)

Titus Brown titus at caltech.edu
Thu Jan 17 00:53:39 PST 2008


On Wed, Jan 16, 2008 at 04:32:20PM -0800, Brandon King wrote:
-> for reverse complementing DNA sequence. And the short answer is I don't
-> know... He did some benchmarking if I remember correctly on why this was
-> faster... I've CC'ed Chris as he probably has a better answer. I think
-> that particular module was written pre-2002 and therefore was
-> benchmarked against an older version of Python. Chris?
-> 
-> Let me know if you have any other questions or request for documentation
-> and I'll see about writing some additional examples/tutorials.
-> 
-> -Brandon
-> 
-> P.S. Chris, you might want to check out http://bio.scipy.org/
-> 
-> Brent Pedersen wrote:
-> > hi, and thanks for making this available. i have immediate use for the
-> > fasta indexing.
-> > what's this in SequenceUtils.py? am i missing something or is
-> > [seq]*len(seq) uneccessary. what's the advantage over python's
-> > reversed?
-> >
-> >
-> > def reverse(seq):
-> >   """reverse a sequence"""
-> >   return(''.join(map(operator.getitem, [seq]*len(seq),
-> >                      xrange(len(seq)-1, -1, -1))))

Ooh, goodie, do we get to have a profiling/benchmark war now? ;) 

Anyway, I'm never one to pass up a chance to take Chris down a peg... I
did a quick benchmark of these three functions:

---

def bh_reverse(seq):
   return(''.join(map(operator.getitem, [seq]*len(seq),
                      xrange(len(seq)-1, -1, -1))))

def ctb_reverse(seq):
   r = array('c', seq)
   r.reverse()
   r = string.join(r, '')

   return r

def obvious_reverse(seq):
   r = list(seq)
   r.reverse()
   r = "".join(r)

   return r

---

(full code is attached).  Here are the numbers for 10x reversing of a
1mb string of As:

bh 7.85962796211
obv 2.24124288559
ctb 2.69798088074

Obviously, obvious_reverse is the way to go...

The behavior of that map statement is confusing to me; perhaps it will
be clearer in the morning.

--titus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bench.py
Type: text/x-python
Size: 883 bytes
Desc: not available
Url : http://lists.idyll.org/pipermail/biology-in-python/attachments/20080117/94ad3dbe/attachment.py 


More information about the biology-in-python mailing list