- 论坛徽章:
- 8
|
回复 1# G比蒙 - #!/usr/bin/perl -w
- my (%h,%ck);
- while(<DATA>){
- chomp;
- my($kn, $seq) = (split /、/);
- my @all = (split //,$seq);
- if($kn eq 'ck'){
- map{$ck{$_}=$all[$_]}(0..$#all);
- }else{
- map{push @{$h{$_}},$all[$_] unless $all[$_] eq 'N';}(0..$#all);
- }
- }
- foreach my $i (sort keys %h){
- my $num = grep/$ck{$i}/i,@{$h{$i}};
- my $ratio = get_ratio($num, @{$h{$i}});
- print "$i\t$ck{$i}\t$num\t$ratio\n";
- }
- sub get_ratio(){
- my($num, @all) = @_;
- my $a = scalar @all;
- sprintf( "%.2f", 1 - $num/$a ) * 100 . '%';
- }
- __DATA__
- 1、CTATATAT
- 2、CTATGTAT
- 3、ATATNTAT
- 4、ATATATAT
- ck、ATATATAT
复制代码 |
|