I am trying to find a way to read and transcribe a list of DNA sequences (list of lists) only when the for loop finds a start codon (triplet of the list items) and until it finds a stop codon, over and over, but the if function will only transcribe the first codon and won't go through the whole sequence.
I'm trying to do this with a mix of normal python and biopython functions cause I think it's simpler.
This is an example:
Start codon: ATG
Stop codon: TAG
gene_1= 'ACGGACTATTC'
gene_2= 'GGCCATGAGTAACGCATAGGGCCC
gene_3=GGGCCCATGACGTACTAGGGGCCCATGCATTCATAG
So, the first gene does not contain any transcript, whereas the second contains 1 and the third contains 2. I'm trying to get rid of everything outside these reading frames and append these transcripts into a list that should look something like this.
mRNAs = ['AGUAACGCA', 'ACGUAC', 'CAUUCA']
This is what I have so far:
genelist=[]
gene_1= 'A','C','G','G','A','C','T','A','T','T','C'
gene_2= 'G','G','C','C','A','T','G','A','G','T','A','A','C','G','C','A','T','A','G','G','G','C','C','C'
gene_3='G','G','G','C','C','C','A','T','G','A','C','G','T','A','C','T','A','G','G','G','G','C','C','C','A','T','G','C','A','T','T','C','A','T','A','G'
genelist.append(gene_1)
genelist.append(gene_2)
genelist.append(gene_3)
def transcription(ORF):
mRNA= ''
for i in range(0, len(ORF), 3):
codon= ORF[i:i+3]
if codon != 'ATG':
next(codon)
if codon == 'ATG':
mRNA=codon.transcribe()
if codon == 'TAG':
break
return(mRNA)
mRNAs=[]
for gene in genelist:
for codon in gene:
mRNA= transcription(codon)
mRNAs.append(mRNA)
print(mRNAs)
But it is not really giving anything back, I wonder if the code it's too redundant and I really don't need to define a function here, do you know any better way to do this? Thaaanks!!
print
statements to see what you are actually processing. You are callingmRNA= transcription(codon)
. What is the value ofcodon
? Isn't it a single base? Isn't your function expecting an array instead? have you even tried running this? Don't you get an error message? $\endgroup$