Try this
#! perl -slw use strict; use Data::Dumper; sub get_pwm { my @data = @_; my $l = length( $data[0] ); my %pwm; foreach my $line (@data) { ++$pwm{ substr $line, $_, 1 }[$_] for 0 .. $l - 1; } my $n = @data; @$_ = map { $_ ? $_ / $n : 0 } @{ $_ }[ 0 .. $l - 1 ] for values +%pwm; return \%pwm; } my @inst = ( 'CAGGTG', 'CAGGTG' ); my $res = get_pwm(@inst); print "$_ => @{ $res->{ $_ } }" for keys %{ $res }; __END__ c:\test>530623 A => 0 1 0 0 0 0 T => 0 0 0 0 1 0 C => 1 0 0 0 0 0 G => 0 0 1 1 0 1
In reply to Re^5: Position Weight Matrix of Set of Strings
by BrowserUk
in thread Position Weight Matrix of Set of Strings
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |