codepad | about

 Link:

Python, pasted on Aug 19:
 ```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 ``` ```def pairwiseScore(seqA, seqB): prev = -1 score = 0 length = len(seqA) similarity = [] relative_similarity = [] for x in xrange(length): if seqA[x] == seqB[x]: if (x >= 1) and (seqA[x - 1] == seqB[x - 1]): score += 3 similarity.append(x) else: score += 1 similarity.append(x) else: score -= 1 for x in similarity: relative_similarity.append(x - prev) prev = x return ''.join((seqA, '\n', ''.join(['|'.rjust(x) for x in relative_similarity]), '\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') ```

Output:
 ```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ``` ```ATTCGT || | ATCTAT Score: 2 GATAAATCTGGTCT || ||| | CATTCATCATGCAA Score: 4 AGCG | || ATCG Score: 4 ATCG |||| ATCG Score: 10 ```

Comments: