Hi, all.

I have the following dataset and need 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.

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

Use strict;
Use warning;

My @split;
My @replicate = ( 4, 3);
My @ratio;
My $p=0, $m=0, $a=0, $rep=0, $i;

Open (IN, "C:\replicate.txt") or die "can not open file\n";

While (<IN>) {
        @split = split (/\t/, $_);
        foreach $rep (@replicate)
        {
                for(my $i=0; $i<$rep; $i++)
                {
                        foreach $item (@split);
                                {
                                if ($item == "P")
                                        {
                                        $p = $p +1;
                                        }
                                elseif ($item == "M")
                                        {
                                        $m = $m +1;
                                        }
                                else ($item == "A")
                                        {
                                        $a = $a +1;
                                        }
                                @ratio = (($p*2)+$m)/$a;
                                print push (@ratio, $ratio);
                                }
                }
        }
}

I have not been able to make this work yet.  I would be appreciative of any
suggestions or help.

Thx in advance,

Aiguo Li
                

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to