in reply to Position Weight Matrix of Set of Strings
I think this meets the spec
#! perl -slw use strict; my %pwm; while( my $line = <DATA> ) { chomp $line; ++$pwm{ substr $line, $_, 1 }[ $_ ] for 0 .. length( $line ) -1; } my $n = $.; @$_ = map{ $_ ? $_ / $n : 0 } @$_ for values %pwm; print "$_ => @{ $pwm{ $_ } }" for keys %pwm; __DATA__ AAA ATG TTT GTC
Produces
C:\test>530623 A => 0.5 0.25 0.25 T => 0.25 0.75 0.25 C => 0 0 0.25 G => 0.25 0 0.25
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Position Weight Matrix of Set of Strings
by monkfan (Curate) on Sep 06, 2006 at 08:49 UTC | |
by BrowserUk (Patriarch) on Sep 06, 2006 at 09:41 UTC | |
by neversaint (Deacon) on Sep 07, 2006 at 02:31 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2006 at 03:55 UTC | |
by monkfan (Curate) on Sep 19, 2006 at 01:05 UTC | |
|