annotate Perl/Heatmaply.pl @ 13:152d7c43478b draft default tip

Uploaded
author dereeper
date Thu, 30 May 2024 20:07:55 +0000
parents e42d30da7a74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
2
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
3 my $in = $ARGV[0];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
4 my $out = $ARGV[1];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
5 my $rowmetadata = $ARGV[2];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
6 my $colmetadata = $ARGV[3];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
7
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
8 my %hash;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
9 my %hash2;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
10 my $n = 0;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
11 open(M,$rowmetadata);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
12 while(<M>){
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
13 my $line = $_;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
14 $line =~s/\n//g;$line =~s/\r//g;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
15 $n++;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
16 my @infos = split(/\t/,$line);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
17 my $genus = $infos[1];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
18 my $country = $infos[2];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
19 my $continent = $infos[3];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
20 $hash{$n} = "Genus: $genus <br>Country: $country <br> Continent: $continent";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
21 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
22 close(M);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
23
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
24 my $k = 0;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
25 open(M,$colmetadata);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
26 while(<M>){
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
27 my $line = $_;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
28 $line =~s/\n//g;$line =~s/\r//g;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
29 $k++;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
30 my @infos = split(/\t/,$line);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
31 my $cog = $infos[1];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
32 my $cog_cat = $infos[2];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
33 my $function = $infos[3];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
34 $hash2{$k} = "Description: $function <br>COG: $cog <br>COG category: $cog_cat";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
35 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
36 close(M);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
37
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
38 open(T,">$in.metadata_tooltips.txt");
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
39 foreach my $n(sort {$a<=>$b} keys(%hash)){
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
40
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
41 my $country = $hash{$n};
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
42 foreach my $k(sort {$a<=>$b} keys(%hash2)){
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
43 my $cog = $hash2{$k};
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
44 print T "<br>$cog <br><br>$country \t";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
45 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
46 print T "\n";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
47 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
48 close(T);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
49
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
50 use strict;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
51 system("ulimit -s 163840;Rscript $dirname/../R/heatmaply.R -f $in -o $out -c $colmetadata -r $rowmetadata");