-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscoring.py
More file actions
107 lines (99 loc) · 3.25 KB
/
scoring.py
File metadata and controls
107 lines (99 loc) · 3.25 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
def MatchQuality(seq1, seq2):
'''
Inputs: seq1 & seq2 are FASTA sequences obtained from genome
sequencing
Return: Score describing quality of the match based on:
+1 for each matching basepair
-1 for each mismatching basepair
+0 for missing partner/gap
'''
matchcounter = 0
for x in range(len(seq1)):
seq1char = seq1[x]
seq2char = seq2[x]
if seq2char == seq1char:
if seq1char == '-' and seq2char == '-':
matchcounter = matchcounter
else:
matchcounter = matchcounter + 1
elif seq2char == '-':
matchcounter = matchcounter
elif seq1char == '-':
matchcounter = matchcounter
elif x == (len(seq1)+1):
break
elif x == (len(seq2)+1):
break
else:
matchcounter = matchcounter - 1
return matchcounter
def MatchQuality(seq1, seq2):
'''
Inputs: seq1 & seq2 are FASTA sequences obtained from genome
sequencing
Return: Score describing quality of the match based on:
+1 for each matching basepair
-1 for each mismatching basepair
+0 for missing partner/gap
'''
bestmatch = 0
for i in range(abs(len(seq1) - len(seq2))+1):
matchcounter = 0
if len(seq1) > len(seq2):
length = range(len(seq2))
else:
length = range(len(seq1))
for x in length:
if len(seq1) > len(seq2):
seq1char = seq1[x+i]
seq2char = seq2[x]
elif len(seq2) > len(seq1):
seq1char = seq1[x]
seq2char = seq2[x+i]
else:
seq1char = seq1[x]
seq2char = seq2[x]
if seq2char == seq1char:
if seq1char == '-' and seq2char == '-':
matchcounter = matchcounter
else:
matchcounter = matchcounter + 1
elif seq2char == '-':
matchcounter = matchcounter
elif seq1char == '-':
matchcounter = matchcounter
else:
matchcounter = matchcounter - 1
if matchcounter > bestmatch:
bestmatch = matchcounter
mseq1='-'
mseq2='-'
time = 0
if len(seq1) > len(seq2):
while time < i:
mseq2 += mseq2[0]
time += 1
mseq1 += seq1
mseq2 += seq2
time = 0
while time < (abs(len(seq1) - len(seq2)) - i):
mseq2 += mseq2[0]
time += 1
elif len(seq2) > len(seq1):
while time < i:
mseq1 += mseq1[0]
time += 1
mseq1 += seq1
mseq2 += seq2
time = 0
while time < (abs(len(seq1) - len(seq2)) - i):
mseq1 += mseq1[0]
time += 1
else:
mseq1 += seq1
mseq2 += seq2
mseq1 += mseq1[0]
mseq2 += mseq2[0]
print mseq1
print mseq2
return bestmatch