• 计算蛋白质一致率


     1 #!/usr/bin/perl
     2 
     3 use strict;
     4 use warnings;
     5 
     6 my $input = $ARGV[0];my $name = $ARGV[1];my $start = $ARGV[2];my $cut_start=$ARGV[3];my $cut_end=$ARGV[4]; 
     7 
     8 my $all_start=$ARGV[5];my $all_end =$ARGV[6];
     9 
    10 my $cut = &store ($input);my %cut = %$cut;
    11 
    12 my ($list,$average) = &count(%cut);
    13 
    14 print "$name	$list	$average	$cut_start	$cut_end	$all_start	$all_end
    ";
    15 
    16 #####sub########
    17 
    18 sub count{
    19     
    20     my %cut = @_;
    21     
    22     my @arr;my @all;
    23     
    24     foreach my $key(keys %cut)
    25     {
    26         my $long = $cut{$key};my @split = split //,$long;
    27         
    28         push @arr,[@split];
    29     }
    30     
    31     my $i=0;my $j=0;
    32 
    33     for($j=0;$j<10;$j++)
    34     {
    35         my %list;        
    36         
    37         for($i=0;$i<$#arr+1;$i++)
    38         {
    39             $list{$arr[$i][$j]}++; 
    40         }
    41         
    42         my $key = (sort {$list{$b} <=> $list{$a}} keys%list)[0];
    43         
    44         my $max = $key eq '-'?0:$list{$key};
    45         
    46         my $rate = $max/($#arr+1);
    47         
    48         $all[$j]=sprintf "%.2f",$rate;
    49     }
    50     
    51     my $list = join("|",@all);
    52 
    53     my $sum =0;
    54     
    55     foreach(@all)
    56     {
    57         $sum += $_;
    58     }
    59     
    60     my $average = $sum/10;  
    61     
    62     return $list,$average;
    63 }
    64 
    65 sub store{
    66     
    67     open FA,$input;
    68 
    69     my @arr;
    70 
    71     my $id;
    72 
    73     my %cut;
    74 
    75     while(my $line = <FA>)
    76     {
    77         chomp $line;
    78 
    79         if($line =~ />(w*)/)
    80         {
    81             $id = $1;
    82         }
    83         else
    84         {
    85             $cut{$id} = substr ($line,$start-1 ,10);
    86         }
    87     }
    88     return %cut;
    89 }
  • 相关阅读:
    Linux提供哪些功能
    C++——重载原理分析
    C++——多维数组动态开辟与释放
    C++——异常处理
    C++——流类库和输入/输出
    C++——virtual function
    C++——虚函数表解析
    C++——多态实现原理分析
    Python基础——__name__变量
    DNS服务——智能域名解析、镜像Web站点、直接域名泛域名
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11099724.html
Copyright © 2020-2023  润新知