Advertisement
Guest User

cse180

a guest
Jan 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1.  
  2. #matches whether or not two strings are off by d mismatch
  3.  
  4. def isMatch(string1, string2, num_wrong):
  5. mismatch = 0
  6. for i in range(len(string1)):
  7. if string1[i] != string2[i]:
  8. mismatch += 1
  9.  
  10. if mismatch <= num_wrong:
  11. return "true"
  12. else:
  13. return "false"
  14.  
  15. print(isMatch("aaabaaa", "aabaaaa", 2))
  16.  
  17.  
  18.  
  19. sequenced = {}
  20. sequence = "ACGTTGCATGTCGCATGATGCATGAGAGCT"
  21. k = 4
  22. num_wrong = 1
  23.  
  24. #put all of the kmers in sequence into dictionary sequenced
  25. for i in range(len(sequence) - k + 1):
  26. sequenced[sequence[i:i+k]] = 0
  27.  
  28.  
  29.  
  30. final_output = []
  31. temp_output = []
  32. max_matches = 0
  33.  
  34. #going through dictionary and compare to other sequences to see if they're similar
  35. for currKey in sequenced:
  36. for compKey in sequenced:
  37. if isMatch(currKey, compKey, num_wrong) == "true":
  38. sequenced[currKey] += 1
  39. temp_output.append(compKey)
  40.  
  41. if sequenced[currKey] > max_matches:
  42. max_matches = sequenced[currKey]
  43. final_output = temp_output
  44. temp_output = []
  45.  
  46. print(*final_output)
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. """for loop that iterates through all keys in the dict: currKey
  54. for loop that iterates through all keys in the dict: #keythatImcomparingto
  55. # match the current k-mer up with all of the other keys in the dict using isMatch
  56. if isMatch(iejfoaijweofia) is true:
  57. ++value of currKey in the dict, dict[currKey] = dict[currKey] + 1
  58. temp_output.append(keythatImcomparingto) # an array of all stuff that matches
  59.  
  60. if dict[currKey] > max_matches
  61. max_matches = value
  62. final_output = temp_output
  63. temp_output = []
  64.  
  65. print final_output
  66. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement