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.

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>


Reply via email to