I wanted a function to compute the Pairwise Alignment Score in Julia, but didn’t find any in the BioJulia repository. I submitted an issue, asking for some guidance, but no response till now. So, after waiting a long time, I resorted to porting my Python implementation into Julia. Here’s what I got:

## Python Implementation

```
def score_pairwise(self, seq1, seq2, matrix, gap=True):
"""Pairwise score generator.
Keyword arguments:
seq1 -- first alignment
seq2 -- second alignment
matrix -- substitution matrix"""
for A, B in zip(seq1, seq2):
diag = ('-' == A) or ('-' == B)
yield (self.gap_extend_score if gap else self.gap_open_score) if diag else matrix[(A, B)]
gap = diag
```

## Julia port

```
function score(S1, S2; matrix=BLOSUM90, gop=-1, gep=-1)
score = 0
prev_gap = false
for (A, B) in zip(S1, S2)
diag = ('-' == A) || ('-' == B)
score += (diag) ? (prev_gap ? gep : gop) : matrix[A, B]
prev_gap = diag
end
score
end
```

**Disclaimer**: I’m pretty new to Julia and I feel this isn’t the best implementation possible and we could improve this a lot. **Any suggestions would be welcome**

## Problem

The result I’m getting from this method is a little bit off from the one I get from the BioJulia package.

I’ve tried it on a number of sequences, and every time it’s a little bit off, sometimes more than BioJulia score and sometimes less.

Can anyone help me in figuring out the problem? I would be very thankful.