1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | |
---|
6 | BEGIN { |
---|
7 | if (not exists $ENV{'ARBHOME'}) { die "Environment variable \$ARBHOME has to be defined"; } |
---|
8 | my $arbhome = $ENV{'ARBHOME'}; |
---|
9 | push @INC, "$arbhome/lib"; |
---|
10 | push @INC, "$arbhome/PERL_SCRIPTS/GENOME"; |
---|
11 | push @INC, "$arbhome/PERL_SCRIPTS/SAI"; |
---|
12 | 1; |
---|
13 | } |
---|
14 | |
---|
15 | use ARB; |
---|
16 | use SAI; |
---|
17 | |
---|
18 | # ----------------------- |
---|
19 | |
---|
20 | sub expectEntry($$) { |
---|
21 | my ($gb_father,$key) = @_; |
---|
22 | my $gb = ARB::search($gb_father, $key, 'NONE'); |
---|
23 | defined $gb || die "Expected entry '$key' in '".ARB::get_db_path($gb_father)."'"; |
---|
24 | return $gb; |
---|
25 | } |
---|
26 | |
---|
27 | # ----------------------- |
---|
28 | |
---|
29 | SAI::connectDB(); |
---|
30 | |
---|
31 | my @SAI = (); |
---|
32 | SAI::scanSAIs(@SAI); |
---|
33 | |
---|
34 | print "SAIs in current database:\n"; |
---|
35 | foreach (@SAI) { |
---|
36 | print "- $_\n"; |
---|
37 | } |
---|
38 | |
---|
39 | my $sai_name = 'POS_VAR_BY_PARSIMONY'; |
---|
40 | my $gb_posvar = SAI::findSAI($sai_name); |
---|
41 | if ($gb_posvar) { |
---|
42 | print "Details for SAI '$sai_name':\n"; |
---|
43 | |
---|
44 | my @alis = (); |
---|
45 | SAI::getSAIalignments($gb_posvar,@alis); |
---|
46 | |
---|
47 | print "- Contains information for the following alignments:\n"; |
---|
48 | foreach my $ali (@alis) { |
---|
49 | print " - $ali\n"; |
---|
50 | my $gb_ali = expectEntry($gb_posvar, $ali); |
---|
51 | |
---|
52 | my $gb_cat = expectEntry($gb_ali, '_CATEGORIES'); |
---|
53 | my $cat = ARB::read_string($gb_cat); |
---|
54 | print " cat='$cat'\n"; |
---|
55 | |
---|
56 | my $gb_data = expectEntry($gb_ali, 'data'); |
---|
57 | my $data = ARB::read_string($gb_data); |
---|
58 | # print " data='$data'\n"; |
---|
59 | print " data contains ".length($data)." characters.\n"; |
---|
60 | |
---|
61 | my $gb_freqs = expectEntry($gb_ali, 'FREQUENCIES'); |
---|
62 | my @freq_entries = ( 'NA', 'NC', 'NG', 'NU'); |
---|
63 | foreach my $fentry (@freq_entries) { |
---|
64 | my $gb_f = expectEntry($gb_freqs, $fentry); |
---|
65 | my @values = (); |
---|
66 | SAI::readIntegerArray($gb_f,@values); |
---|
67 | print " $fentry contains ".scalar(@values)." integer values, "; |
---|
68 | my $sum = 0; |
---|
69 | foreach (@values) { $sum += $_; } |
---|
70 | print " $fentry sum is $sum\n"; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | else { |
---|
75 | print "No such SAI '$sai_name'\n"; |
---|
76 | } |
---|
77 | |
---|
78 | SAI::disconnectDB(); |
---|
79 | |
---|