Bio::DB::MeSH move to its own distribution.
[bioperl-live.git] / t / LocalDB / Registry.t
blobb11b5aca1f74d6620cd4f228484d52f13a779006
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 14);
11         
12         $ENV{OBDA_SEARCH_PATH} = 't/data/registry/flat;t/data/registry/bdb';
13         
14         use_ok('Bio::DB::Registry');
15         use_ok('Bio::DB::Flat');
18 # we need a temp directory t/tmp since t/tmp is specified in the registry files
19 my $tmpdir = File::Spec->catfile(qw(t tmp));
20 mkdir($tmpdir,0777);
22 SKIP: {
23         skip "unable to create temp dir '$tmpdir', skipping tests", 12 unless -d $tmpdir;
24         
25         my $flat = Bio::DB::Flat->new(-directory  => $tmpdir,
26                                           -dbname     => 'testflat',
27                                           -format     => 'fasta',
28                                           -index      => 'binarysearch',
29                                                                   -write_flag => 1 );
30         my $entries = $flat->build_index(test_input_file('cysprot.fa'));
31         is $entries, 7;
32         
33         SKIP: {
34                 test_skip(-tests => 2, -requires_modules => [qw(DB_File)]);
35                 
36                 my $bdb = Bio::DB::Flat->new(-directory  => $tmpdir,
37                                          -dbname     => 'testbdb',
38                                          -format     => 'fasta',
39                                          -index      => 'bdb',
40                                          -write_flag => 1 );
41                 ok defined($bdb);
42                 $entries = $bdb->build_index(test_input_file('cysprot.fa'));
43                 is $entries, 7;
44         }
45         
46         SKIP: {
47                 test_skip(-tests => 9,
48                   -requires_modules => [qw(LWP::UserAgent HTTP::Request::Common)],
49                   -requires_networking => 1);
50                 
51                 my $registry = Bio::DB::Registry->new();
52                 ok defined($registry);
53                 my @available_services = $registry->services;
54                 
55                 ok grep /testflat/,@available_services;
56                 my $db = $registry->get_database('testflat');
57                 ok defined($db);
58                 my $seq = $db->get_Seq_by_id("ALEU_HORVU");
59                 ok defined($seq);
60                 my $sequence = $seq->seq;
61                 is $sequence, "MAHARVLLLALAVLATAAVAVASSSSFADSNPIRPVTDRAASTLESAVLGALGRTRHALRFARFAVRYGKSYESAAEVRRRFRIFSESLEEVRSTNRKGLPYRLGINRFSDMSWEEFQATRLGAAQTCSATLAGNHLMRDAAALPETKDWREDGIVSPVKNQAHCGSCWTFSTTGALEAAYTQATGKNISLSEQQLVDCAGGFNNFGCNGGLPSQAFEYIKYNGGIDTEESYPYKGVNGVCHYKAENAAVQVLDSVNITLNAEDELKNAVGLVRPVSVAFQVIDGFRQYKSGVYTSDHCGTTPDDVNHAVLAVGYGVENGVPYWLIKNSWGADWGDNGYFKMEMGKNMCAIATCASYPVVAA";
62         
63                 SKIP: {
64                         test_skip(-tests => 4, -requires_modules => [qw(DB_File)]);
65                         
66                         ok grep /testbdb/,@available_services;
67                         $db = $registry->get_database('testbdb');
68                         ok defined($db);
69                         $seq = $db->get_Seq_by_id("ALEU_HORVU");
70                         ok defined($seq);
71                         $sequence = $seq->seq;
72                         is $sequence, "MAHARVLLLALAVLATAAVAVASSSSFADSNPIRPVTDRAASTLESAVLGALGRTRHALRFARFAVRYGKSYESAAEVRRRFRIFSESLEEVRSTNRKGLPYRLGINRFSDMSWEEFQATRLGAAQTCSATLAGNHLMRDAAALPETKDWREDGIVSPVKNQAHCGSCWTFSTTGALEAAYTQATGKNISLSEQQLVDCAGGFNNFGCNGGLPSQAFEYIKYNGGIDTEESYPYKGVNGVCHYKAENAAVQVLDSVNITLNAEDELKNAVGLVRPVSVAFQVIDGFRQYKSGVYTSDHCGTTPDDVNHAVLAVGYGVENGVPYWLIKNSWGADWGDNGYFKMEMGKNMCAIATCASYPVVAA";
73                 }
74         }
77 END {
78         File::Path::rmtree($tmpdir) if ($tmpdir && (-d $tmpdir));