Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop help

Status
Not open for further replies.

tsbatth

Programmer
Mar 5, 2008
7
US
hi im writing this code to determine number of start codons after but I keep getting an error, this is the following code

RNAseq = split('', $RNA);
$nstart = 0; #number of start codons
$start = 'AUG';
for ($i=0; $i<$mlength -2; $i ++)
{
@codon = @RNAseq[$i, $i+1, $i+2];
$cod = join('', @codon);
if ($cod eq $start)
{
$start[$nstart]= $i;
$nstart ++;
}
}
print "\n Number of start codons is: $nstart";

I get an error saying name "Main:mlength" used only once and a possible typo at that line. Any help please?
 
yeah.. mlength was used only once. It isn't established anywhere.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
well.. I don't really understand what your trying to do. Apparently you want to loop while $i < $mlength. Here do you plan on getting this mlength value from?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
i am trying to find the start codon in a sequence, the start codon is a 3 letter sequence from rna 'AUG', i dont understand this mlength part, i got this piece of code from somewhere else. My guess would be that its supposed to be position of start codon?
 
So your just trying to see how many times AUG shows up in @RNAseq?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
$count = grep /AUG/, @RNAseq;
print "$count\n";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
thanks, but i have to do it this way so i can get the position of the start codon, anyway i can make this work?
 
i set $mlength = @RNAseq but after it gives me the number of start codons, the program freezes well dos freezes and nothing more, i have to restart dos
 
I think it's a fair assumption that most the people here don't know much about DNA/RNA sequences, or at least I don't.

If this isn't what you're looking for you might want to explain what you want with a more specific example.
Code:
use warnings;
use strict;

my $rna = 'GUCCAUGACUAGA';
my $start = 'AUG';
my $nstart;

if ($rna =~ m/^(.*?)$start/) {
	$nstart = length $1;
	print "Number of start codons is: $nstart\n";
} else {
	print "$start not found.\n";
}
Also, I'm not sure if 'AUG' is supposed to be included or not. In the example above, would you expect 4 or 7 to be printed? If $start is supposed to be included, move the right paren to the other side of $start.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top