Fix bug 253 testing for defined
[bioperl-live.git] / t / SeqIO / largefasta.t
blobe9aa50c8f05d33592cb6e1796a3bed7a1172be62
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 => 16);
12     use_ok('Bio::SeqIO::largefasta');
15 my $tmpfile = test_output_file();
17 my $seqio = Bio::SeqIO->new('-format' => 'largefasta',
18                             '-file'   => test_input_file('genomic-seq.fasta'),
19                             );
20 isa_ok($seqio, 'Bio::SeqIO');
22 my $pseq = $seqio->next_seq();
23 $pseq->alphabet('dna');
24 $pseq->desc('this is my description');;
25 my $plength = $pseq->length();
26 my $last_3 = $pseq->subseq($plength-3,$plength);
28 is defined $pseq, 1;
29 is $plength > 0, 1;
30 is length($pseq->subseq(100, 299)), 200; 
31 is $pseq->trunc(100,199)->length(), 100; 
32 is $pseq->alphabet(), 'dna';
33 is $pseq->display_id(), 'HSBA536C5';
34 is $pseq->accession_number(), 'unknown';
35 is $pseq->desc, 'this is my description';
37 is open(OUT, '>', $tmpfile), 1;
39 my $seqout = Bio::SeqIO->new('-format' => 'largefasta',
40                              '-fh'     => \*OUT );
41 is defined $seqout, 1;
43 is $seqout->write_seq($pseq), 1;
44 $seqout->close();
45 close(OUT);
46 my $seqin = Bio::SeqIO->new('-format' => 'largefasta',
47                             '-file'   => $tmpfile);
48 my $pseq2 = $seqin->next_seq;
49 is ($plength, $pseq2->length());
50 is ($pseq->display_id(), $pseq2->display_id());
51 is ($pseq->desc(), $pseq2->desc());