已知KEGG数据库中ko_map.tab文件,K——>ko:
目标文件:map——>K
代码示例:
#! /usr/bin/perl -w
use strict;
my %seq;
open IN, "ko_map.tab" or die $!;
while(<IN>){
chomp;
my ($ko,$map) = split(/\t/,$_,2);
my @maps = split(/ /,$map);
foreach my $elis (@maps){
if ( exists $seq{$elis} ) { $seq{$elis} = join(",",$ko,$seq{$elis}); }
else { $seq{$elis} = $ko; }
}
}
close IN;
open OUT, ">map_ko.list" or die $!;
foreach my $keys ( sort { $a <=> $b } keys %seq)
{
my @aa = split(/,/,$seq{$keys});
print OUT "map$keys","\t",$#aa+1,"\t",$seq{$keys},"\n";
}
close OUT;