Mercurial > repos > dereeper > pangenome_explorer
view PanExplorer_workflow/Perl/convertANI.pl @ 2:97e4e3e818b6 draft
Uploaded
author | dereeper |
---|---|
date | Thu, 30 May 2024 11:48:09 +0000 |
parents | 032f6b3806a3 |
children |
line wrap: on
line source
#!/usr/bin/perl use strict; my $file = $ARGV[0]; my $metadata = $ARGV[1]; my %strains; open(F,$metadata); while(<F>){ my $line = $_; $line =~s/\n//g;$line =~s/\r//g; my ($path_genome,$strain) = split(/\t/,$line); $strains{$path_genome} = $strain; } close(F); my %ANIs; my %genomes; my $num_line = 0; open(F,$file); <F>; while(<F>){ $num_line++; my $line = $_; $line =~s/\n//g;$line =~s/\r//g; my @infos = split(/\t/,$line); my $genome = $infos[0]; $genome = $strains{$genome}; $genomes{$num_line} = $genome; for (my $i = 1; $i <= $#infos; $i++){ $ANIs{$i}{$num_line} = $infos[$i]; $ANIs{$num_line}{$i} = $infos[$i]; } } close(F); print "Genomes"; foreach my $i(sort keys(%ANIs)){ print "\t".$genomes{$i}; } print "\n"; foreach my $i(sort keys(%ANIs)){ print $genomes{$i}; foreach my $j(sort keys(%ANIs)){ my $ani = $ANIs{$i}{$j}; if ($ani eq "NA"){$ani = 0;} if (!$ani && $i == $j){ $ani = 100; } print "\t".$ani; } print "\n"; }