2012-03-05 5 views
0

이 채점 기능을 작동시키는 데 어려움이 있습니다. 우리 프로그램의 목표는 t x n 행렬을 만들고 합의 순서를 찾는 것입니다. 어떤 도움을 주시면 감사하겠습니다컨센서스 시퀀스 도움말 (파이썬에서)

TypeError: 'int' object is not subscriptable.

:

가 나는 오류가 계속. 그래서 def Score(s, i, l, **dna)

를 사용하는 경우가 int 변수 인 경우

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

로 액세스 할 수 없습니다 들여 쓰기를해야합니다. 어쨌든 오류 메시지를 먼저보고 ** 오류가 발생한 위치를 확인하십시오. –

답변

0

이 변수 dna 사전, , 당신은 내가 *이 당신을 위해 의미 어떻게 생각 * dna[j][s[j]:s[j]+l]

+0

아니요. 사전으로 변수를 입력하지 않았습니다. 그게 도움이 될까 ...... 내 dna = dact = "tactagcaat", "acgcttgcgt", "cggtggttaa" – user1238097

+0

은'dna' 문자열 목록 – avasal