Question: Hi:) I have this function that gets a sequence and returns a mat of all the wanted codons (sub-sequence). however I need the mat to

Hi:) I have this function that gets a sequence and returns a mat of all the wanted codons (sub-sequence). however I need the mat to have the coordinates of the codons and not the codons. I tried changing it by adding sequence.index() but it doesn't work. this is the out put that I'm getting now (a summarized version): ['ATGCAA', 'ATGTCAA', 'ATGGA'] and this is for example what I should get: [[2,10],[7,18]]

how can I change it to show the coordinates?

the code:

sequence= open("seq_3b.txt", "r").read() def find_orf(sequence): # Find all ATG indexs. ATG is usually the start codon for the Methionine start start_position = 1 start_indexs = [] stop_indexs = [] for i in range(1, len(sequence), 3): if sequence[i:i+3] == "ATG": start_indexs.append(i)

# Find all stop codon indexs. for i in range(1, len(sequence), 3): stops =["TAA", "TAA", "TGA"] if sequence[i:i+3] in stops: stop_indexs.append(i)

Xnum_ORFs2 = [] mark = 0 for i in range(0,len(start_indexs)): for j in range(0, len(stop_indexs)): if start_indexs[i] < stop_indexs[j] and start_indexs[i] > mark: Xnum_ORFs2.append(sequence[start_indexs[i]:stop_indexs[j]+3]) mark = stop_indexs[j]+3 break return Xnum_ORFs2

print (find_orf(sequence))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!