Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Excersice 8
- try:
- sprot = input('Please insert a filename')
- infile = open(sprot, 'r')
- except IOError as error:
- print("We have a problem opening the file, due to:", str(error))
- sys.exit(1)
- dna = ''
- startCodon = 0
- stopCodon = 0
- for line in infile:
- if line[0] != '>':
- dna += str(line[:-1])
- for base in range(len(dna)):
- if (dna[base:base+3] == 'ATG' and base > stopCodon):
- startCodon = base
- iterations = (len(dna) - startCodon) / 3
- for i in range(iterations):
- index = i * 3 + startCodon
- if (dna[index:index+3] == 'TAA' or dna[index*3:index*3+3] == 'TAG' or dna[index*3:index*3+3] == 'TGA'):
- stopCodon = index
- print('The start codon is:', startCodon + 1, 'and the coresponding stopcodon is:', stopCodon + 1) #print +1 since python counts from 0 and not 1.
- break
- infile.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement