The program should find the substrings in a given string and count their number of occurrences. Moreover the substring must check the occurrences only for every three alphabets.
for eg: String: AGAUUUAGA
output:
AGA-2 UUU-1
print"Enter the mRNA Sequence\n";
$count = 0;
$count1 = 0;
$seq = <>;
chomp($seq);
$p = '';
$ln = length($seq);
$j = $ln/3;
for($i=0,$k=0;$i<$ln,$k<$j;$k++)
{
$fra[$k]=substr($seq,$i,3);
$i=$i+3;
if({$fra[$k]} eq AGA)
{
$count++;
print"The number of AGA is $count";
}
elseif({$fra[$k]} eq UUU)
{
$count1++;
print" The number of UUU is $count1";
}
}
downvote - it's tagged as homework and not a question.
@Casbon Please note that the tags can be edited by someone else than the OP, as is the case here. The homework tag has been added by another user with admin rights. I agree that Payaliya should make a greater effort when posting questions.
which error are you getting? What is the expected output?
I have reformatted the code to make it easier to read on this website. Please use the "Code block" button when posting code. Moreover, I've improved the spelling of your question and the title, check whether it is ok.
What is the question?
Payaliya please stop editing the title of the question when you think it should be [closed] - questions are not 'closed' just because there is a single acceptable answer, they are closed for being off-topic or duplicated, or not a real question!