-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMIT-PS3_MatchingStrings.py
70 lines (52 loc) · 1.58 KB
/
MIT-PS3_MatchingStrings.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Problem Set 3
# Name: Arko Annuk
# Time: 4:30
import re
# target strings
target1 = 'atgacatgcacaagtatgcat'
target2 = 'atgaatgcatggatgtaaatgcag'
# key strings
key10 = 'a'
key11 = 'atg'
key12 = 'atgc'
key13 = 'atgca'
key14 = 'zvd'
key1 = ('a')
key2 = ('atg')
#iterative approach to counting substrings
def countSubStringMatch(target,key):
count = target.count(key)
if key in target:
print('found')
print('The key count is:', count)
else:
print('not found')
#makes it so you can snipe the key placements in string
def subStringMatchExact(target,key):
result = [_.start() for _ in re.finditer(key, target)]
print (str(result))
#derive predefined substrings straight from target
starts1 = [_.start() for _ in re.finditer(key1,target2)]
starts2 = [_.start() for _ in re.finditer(key2,target2)]
#length is the number of chars in firstMatch+1
#mark firstMatch as key1, secondMatch as key 2
def constrainedMatchPair(firstMatch,secondMatch,length):
n = [_.start() for _ in re.finditer(firstMatch,target2)]
k = [_.start() for _ in re.finditer(secondMatch,target2)]
m = (str(length))
print (n)
print (k)
print (m)
for x in k:
for y in n:
if x-y == 2:
print (x)
print (y)
#This compares the list values against eachother
#I need to find all the values of "2", save them as correct value and print
## for ans in [x-y for y in n for x in k]:
## if (ans == 2):
## print (k)
##
## test = [x-y for y in n for x in k]
## print (test)