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
|
# This is -*-Perl-*- code
## Bioperl Test Harness Script for Modules
##
# $Id: flat.t,v 1.1.2.1 2002/03/18 16:32:18 jason Exp $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'
use strict;
use vars qw($NUMTESTS);
my $error;
BEGIN {
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
$error = 0;
if( $@ ) {
use lib 't';
}
use Test;
$NUMTESTS = 7;
plan tests => $NUMTESTS;
}
if( $error == 1 ) {
exit(0);
}
my $testnum;
my $verbose = 0;
## End of black magic.
##
## Insert additional test code below but remember to change
## the print "1..x\n" in the BEGIN block to reflect the
## total number of tests that will be run.
#First of all we need to create an flat db
use Bio::DB::Flat;
use Bio::Root::IO;
use Cwd;
my $cd = cwd();
my $tmpdir = $cd."/t/tmp";
&maketmpdir();
my $db = Bio::DB::Flat->new(-directory => $tmpdir,
-index => 'bdb',
-format => 'fasta',
-verbose => 1,
-write_flag => 1
);
ok($db);
my $dir = $cd."/t/data/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);
ok($seq->length,504);
&cleanup();
&maketmpdir();
$db = Bio::DB::Flat->new(-directory => $tmpdir,
-index => 'bdb',
-format => 'embl',
-verbose => 1,
-write_flag => 1
);
$dir= $cd."/t/data/factor7.embl";
$result = $db->build_index(glob($dir));
ok($result);
$seq = $db->get_Seq_by_id('HSCFVII');
ok($seq);
ok($seq->length,12850);
&cleanup();
#&maketmpdir();
#my $db = Bio::DB::Flat->new(-directory => $tmpdir,
# -index => 'flat',
# -format => 'fasta',
# -verbose => 1,
# -write_flag => 1
# );
sub maketmpdir {
mkdir $tmpdir;
}
sub cleanup {
eval {
Bio::Root::IO->rmtree($tmpdir);
};
}
|