Please help me with Matlab HW Problem - FOR loop

4 visualizzazioni (ultimi 30 giorni)
Erik
Erik il 13 Ott 2014
Commentato: Erik il 17 Ott 2014
Hello all,
I need help with the last part of my HW. I have created a FOR loop which finds start codons and stop codons in an mRNA strand. The start codon is AUG and the stop codons are UAA, UAG, or UGA. I have correctly found 41 start codons and 90 stop codons in the strand. MC1R.mat with the mRNA strand info is attached. Here is my code.
clear all; close all;
load MC1R;
location_start = (strcmp(mRNA,'aug'));
count1 = sum(location_start);
location_stop = (strcmp(mRNA,'uaa'))+(strcmp(mRNA,'uag'))+(strcmp(mRNA,'uga'));
count2 = sum(location_stop);
for mRNA = 1
fprintf('The total number of start codons is %i.\n', count1)
fprintf('The total number of stop codons is %i.\n', count2)
end
So everything seems right. But the program now needs an adjustment because not all start codons actually start the protein manufacturing process and not all stop codons actually end the process. Once a protein is started, the process continues until a stop codon is found in the mRNA – any extra start codons in the sequence simply produce the amino acid methionine. Similarly, once a protein is completed, the transfer RNA searches for the next start codon in the strand and ignores any extra stop codons in the sequence.
I am given the instruction: Right before the for loop, create a variable called flag and set it equal to 0. You will use this variable to control when you are looking for a start codon and when you are looking for a stop codon. This variable, flag will only take on two possible values, 0 or 1.
flag = 0 means you are looking for a start codon
flag = 1 means you are looking for a stop codon
Using your flag variable, adjust your conditional statements so you are only looking for a start when flag is 0 and you are only looking for a stop when flag is 1. Also, adjust your code so that once you find a start codon, you then begin searching for a stop and once you find a stop codon, you go back to looking for a start codon.
The final fprintf statements should reveal 28 start codons and 28 stop codons when the program is executed correctly. I have tried over and over to set up the flag variable but am failing miserably. Any hints or walkthroughs would be extremely appreciated.
Thanks for your time,
Erik
  4 Commenti
dpb
dpb il 13 Ott 2014
Not only did you initialize flag outside the loop, you don't have a loop.
Think about how you would find these by hand beginning from the beginning of the string and look for the next appropriate point and changing what you're looking for when find the first...
Where you do have a loop there's no point (which is clear since you run it over only 1 constant iteration, anyway); the total counts are scalar variables.
Erik
Erik il 17 Ott 2014
Figured it out. Thanks for the help.
clear all; close all;
load MC1R;
countstart=0;
countstop=0;
flag=0;
for k = 1:3366
if strcmp(mRNA(k),'aug') && flag==0
countstart=countstart+1;
location_count_start=k;
flag = flag +1;
elseif (strcmp(mRNA(k),'uaa') || strcmp(mRNA(k),'uag') || strcmp(mRNA(k),'uga')) && flag==1
countstop=countstop+1;
location_count_stop=k;
flag = flag -1;
end
end
fprintf('The total number of start codons is %i and the total number of stop codons is %i. \n',countstart,countstop)

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by