-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosalind_hamming(hamm).py
28 lines (19 loc) · 2.51 KB
/
rosalind_hamming(hamm).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
# Diane Kaplan
# Rosalind Problem: hamm (counting point mutations)
# May 30, 2015
DEBUG = True
# hamming_distance finds the number of differences between two sequences:
# compare values for inequality at each position in the sequence and increment counter
def hamming_distance (seq, comparison_seq):
cursor = 0
string_length = len(seq)
difference_counter = 0
while cursor < string_length: #ours are all the same length, could also add a check/flexbility
if seq[cursor] != comparison_seq[cursor]:
difference_counter += 1
cursor += 1
return difference_counter
string1 = 'TTCGAGGCTTTTGCGGACCTTAATCTTTATTGAGTTCCGCTACCTCTCAGCTCAATGACGTTTCGTGTGAATTTTTGTGAGTTCGGGCGGGAAGACCTCGCACCCCCGACACTTTCCCTAAAACTCGGATAGAAATGTTGACGGCCTTCACTGGCAGGGGAATCCCACATCTTGGCGCGTAGTGGTCTGGTGGATAGACAGATGGTACCAGTCGCAAGCGTCTGACTAGTGGCGATGAGTGCTAGACCCACCTAAGGTAACGGCAACGAATTGCTTAATCTACTTCAGGTTAGTAATGTCAGACGGTGTAGCACCCCTAAAGAGAAGGACAGGGGTGGGGCGCGCCAGGCTGATCTCCCGGCCTAATTCAAAGCGGATGTAAACCGTCTAGGTACTCTAGGATGCAGGGCAAGTACAGGACAAATCCTCATCGAGCCTGTACTCTTGCGAATACCGGACCTAGGCTCCTAACTTTGTCCTTTCTGTTACGATGATTGTACGCTAAGAGTTAGAAATTACCATGTCACACGGATTTTCGTCGCCACTAGCTATTCACGCGCACGAGAGTTGGTCTCACTTCTAAACGGTCGTATATGCTTAGATTACAGTATGCCCAGACGGGTTGTCTCTTTAGCCGCTACCATCCACCGGATCGACGACCCCCTAAGATTGGGGGAGAACTCCAGCAATTTCCTAGACAGCCAATCTAGGGGGTCATAAATCCGGGCAATTCCTGTAGTATACCCAATAACCCCAGCATGGCGGATCGCTATGTACATACTAATAACTTGCAACCGGGCCGTCCGACAGACATGCCTTCGCGCTCTATTCCCTAGCCGAGTCTACGCTAACATAAAGGTAGCTTCGAGTGGTGCCGAGTCATCCCCTCGGGAGATCCCCGCTTAACCCCTAAGATCTTGCACAAGAT'
string2 = 'CGTATGACGTTGACGGAAATTGACCCATAGTCTGTTAACGGCCCGGTGATCACCAAGACTGCAGCGAGTAATGGGGGTAAGGTTTGGCTCGCAGACCTGTGCGTCCGTTCTCTTACCCTGAGACTCGAAGCAATATGTGATACGCCTTCAAGGCCAGGCGAATCCCTCGGCTTTGCGAGTAGTTTTACGATGTTCGTAGGGATTCGAACTCGAGCAACCTTCGCCCCGGTCGAAAAGTGTTCTATATCAACCGACGATTCGTGCTACGCAGTCCTGCTCCTGCGCGAGTGAGAATCTCTCACGTGATGCAGCTCCCCGATGATGACTGACTGGCTTGGTTCGCGCAGGGACTTCCCTCCGGTATAAACCCTAGGCGATATCCATTAGGGTTGTAAGCACGAATACAAGGCAACGAAAGTGCAAAAGCTTCCCGCGTGTATTAGCTAGTCATCACTCGTCCTAGGTGACATACCTACGCCAACATAATTAGATGACAATAGACTATTGTCACAAACCCATCTTGTCACCCGAACGACCCTTCACACTCTATTTCACTCAATTTATGATTTGGTGTTTGGGCTCAAGAGAAGTACATGATTATAGCACAGCCTGATACGAAACATTAATGCTTAATCCCTAACCCTAGTTCGCACAGCCGTTCCCGCATTGTTGGAAGACAAATCCTCAAAGATCTAGGGCTGACAATCCACGGCAGCTCGAACGCGTGCATTTGCTGGAGATCACTCCCCATGAGCCTCATAAACTGTCCCTAACTCAGTACGAAAATCATTCTTGACGGCATCCCCCAAGATCTGCTTTCGCGCCCACTGCCGCCGCTGACACAACGCTAAAATAATGTTCGCCGGCCTATCTGAGGGGAATGTTTCTTGTAAATAACCCGGTACAAGGTTATCATCTAGCGGAAGAG'
print hamming_distance(string1, string2)