私はこのスコアリング機能を働かせるのが難しいです。私のプログラムの目的は、t×n行列を作り、コンセンサス配列を見つけることです。コンセンサス配列の助けを借りて
私はエラーを取得しておいてください。
TypeError: 'int' object is not subscriptable.
任意の助けをいただければ幸いです。
def Score(s, i, l, dna):
t = len(dna) # t = number of dna sequences
# Step 1: Extract the alignment corresponding to starting positions in s
alignment = []
for j in range(0, i):
alignment.append(dna[j][s[j]:s[j]+l])
# Step 2: Create the corresponding profile matrix
profile = [[],[],[],[]] # prepare an empty 4 x l profile matrix first
for j in range(0, 4):
profile[j] = [0] * l
for c in range(0, l): # for each column number c
for r in range(0, i): # for each row number r in column c
if alignment[r][c] == 'a':
profile[0][c] = profile[0][c] + 1
elif alignment[r][c] == 't':
profile[1][c] = profile[1][c] + 1
elif alignment[r][c] == 'g':
profile[2][c] = profile[2][c] + 1
else:
profile[3][c] = profile[3][c] + 1
# Step 3: Compute the score from the profile matrix
score = 0
for c in range(0, l):
score = score + max([profile[0][c], profile[1][c], profile[2][c], profile[3][c]])
return score
としてそれにアクセスすることはできません
def Score(s, i, l, **dna)
を使用する場合は、あなたの変数
dna
辞書、 ですインデントされる。とにかく、最初にエラーメッセージを見て、**どこにエラーが発生したかを判断してください。 –