source: branches/port5/PERL2ARB/test.pl

Last change on this file was 2272, checked in by westram, 21 years ago
  • uses demo.arb if no ARB is running
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
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
11BEGIN {print "1..1\n";}
12END {print "not ok 1\n" unless $loaded;}
13use ARB;
14$loaded = 1;
15print "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
23print"Looking for a running arb server...\n";
24my $gb_main = ARB::open(":",rw);
25if (!$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}
33else {
34  print "Connected to a running instance of ARB!\n";
35}
36
37print "\n";
38
39# begin a transaction
40ARB::begin_transaction($gb_main);
41
42# read and print alignment name
43my $gb_alignment_name = ARB::search($gb_main,"presets/use","none");
44my $name = ARB::read_string($gb_alignment_name);
45print "Current alignment name is '$name'\n";
46
47# traverse all species
48my $gb_species = BIO::first_species($gb_main);
49if (!$gb_species) {
50  print "Strange: Database does not contain species.\n";
51}
52else {
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
62my $tree_name = BIO::get_next_tree_name($gb_main,0);
63my $tree_counter=0;
64if ($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}
71print "Number of trees in database: $tree_counter\n";
72
73# commit the transaction
74ARB::commit_transaction($gb_main);
75
76print "\nClosing database\n";
77ARB::close($gb_main);
78
79print "All tests passed.\n";
80
81
Note: See TracBrowser for help on using the repository browser.