這個(gè)perl腳本的作用是將Mega等軟件比對(duì)保存的fasta格式的結(jié)果轉(zhuǎn)化為KaKs_Calculator軟件需要的AXT的輸入格式露戒。
可以通過(guò)下面的地址下載:
https://github.com/qujingtao/perl-scripts-in-bioinformatics/blob/master/convert_fasta_to_axt.pl
用法為:
perl convert_fasta_to_axt.pl example.fasta
或者將腳本拷貝使用。注意DOS與UNIX之間的轉(zhuǎn)換逗威。
#!/usr/bin/perl
#The function of this perl script converts the fasta format of MEGA software into the axt format required by the KaKs_Calculator software.
#Usage: perl convert_fasta_to_axt.pl example.fasta.
use warnings;
use strict;
open IN,"$ARGV[0]";
my ($name) = $ARGV[0] =~ /(.*)\.fas/;
open OUT,">$name.axt";
my %seq = ();
local $/ = ">";
<IN>;
while (<IN>) {
s/>//;
my @a = split/\n/,$_,2;
$a[1] =~ s/\n//g;
my @b = split/\s+/,$a[0];
$seq{$b[0]} = $a[1];
}
close IN;
my @keys = keys %seq;
foreach my $i (0..$#keys) {
foreach my $j (0..$#keys) {
if ($i < $j) {
print OUT "$keys[$i]&$keys[$j]\n$seq{$keys[$i]}\n$seq{$keys[$j]}\n\n";
}
}
}
close OUT;