def pairwiseScore(seqA, seqB):
score = 0
bars = [str(' ') for x in seqA] #create a list filled with number of spaces equal to length of seqA string. It could be also seqB, because both are meant to have same length
length = len(seqA)
similarity = []
for x in xrange(length):
if seqA[x] == seqB[x]: #check if for every index 'x', corresponding character is same in both seqA and seqB strings
if (x >= 1) and (seqA[x - 1] == seqB[x - 1]): #if 'x' is greater than or equal to 1 and characters under the previous index, were same in both seqA and seqB strings, do..
score += 3
similarity.append(x)
else:
score += 1
similarity.append(x)
else:
score -= 1
for x in similarity:
bars[x] = '|' #for every index 'x' in 'bars' list, replace space with '|' (pipe/vertical bar) character
return ''.join((seqA, '\n', ''.join(bars), '\n', seqB, '\n', 'Score: ', str(score)))
print pairwiseScore("ATTCGT", "ATCTAT"), '\n', '\n', pairwiseScore("GATAAATCTGGTCT", "CATTCATCATGCAA"), '\n', '\n', pairwiseScore('AGCG', 'ATCG'), '\n', '\n', pairwiseScore('ATCG', 'ATCG')