in reply to Can't think of an algorithm to go..
sub consensus { $rest='-'; my %counts; $counts{$_}++ for @_; my ($consensus) = sort { $counts{$b} <=> $counts{$a} } keys(%counts); return ( $counts{$consensus} / @_ >= 0.7 ? $consensus : $rest ); } while(<>) { $consensus = ''; @total_seqs=(); $seq=$_; push @total_seqs,$seq; for $i (0..length($seq)-1) { $consensus.= consensus( map substr($_, $i, 1), @total_seqs ) +; } }print("CON:$consensus\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't think of an algorithm to go..
by Anonymous Monk on Jun 14, 2009 at 09:32 UTC |