-
Notifications
You must be signed in to change notification settings - Fork 1
/
hd_paper_listings.py
43 lines (39 loc) · 1.34 KB
/
hd_paper_listings.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from string_comparison import StringComparator
# Listing 1
target = '10110'
db = ['10110', '11010', '01110', '01001']
x = StringComparator(target, db)
results = x.run()
print(f"D = {results['hamming_distances']}")
assert(results['hamming_distances'] == [0, 2, 2, 5])
# Listing 2
target = ['foo', 'quux', 'foo']
db = [['foo', 'quux', 'bar'],
['foo', 'bar', 'foo'],
['bar', 'foo', 'foo'],
['foo', 'bar', 'bar']]
x = StringComparator(target, db, is_binary=False)
results = x.run()
print(f"D = {results['hamming_distances']}")
assert(results['hamming_distances'] == [1, 1, 2, 2])
# Listing 3
target = ['C', 'G', 'A', 'A', 'T', 'T']
db = [['C', 'G', 'A', 'A', 'T', 'T'],
['C', 'C', 'A', 'A', 'C', 'C'],
['G', 'A', 'A', 'A', 'G', 'A'],
['C', 'G', 'A', 'T', 'A', 'T']]
x = StringComparator(target, db,
is_binary=False, shots=10000)
results = x.run()
print(f"D = {results['hamming_distances']}")
assert(results['hamming_distances'] == [0, 3, 4, 2])
# Listing 4
target = ['AUG', 'ACG', 'CCC']
db = [['AUG', 'ACG', 'CUU'],
['GAG', 'CGC', 'CCC'],
['AAA', 'ACG', 'UUU'],
['AGA', 'GAG', 'UUU']]
x = StringComparator(target, db, is_binary=False)
results = x.run()
print(f"D = {results['hamming_distances']}")
assert(results['hamming_distances'] == [1, 2, 2, 3])