I have two strings in python that I have converted to lists:
Seq1 = [x1,x2,x3,x4]
Seq2 = [y1,y2,y3,y4]
The strings are the same length and are composed of only the letters 'a', 'c', 'g', and 'u'.
Then I created an empty matrix len(Seq1) by len(Seq2):
a = numpy.zeros(shape=len(Seq1),len(Seq2))
Next, I want to compare the list values and place a 1 if the values match and 0 if they don’t. The value should be placed in the relevant array element
i.e.
if seq1[0] == seq[0]:
a[0,0] = [1]
else:
a[0,0] = [0]
# repeat for all the values.
print a
I had a loop that was working but it only filled in the first row and column. I can see that it’s a problem with a range function like Seq1[i] == Seq2[j] but I can’t figure it out.
A compact way to write the loop is: