replicant4 has asked for the wisdom of the Perl Monks concerning the following question:
also I nedd the same thing for the next block of code.sub get_Hx{ my $site = $_[0]; my $no_of_sequences =length($site); my $sum = 0; foreach(qw/A C D E F G H I J K L M N P Q R S T V W Y _ \./){ my $count = () = $site =~ /$_/g; $sum += -($count/$no_of_sequences)*log_2($count/$no_of_sequences) +if($count > 0); } return $sum; }
By case insensitive I mean that whenever my program finds an A or an a it should do countA +2 and not two different counters. Thanks for anyone's helpmy $site1; my $site2; my $l=0; foreach $site1 (@site1) { my @site1_parts = split(//, $site1); $l++; my $j=0; my $mutual; my $Hx= get_Hx($site1); #print "$Hx\n"; foreach $site2 (@site2) {#begining of loop2 for each site 2 $j++; my $Hy = get_Hx($site2); my $Hxy; my %counts; my @count_collection; my @site2_parts = split(//, $site2); my $i = @site1_parts; $counts{get_index($site1_parts[$i], $site2_parts[$i])}++ while + ($i--); push(@count_collection, \%counts); foreach my $counts (@count_collection) { my $total; foreach (sort keys %$counts) { #print "$counts{$_}\n"; my $freq = $counts->{$_}/length($site1); my $MI = -$freq * log_2$freq; #$total +=$freq; $Hxy +=$MI; } #print "$Hxy \ $Hx\ $Hy \n"; $mutual = $Hx + $Hy - $Hxy; } print " $l,$j,$mutual\n"; #print " $l,$j\n"; #print($_, ': ', $counts{$_}, $/) foreach (sort keys %counts); #print($/); }#end of loop2 for each site2 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: making my suroutine and parts of my program case insensitive.
by The Mad Hatter (Priest) on Oct 31, 2004 at 12:21 UTC | |
|
Re: making my suroutine and parts of my program case insensitive.
by Happy-the-monk (Canon) on Oct 31, 2004 at 12:19 UTC |