0

I can't figure out why just only one is not correct. I really need to understand this. Please, help me

import sys
import csv
# Open sequence file
sequence_file = open(str(sys.argv[2]), 'r')
sequence_cursor = sequence_file.read()
sequence = str(sequence_cursor)
# Open database and copy in a dictionary struture
result_dic = []
with open(str(sys.argv[1]), 'r') as arquivo_dict:
    leitorDic = csv.DictReader(arquivo_dict, delimiter=',')
    for row in leitorDic:
        result_dic.append(row)
# Gets the longest sequence for each STR
STRs = ['AGATC', 'AATG', 'TATC']
result = [0, 0, 0]
i = 0
for strs in STRs:
    counter = 0
    str_temp = strs

    while strs in sequence:
        counter += 1
        strs += str_temp
    result[i] = counter
    i += 1
# Match the results and print the right name
j = 0

for person in result_dic:
    if int(result_dic[j]['AGATC']) == result[0] and int(result_dic[j]['AATG']) == result[1] and int(result_dic[j]['TATC']) == result[2]:
        print(result_dic[j]['name'])
        exit()
    j += 1
print('No match')
exit()

enter image description here

1

My mistake was hard coding STRs[] and result[] Here the correction

STRs = []
for key in result_dic[1]:
    if not key == 'name':
        STRs.append(key)
# Gets the longest sequence for each STR
result = [0] * len(STRs)
i = 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .