2012-03-05 59 views
0

私はこのスコアリング機能を働かせるのが難しいです。私のプログラムの目的は、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 
+2

としてそれにアクセスすることはできませんdef Score(s, i, l, **dna)

を使用する場合は、あなたの変数dna辞書、 ですインデントされる。とにかく、最初にエラーメッセージを見て、**どこにエラーが発生したかを判断してください。 –

答えて

0

ので、それはint変数である場合は、これはあなたが意味する方法である*だと思う私は* dna[j][s[j]:s[j]+l]

+0

いいえ、私は変数として辞書に入れませんでした。それは助けるだろう......私のdnaはこのdna = "tactagcaat"、 "acgcttgcgt"、 "cggtggttaa"で構成されています – user1238097

+0

は 'dna'文字列のリストです – avasal

関連する問題