Guest User

Untitled

a guest
Feb 21st, 2018
147
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. In [75]: from Bio.Seq import Seq
  2.     ...:
  3.     ...: def my_reverse_complement(seq):
  4.     ...:     return Seq(seq).reverse_complement()
  5.     ...:
  6.  
  7. In [76]: import string
  8.     ...: tab = str.maketrans("ACTG", "TGAC")
  9.     ...:
  10.     ...: def reverse_complement_table(seq):
  11.     ...:     return seq.translate(tab)[::-1]
  12.     ...:
  13.  
  14. In [77]: s = 'ATGCGTA'* 100000
  15.  
  16. In [78]: %timeit my_reverse_complement(s)
  17. 100 loops, best of 3: 1.63 ms per loop
  18.  
  19. In [79]: %timeit reverse_complement_table(s)
  20. 1000 loops, best of 3: 1.33 ms per loop
  21.  
  22. In [80]: %timeit my_reverse_complement(s)
  23. 1000 loops, best of 3: 1.54 ms per loop
  24.  
  25. In [81]: %timeit reverse_complement_table(s)
  26. 1000 loops, best of 3: 1.29 ms per loop
RAW Paste Data