"Aiguo Li" <[EMAIL PROTECTED]> wrote in message...
> Hello,
Hello.
> I have the following dataset and want to calculate a P/A ratio for each
> replicates in the dataset. In this case, treatment 1 has 4 replicats and
> treatment2 has 3 replicates. The P/A = [((#of P)*2) + (# of M)]/# of
> replicates. The output should be two columns of P/A ratios for two
> treatments.
Your explanation doesn't make much sense to me. Maybe it's just me.
;-)
Is the line starting with "Replicates" a header row? I gleaned from your
code that
P/A = (2p + m)/a
where p, m, and a equal the number of P's, M's, and A's respectively on a
row. If this is true, what is to be done when a row is missing A, M, or P?
Of course, if A is missing then the equation is undefined because you have
zero in the denominator. You also state that the output should be two
columns, yet in your code you print $a, $m, and $p but nothing else.
It would be helpful if you took one record from below then manually compute
the two columns you want printed.
> Dataset:
> Replicates 1 1 1 1 2 2 2
> AFFX-BioB-5_at P P P P P P P
> AFFX-BioB-M_at P P P P P P P
> AFFX-BioB-3_at P P P A A P P
> AFFX-BioC-5_at P P P P P P P
> AFFX-BioC-3_at P P P P P P P
> AFFX-BioDn-5_at P P M P P P P
> AFFX-BioDn-3_at P P P P P P P
> AFFX-CreX-5_at P P P P P P P
> AFFX-CreX-3_at P P P P P P P
> AFFX-DapX-5_at A A P A A P A
> AFFX-DapX-M_at A A A A A A A
> AFFX-DapX-3_at A A A A A A A
> AFFX-LysX-5_at A A A P A A A
> AFFX-LysX-M_at A A A A A A A
> AFFX-LysX-3_at A A A A P M A
> AFFX-PheX-5_at A A A A A A A
> AFFX-PheX-M_at A A A A A A A
> AFFX-PheX-3_at A A A A A A A
>
>
> I have made this far with the following code, but have not been able to
make
> the code work yet. Could anybody shed some light on it?
>
> Thanks,
>
> AG
>
> #!usr/bin/perl -w
>
> use strict;
> use warnings;
>
> my @split;
> my @replicate = ( 5, 3);
> my @ratio;
> my $p=0;
> my $m=0;
> my $a=0;
> my $rep=0;
> my $item;
> my $ratio;
>
>
> open (FILE, "<C:/replicate.txt") or die "Can't open file: $!";
>
>
> while( <FILE> )
> {
> #print;
> chomp;
> @split = split (/\t/, $_);
> push (@split, $_);
> #print "$_ \n";
> foreach $rep (@replicate)
> {
> for(my $i=1; $i<=$rep; $i++)
> {
> push (@split, $_);
> SWITCH:
> if ($_ =~ "P") {$p++; last SWITCH;}
> if ($_ =~ "M") {$m++; last SWITCH;}
> if ($_ =~ "A") {$a++; last SWITCH;}
> }
> print $p, $m, $a;
> @ratio = (($p*2)+$m)/$a;
>
>
>
>
> }
> }
>
> close FILE;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>