Python-script, which should translate 1000 DNA-Seq

2019-07-26 08:32发布

问题:

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.