I am trying to write a code where the user inputs a string of RNA and is told whether a stop codon and start codon exists. In order to "start" the string must have 'AUG' and to stop it needs 'UGA,' 'UAG', or 'UAA'. For some reason my code won't run. Any suggestions?
From simple inspection, it doesn't appear to. A stop codon is not detected if it occurs before a start codon or if a start codon is not detected. That may or may not be reasonable given the ambiguity of the OP's sample output. However, only 1 out of 3 possible stop codons is detected which clearly doesn't do what he wants.
So I even extract the RNA sequence as a bonus. If you just see if a certain start colon or a stop colon is there in the sequence that would be very easy.
Which sequence do you extract if only a stop codon is present? If there is more than one sequence present? If there is more than one stop codon present after a single start codon? If two start codons precede any number of stop codons?
It seems like your reach may be exceeding your grasp as far as your bonus goes.
OP: I'm not sure how familiar you are with std::regex, so I'm not providing a step by step breakdown of the program. You already have a perfectly good solution to your problem but in case you're interested in exploring std::regex for this or future problems you can start here: http://www.cplusplus.com/reference/regex/ECMAScript/ and then wherever google takes you and finally come back here if something is still unclear