My source code was listed below.
But the output file just look like
I think there would be some problem when returning the matrix value.
Would anyone can help me?
Thanks!
=============================
require "nodes.dump"; # it's a required symbol list. ex: A, D, E
my $ppi_file = "PPI_files.txt"; # it's the table. ex: A B 1
my @all_node = sort keys %nodes;
open FILE,">distance_matrix.txt";
print FILE "\t";
foreach ( @all_node ){
print FILE "$_\t";
} #print first line of distance matrix>
print FILE "\n";
foreach my $a ( @all_node ){
print FILE "$a\t";
foreach my $b ( @all_node ){
my $value = &search_distance_value($a,$b);
print FILE "$value\t";
}
print FILE "\n";
}
close FILE;
sub search_distance_value
{
my $a = $_[0];
my $b = $_[1];
my %ppi;
open TABLE, "<$ppi_file"; #table: A B 1, A D 2,...
while ( $line = <TABLE> ){
chomp $line;
my ( $node1, $node2, $dist ) = split /\s+/, $line;
$ppi{$node1}{$node2} = $dist;
}
if ( ( $node1 = $a ) && ( $node2 = $b ) ){
return $dist;
}
}