Python-script, which should translate 1000 DNA-Sequences to proteins by 1152 different codontables, don't work

怎甘沉沦 提交于 2019-12-11 04:33:05

问题


Now I'm working on bioinformatics project for my diploma work. I have written Python-script, which should translate the list of strings of 1000 DNA-Sequences to proteins by 1152 different codontables (genetics codes). This codontables are contained in a list of dictionaries, which were received by shuffling of keys and values (codons and amino acids). I want, what this script translates 1000 Sequences in 1152 ways in one go mileage in IPython console or just in Python-3.6 IDLE. This script was written in Spyder 3.2.7. I tried a lot of ways to fix my code, but my script doesn't run. There is my code:

file = open('F:\\біоінформатика\\DNA_Sequence72 - Копія.py', 'r')
DNA = file.read()
DNA_Sequences = DNA.split(',')
Genetic_Codes = open('F:\\біоінформатика\\Genetic_Codes.py', 'r')
Genetic_Codes = Genetic_Codes.read()
Genetic_Codes_list = Genetic_Codes.split('\n')
for row in Genetic_Codes_list: #for str in list[Genetic_Codes_list] in range(1152):   
    Alternative_Genetic_Codes = Genetic_Codes_list.pop(0)
    for dna in range(1000):
        dna = DNA_Sequences.pop(0)
        codontable = Alternative_Genetic_Codes
        codontable_sequence = ""
        for i in range(0, len(dna)-(3+len(dna)%3), 3):
            if codontable[dna[i:i+3]] == "_":
                break
            codontable_sequence += codontable[dna[i:i+3]]
        print(list([codontable_sequence]))

After running I get such error:

File "", line 8, in

if codontable[dna[i:i+3]] == "_":

TypeError: string indices must be integers There is a screenshot of variables after script running: enter image description here I will be very thankful for your help.

来源:https://stackoverflow.com/questions/49653119/python-script-which-should-translate-1000-dna-sequences-to-proteins-by-1152-dif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!