Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #matches whether or not two strings are off by d mismatch
- def isMatch(string1, string2, num_wrong):
- mismatch = 0
- for i in range(len(string1)):
- if string1[i] != string2[i]:
- mismatch += 1
- if mismatch <= num_wrong:
- return "true"
- else:
- return "false"
- print(isMatch("aaabaaa", "aabaaaa", 2))
- sequenced = {}
- sequence = "ACGTTGCATGTCGCATGATGCATGAGAGCT"
- k = 4
- num_wrong = 1
- #put all of the kmers in sequence into dictionary sequenced
- for i in range(len(sequence) - k + 1):
- sequenced[sequence[i:i+k]] = 0
- final_output = []
- temp_output = []
- max_matches = 0
- #going through dictionary and compare to other sequences to see if they're similar
- for currKey in sequenced:
- for compKey in sequenced:
- if isMatch(currKey, compKey, num_wrong) == "true":
- sequenced[currKey] += 1
- temp_output.append(compKey)
- if sequenced[currKey] > max_matches:
- max_matches = sequenced[currKey]
- final_output = temp_output
- temp_output = []
- print(*final_output)
- """for loop that iterates through all keys in the dict: currKey
- for loop that iterates through all keys in the dict: #keythatImcomparingto
- # match the current k-mer up with all of the other keys in the dict using isMatch
- if isMatch(iejfoaijweofia) is true:
- ++value of currKey in the dict, dict[currKey] = dict[currKey] + 1
- temp_output.append(keythatImcomparingto) # an array of all stuff that matches
- if dict[currKey] > max_matches
- max_matches = value
- final_output = temp_output
- temp_output = []
- print final_output
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement