-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhbxResultsTable.pl
executable file
·73 lines (72 loc) · 1.66 KB
/
hbxResultsTable.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w
use strict;
my $fams = `grep ',' HomeoDBfamilies.csv`;
my %fams = split /[\n,]/, $fams;
my @fams = ();
while (my ($keys, $values) = each %fams) {
#push @fams, "$keys\_$values";
push @fams, "$values\t$keys";
# print "0.$values\t$keys\n";
}
my $species = `grep '[A-Z]' speciesList.tsv`;
my @species = split /\n/, $species;
foreach my $specie (@species) {
chomp $specie;
($specie, my $code) = split /\t/, $specie;
#print "0.$specie\n";
}
my $classlog = $ARGV[0];
chomp $classlog;
my $entries = `grep '_' $classlog`;
my %hash = ();
my @entries = split /\n/, $entries;
foreach my $entry (@entries) {
chomp $entry;
my ($spec,$header,$uid,$fasta,$homeodb,$interpro,$classif,$phylo) = split /\t/, $entry;
my $class = "";
my $family = "";
if ($phylo =~ /_/) {
$classif =~ s/_/\./g;
my $homeo = "";
if (($homeo) = grep/$classif/, @fams) {
chomp $homeo;
($family,$class) = split /\t/, $homeo;
#print "1.$class\t$family\n";
}
}
elsif ($classif !~ /Unknown/) {
($family,$class) = split /\|/, $classif;
#print "2.$class\t$family\n";
}
#else {
#print $entry, "\n";
#}
my $gene = $header;
if ($header =~ /GN=(.*)PE=/) {
$gene = $1;
}
$hash{"$class\t$family"}{$spec}.="$gene ";
#print "1.$spec\n";
}
#foreach my $name (sort keys %hash) {
# foreach my $subject (keys %{ $hash{$name} }) {
# print "$name, $subject: $hash{$name}{$subject}\n";
# }
#}
#exit;
print "HBX Class\tHBX Family\t";
print join("\t", @species), "\n";
foreach my $fam (@fams) {
chomp $fam;
print "$fam\t";
foreach my $taxon (@species) {
chomp $taxon;
if ($hash{$fam}{$taxon}) {
print "$hash{$fam}{$taxon}\t";
}
else {
print "-\t";
}
}
print "\n";
}