1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 14,
10 -requires_module => 'Bio::DB::Fasta');
12 use_ok('Bio::Root::IO');
16 my $DEBUG = test_debug();
18 # this obfuscation is to deal with lockfiles by GDBM_File which can
19 # only be created on local filesystems apparently so will cause test
20 # to block and then fail when the testdir is on an NFS mounted system
22 my $io = Bio::Root::IO->new(-verbose => $DEBUG);
23 my $tempdir = $io->tempdir('CLEANUP' => 1);
24 my $test_dbdir = $io->catfile($tempdir, 'dbfa');
25 mkdir($test_dbdir); # make the directory
26 my $indir = test_input_file('dbfa');
27 opendir(INDIR,$indir) || die("cannot open dir $indir");
28 # effectively do a cp -r but only copy the files that are in there, no subdirs
29 for my $file ( map { $io->catfile($indir,$_) } readdir(INDIR) ) {
30 next unless (-f $file );
31 copy($file, $test_dbdir);
35 # now use this temporary dir for the db file
36 my $db = Bio::DB::Fasta->new($test_dbdir, -reindex => 1);
38 cmp_ok($db->length('CEESC13F'), '>', 0);
39 is(length $db->seq('CEESC13F:1,10'), 10);
40 is(length $db->seq('AW057119',1,10), 10);
41 my $primary_seq = $db->get_Seq_by_id('AW057119');
43 cmp_ok(length($primary_seq->seq), '>', 0);
44 ok(!defined $db->get_Seq_by_id('foobarbaz'));
49 ok(tie(%h,'Bio::DB::Fasta',$test_dbdir));
51 ok($dna1 = $h{'AW057146:1,10'});
52 ok($dna2 = $h{'AW057146:10,1'});
54 my $revcom = reverse $dna1;
55 $revcom =~ tr/gatcGATC/ctagCTAG/;