Advertisement
Guest User

Untitled

a guest
May 5th, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. for i in range(0,len(nodes)):
  2. fragment = nodes[i]
  3. for l in range(0, length1):
  4. fragment1 = Text[l:int(l)+int(k)]
  5. count = [0]*gen_len
  6.  
  7. for j in range( 0, gen_len ):
  8. if fragment[j] != fragment1[j]:
  9. count[j] = count[j]+1
  10.  
  11. if j == (gen_len-1):
  12.  
  13. if int(sum(count)) <= int(Num_mismatches):
  14. count2[i] = count2[i]+1
  15. result2[i] = fragment
  16. result.append(fragment)
  17.  
  18. if count2[i] > maxval:
  19. maxval = count2[i]
  20.  
  21. from itertools import islice, izip
  22.  
  23. for i in xrange(0,len(nodes)):
  24. fragment = nodes[i]
  25. for l in xrange(0, length1):
  26. # fragment1 was replaced by islice to avoid list creation
  27. # It may or may not be faster. Try timing a version
  28. # where you replace islice(Text, 1, l+k) with Text[l:int(l)+int(k)]
  29. count = sum(f != f1 for f, f1 in izip(fragement, islice(Text, 1, l+k)))
  30. if count <= Num_mismatches:
  31. count2[i] += 1
  32. # code smell: why have both result and result2?
  33. result2[i] = fragment
  34. result.append(fragment)
  35. # you are not using maxval anywhere in these loops.
  36. # you may want to set it after these loops.
  37. if count2[i] > maxval:
  38. maxval = count2[i]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement