| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | # Before `make install' is performed this script should be runnable with |
|---|
| 4 | # `make test'. After `make install' it should work as `perl test.pl' |
|---|
| 5 | |
|---|
| 6 | ######################### We start with some black magic to print on failure. |
|---|
| 7 | |
|---|
| 8 | # Change 1..1 below to 1..last_test_to_print . |
|---|
| 9 | # (It may become useful if the test is moved to ./t subdirectory.) |
|---|
| 10 | |
|---|
| 11 | BEGIN {print "1..1\n";} |
|---|
| 12 | END {print "not ok 1\n" unless $loaded;} |
|---|
| 13 | use ARB; |
|---|
| 14 | $loaded = 1; |
|---|
| 15 | print "ok 1\n"; |
|---|
| 16 | |
|---|
| 17 | ######################### End of black magic. |
|---|
| 18 | |
|---|
| 19 | # Insert your test code below (better if it prints "ok 13" |
|---|
| 20 | # (correspondingly "not ok 13") depending on the success of chunk 13 |
|---|
| 21 | # of the test code): |
|---|
| 22 | |
|---|
| 23 | print"Looking for a running arb server...\n"; |
|---|
| 24 | my $gb_main = ARB::open(":",rw); |
|---|
| 25 | if (!$gb_main) { |
|---|
| 26 | print "None found - using demo database demo.arb provided with ARB\n"; |
|---|
| 27 | $gb_main = ARB::open("../demo.arb",rw); |
|---|
| 28 | if (!$gb_main) { |
|---|
| 29 | die "Oops! demo.arb isn't in parent directory as expected"; |
|---|
| 30 | } |
|---|
| 31 | print "Opened database.\n"; |
|---|
| 32 | } |
|---|
| 33 | else { |
|---|
| 34 | print "Connected to a running instance of ARB!\n"; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | print "\n"; |
|---|
| 38 | |
|---|
| 39 | # begin a transaction |
|---|
| 40 | ARB::begin_transaction($gb_main); |
|---|
| 41 | |
|---|
| 42 | # read and print alignment name |
|---|
| 43 | my $gb_alignment_name = ARB::search($gb_main,"presets/use","none"); |
|---|
| 44 | my $name = ARB::read_string($gb_alignment_name); |
|---|
| 45 | print "Current alignment name is '$name'\n"; |
|---|
| 46 | |
|---|
| 47 | # traverse all species |
|---|
| 48 | my $gb_species = BIO::first_species($gb_main); |
|---|
| 49 | if (!$gb_species) { |
|---|
| 50 | print "Strange: Database does not contain species.\n"; |
|---|
| 51 | } |
|---|
| 52 | else { |
|---|
| 53 | my $species_count=0; |
|---|
| 54 | while ($gb_species) { |
|---|
| 55 | $species_count++; |
|---|
| 56 | $gb_species=BIO::next_species($gb_species); |
|---|
| 57 | } |
|---|
| 58 | print "Number of species in database: $species_count\n"; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | # traverse all trees |
|---|
| 62 | my $tree_name = BIO::get_next_tree_name($gb_main,0); |
|---|
| 63 | my $tree_counter=0; |
|---|
| 64 | if ($tree_name) { |
|---|
| 65 | while ($tree_name) { |
|---|
| 66 | $tree_counter++; |
|---|
| 67 | print "tree '$tree_name'\n"; |
|---|
| 68 | $tree_name = BIO::get_next_tree_name($gb_main,$tree_name); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | print "Number of trees in database: $tree_counter\n"; |
|---|
| 72 | |
|---|
| 73 | # commit the transaction |
|---|
| 74 | ARB::commit_transaction($gb_main); |
|---|
| 75 | |
|---|
| 76 | print "\nClosing database\n"; |
|---|
| 77 | ARB::close($gb_main); |
|---|
| 78 | |
|---|
| 79 | print "All tests passed.\n"; |
|---|
| 80 | |
|---|
| 81 | |
|---|