in reply to Can't think of an algorithm to go..

Ikegami, thanks again... Here is what I have added to what you wrote beforehand:
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
    I think I found it...
    I didn't need to have @total_seqs=(); inside my loop...
    now I have the same results as you...
    Thanks again for everything!