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