KEGG数据库整理示例
2020-06-28 本文已影响0人
生物信息与育种
已知KEGG数据库中ko_map.tab文件,K——>ko:
image.png
目标文件:map——>K
image.png
代码示例:
#! /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;