File: Flat.t

package info (click to toggle)
bioperl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 35,788 kB
  • sloc: perl: 94,019; xml: 14,811; makefile: 20
file content (133 lines) | stat: -rw-r--r-- 3,745 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*-Perl-*- Test Harness script for Bioperl
# $Id$

use strict;

BEGIN {
    use Bio::Root::Test;

    test_begin(-tests => 27,
               -requires_module => 'DB_File');

    use_ok('Bio::DB::Flat');
}

my $verbose = test_debug();

# First of all we need to create an flat db

my $tmpdir = test_output_dir();

my $db = Bio::DB::Flat->new(-directory  => $tmpdir,
                            -index      => 'bdb',
                            -dbname     => 'mydb',
                            -format     => 'fasta',
                            -verbose    => $verbose,
                            -write_flag => 1 );
ok($db);
my $dir = test_input_file('AAC12660.fa');
my $result = $db->build_index(glob($dir));
ok($result);

# Now let's get the sequence out again
my $seq = $db->get_Seq_by_id('AAC12660');
ok($seq);
is($seq->length,504);
undef $db;

$db = Bio::DB::Flat->new(-directory  => $tmpdir,
                         -index      => 'bdb',
                         -format     => 'embl',
                         -dbname     => 'myembl',
                         -verbose    => $verbose,
                         -write_flag => 1 );

$dir= test_input_file('cds_sample.embl');

$result = $db->build_index(glob($dir));

is ($db->get_all_primary_ids, 1);
#is ($db->get_all_accs, 1);
ok($result);
$seq = $db->get_Seq_by_id('EAL24309');
ok($seq);
is($seq->length,192);

# deal with wantarray conditions
$seq = $db->get_Seq_by_acc('CH236947.1');
ok($seq && ref($seq));
is($seq->length,192);

undef $db;

$db = Bio::DB::Flat->new(-directory  => $tmpdir,
                         -index      => 'binarysearch',
                         -format     => 'fasta',
                         -dbname     => 'mybinfa',
                         -verbose    => $verbose,
                         -write_flag => 1
                         );

$dir = test_input_file('dbfa', '1.fa');
$result = $db->build_index($dir);
ok($result);
$seq = $db->get_Seq_by_id('AW057119');
ok($seq);
is($seq->length, 808);
$seq = $db->get_Seq_by_id('AW057118');
ok($seq);
is($seq->length, 299);

undef $db;

SKIP: {
    test_skip(-tests => 4, -requires_module => 'Data::Stag');
    $db = Bio::DB::Flat->new(-directory  => $tmpdir,
                             -index      => 'binarysearch',
                             -format     => 'swiss',
                             -dbname     => 'mybinswiss',
                             -verbose    => $verbose,
                             -write_flag => 1
                             );
    $dir= test_input_file('swiss.dat');
    $result = $db->build_index($dir);

    ok($result);
    $seq = $db->get_Seq_by_id('ACON_CAEEL');
    ok($seq);
    is($seq->length,788);

    $seq = $db->get_Seq_by_id('ACON_CAEEL');
    ok($seq && ref($seq));

    undef $db;
}
$db = Bio::DB::Flat->new(-directory  => $tmpdir,
                         -index      => 'binarysearch',
                         -format     => 'fasta',
                         -dbname     => 'myfasta',
                         -verbose    => $verbose,
                         -write_flag => 1 );

$dir = test_input_file('tmp.fst');
$result = $db->build_index(glob($dir));
ok($result);
$seq = $db->get_Seq_by_id('TEST00004');
is($seq->length,98);

undef $db;

$db = Bio::DB::Flat->new(-directory  => $tmpdir,
                         -index      => 'bdb',
                         -format     => 'fasta',
                         -dbname     => 'mybfasta',
                         -verbose    => $verbose,
                         -write_flag => 1 );

$dir = test_input_file('tmp.fst');
$result = $db->build_index(glob($dir));
ok($result);
for my $id ( qw(TEST00001 TEST00002 TEST00003 TEST00004) ) {
    $seq = $db->get_Seq_by_id($id);
    is($seq->length,98);
}