in reply to Tallying overall frequency of characters in a set of strings by position
#!/usr/bin/perl # http://perlmonks.org/?node_id=1162755 use strict; use warnings; my %score; chomp(my @array = <DATA>); for my $i (1..@array) { $score{$1}[$-[0]] += 1/@array while $array[$i - 1] =~ /(.)/g; } printf " " . "%5s " x @array . "\n", sort keys %score; for my $pos ( 1..length $array[0] ) { printf "%1d" . "%7.2f" x @array . "\n", $pos, map { $score{$_}[$pos - 1] // 0 } sort keys %score; } __DATA__ AABBC BAABC AABBD AACBB
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tallying overall frequency of characters in a set of strings by position
by Anonymous Monk on May 11, 2016 at 15:40 UTC | |
by Anonymous Monk on May 11, 2016 at 16:17 UTC | |
by Anonymous Monk on May 11, 2016 at 16:40 UTC | |
by Anonymous Monk on May 11, 2016 at 16:59 UTC |