3
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use strict;
|
|
4
|
|
5 my $file = $ARGV[0];
|
|
6 my $metadata = $ARGV[1];
|
|
7
|
|
8 my %strains;
|
|
9 open(F,$metadata);
|
|
10 while(<F>){
|
|
11 my $line = $_;
|
|
12 $line =~s/\n//g;$line =~s/\r//g;
|
|
13 my ($path_genome,$strain) = split(/\t/,$line);
|
|
14 $strains{$path_genome} = $strain;
|
|
15 }
|
|
16 close(F);
|
|
17
|
|
18 my %ANIs;
|
|
19 my %genomes;
|
|
20 my $num_line = 0;
|
|
21 open(F,$file);
|
|
22 <F>;
|
|
23 while(<F>){
|
|
24 $num_line++;
|
|
25 my $line = $_;
|
|
26 $line =~s/\n//g;$line =~s/\r//g;
|
|
27 my @infos = split(/\t/,$line);
|
|
28 my $genome = $infos[0];
|
|
29 $genome = $strains{$genome};
|
|
30 $genomes{$num_line} = $genome;
|
|
31 for (my $i = 1; $i <= $#infos; $i++){
|
|
32 $ANIs{$i}{$num_line} = $infos[$i];
|
|
33 $ANIs{$num_line}{$i} = $infos[$i];
|
|
34 }
|
|
35 }
|
|
36 close(F);
|
|
37
|
|
38 print "Genomes";
|
|
39 foreach my $i(sort keys(%ANIs)){
|
|
40 print "\t".$genomes{$i};
|
|
41 }
|
|
42 print "\n";
|
|
43 foreach my $i(sort keys(%ANIs)){
|
|
44 print $genomes{$i};
|
|
45 foreach my $j(sort keys(%ANIs)){
|
|
46 my $ani = $ANIs{$i}{$j};
|
|
47 if ($ani eq "NA"){$ani = 0;}
|
|
48 if (!$ani && $i == $j){
|
|
49 $ani = 100;
|
|
50 }
|
|
51 print "\t".$ani;
|
|
52 }
|
|
53 print "\n";
|
|
54 }
|