-
Notifications
You must be signed in to change notification settings - Fork 0
/
hbxOrigins.pl
executable file
·68 lines (68 loc) · 1.92 KB
/
hbxOrigins.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
#!/usr/bin/perl -w
use strict;
use lib '/home/cristig/Desktop/ComparativeGenomics';
use queryMySQL;
use List::UtilsBy qw(max_by);
use List::Util qw(max);
my $hbxcountfile = $ARGV[0];
my @hbxcount = `grep -v -P ',0' $hbxcountfile`;
my %hash = ();
my %homeos = (
Human => "Homo sapiens",
Beetle => "Tribolium castaneum",
Amphioxus => "Branchiostoma floridae",
Frog => "Xenopus tropicalis",
Chicken => "Gallus gallus",
Fruitfly => "Drosophila melanogaster",
Zebrafish => "Danio rerio",
Nematode => "Caenorhabditis elegans",
);
foreach my $hbx (@hbxcount) {
chomp $hbx;
my ($spec, $group, $class, $family, $count) = split /,/, $hbx;
if ($homeos{$spec}) {
$spec = $homeos{$spec};
}
$hash{"$class,$family"}.="$spec,";
}
foreach my $keys (sort keys %hash) {
my $highindex = 0;
$hash{$keys} =~ s/,$//;
my @specs = split /,/, $hash{$keys};
my $specount = scalar(@specs);
my %logeny = ();
my @phylos = ("Kingdom", "Ten", "Nine", "Eight", "Seven", "Six", "Five", "Four", "Three");
foreach my $spec (@specs) {
chomp $spec;
foreach (my $i = 0; $i < @phylos; $i++) {
#print $phylos[$i], "\n";
my $type = "";
while ($type eq "") {
$type = `echo 'SELECT DISTINCT $phylos[$i] FROM phylogeny WHERE Species="$spec"' | mysql -B -uweb ComparativeGenomics`;
#print "echo 'SELECT DISTINCT $phylos[$i] FROM phylogeny WHERE Species=\"$spec\"' | mysql -B -uweb ComparativeGenomics\n";
}
$logeny{$type}++;
#print $type, "\n";
}
}
my $highest = max values %logeny;
foreach my $type (sort keys %logeny) {
if ($logeny{$type} == $highest) {
chomp $type;
#print $logeny{$type}, "\n";
my ($column, $cladename) = split /\n/, $type;
#print $type, "\n";
my $index = grep { "$phylos[$_]" eq "$column" } 0..$#phylos;
if ($highindex < $index) {
$highindex = $index;
}
if ($index => $highindex) {
$hash{$keys} = $cladename;
}
}
}
}
while (my ($keys, $values) = each %hash) {
print $keys,",",$values, "\n";
}
exit;