Accept space after equal sign in qualifiers when reading EMBL.
[bioperl-live.git] / t / LocalDB / Flat.t
blob25174a6c6c9e82439fe1c33a517a482f9bc7b3bb
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin(-tests => 25,
11                -requires_module => 'DB_File');
13     use_ok('Bio::DB::Flat');
16 my $verbose = test_debug();
18 # First of all we need to create an flat db
20 my $tmpdir = test_output_dir();
22 my $db = Bio::DB::Flat->new(-directory  => $tmpdir,
23                             -index      => 'bdb',
24                             -dbname     => 'mydb',
25                             -format     => 'fasta',
26                             -verbose    => $verbose,
27                             -write_flag => 1 );
28 ok($db);
29 my $dir = test_input_file('AAC12660.fa');
30 my $result = $db->build_index(glob($dir));
31 ok($result);
33 # Now let's get the sequence out again
34 my $seq = $db->get_Seq_by_id('AAC12660');
35 ok($seq);
36 is($seq->length,504);
37 undef $db;
39 $db = Bio::DB::Flat->new(-directory  => $tmpdir,
40                          -index      => 'bdb',
41                          -format     => 'embl',
42                          -dbname     => 'myembl',
43                          -verbose    => $verbose,
44                          -write_flag => 1 );
46 $dir= test_input_file('cds_sample.embl');
48 $result = $db->build_index(glob($dir));
50 is ($db->get_all_primary_ids, 1);
51 #is ($db->get_all_accs, 1);
52 ok($result);
53 $seq = $db->get_Seq_by_id('EAL24309');
54 ok($seq);
55 is($seq->length,192);
57 # deal with wantarray conditions
58 $seq = $db->get_Seq_by_acc('CH236947.1');
59 ok($seq && ref($seq));
60 is($seq->length,192);
63 undef $db;
65 $db = Bio::DB::Flat->new(-directory  => $tmpdir,
66                          -index      => 'binarysearch',
67                          -format     => 'fasta',
68                          -dbname     => 'mybinfa',
69                          -verbose    => $verbose,
70                          -write_flag => 1
71                          );
73 $dir= test_input_file('dbfa', '1.fa');
74 $result = $db->build_index($dir);
75 ok($result);
76 $seq = $db->get_Seq_by_id('AW057119');
77 ok($seq);
78 is($seq->length,808);
79 undef $db;
81 SKIP: {
82     test_skip(-tests => 4, -requires_module => 'Data::Stag');
83     $db = Bio::DB::Flat->new(-directory  => $tmpdir,
84                              -index      => 'binarysearch',
85                              -format     => 'swiss',
86                              -dbname     => 'mybinswiss',
87                              -verbose    => $verbose,
88                              -write_flag => 1
89                              );
90     $dir= test_input_file('swiss.dat');
91     $result = $db->build_index($dir);
93     ok($result);
94     $seq = $db->get_Seq_by_id('ACON_CAEEL');
95     ok($seq);
96     is($seq->length,788);
98     $seq = $db->get_Seq_by_id('ACON_CAEEL');
99     ok($seq && ref($seq));
101     undef $db;
103 $db = Bio::DB::Flat->new(-directory  => $tmpdir,
104                          -index      => 'binarysearch',
105                          -format     => 'fasta',
106                          -dbname     => 'myfasta',
107                          -verbose    => $verbose,
108                          -write_flag => 1 );
110 $dir = test_input_file('tmp.fst');
111 $result = $db->build_index(glob($dir));
112 ok($result);
113 $seq = $db->get_Seq_by_id('TEST00004');
114 is($seq->length,98);
116 undef $db;
118 $db = Bio::DB::Flat->new(-directory  => $tmpdir,
119                          -index      => 'bdb',
120                          -format     => 'fasta',
121                          -dbname     => 'mybfasta',
122                          -verbose    => $verbose,
123                          -write_flag => 1 );
125 $dir = test_input_file('tmp.fst');
126 $result = $db->build_index(glob($dir));
127 ok($result);
128 for my $id ( qw(TEST00001 TEST00002 TEST00003 TEST00004) ) {
129     $seq = $db->get_Seq_by_id($id);
130     is($seq->length,98);