New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / largefasta.t
blob697e552423950a09c0bf8c438ed3a67556c81fd0
3 use strict;
4 BEGIN { 
5     eval { require Test; };
6     if( $@ ) {
7         use lib 't';
8     }
9     use Test;    
10     plan tests => 15;
13 use Bio::SeqIO;
14 use vars qw($tmpfile);
15 use Bio::Root::IO;
16 END { unlink $tmpfile; }
18 $tmpfile = Bio::Root::IO->catfile("t","data","largefastatest.out");
19 my $seqio = new Bio::SeqIO('-format'=>'largefasta',
20                            '-file'  =>Bio::Root::IO->catfile("t","data","genomic-seq.fasta"));
21 ok defined $seqio, 1, 'cannot instantiate Bio::SeqIO::largefasta';
23 my $pseq = $seqio->next_seq();
24 $pseq->alphabet('dna');
25 $pseq->desc('this is my description');;
26 my $plength = $pseq->length();
27 my $last_3 = $pseq->subseq($plength-3,$plength);
29 ok defined $pseq, 1, 'could not call next_seq';
30 ok $plength > 0, 1, "could not call length, seq was empty";
31 ok length($pseq->subseq(100, 299)), 200, 'error in subseq'; 
32 ok $pseq->trunc(100,199)->length(), 100, 'error in trunc'; 
33 ok $pseq->alphabet(), 'dna', 'alphabet was ' . $pseq->alphabet();
34 ok $pseq->display_id(), 'HSBA536C5',"no display id";
35 ok $pseq->accession_number(), 'unknown', "no accession";
36 ok $pseq->desc, 'this is my description', 'no description';
38 ok open(OUT, ">$tmpfile"), 1,'could not open output file';
40 my $seqout = new Bio::SeqIO('-format' => 'largefasta',
41                             '-fh'     => \*OUT );
42 ok defined $seqout, 1,'could not open seq with outputstream';
44 ok $seqout->write_seq($pseq), 1,'could not write seq';
45 $seqout->close();
46 close(OUT);
47 my $seqin = new Bio::SeqIO('-format' => 'largefasta',
48                         '-file'   => $tmpfile);
49 my $pseq2 = $seqin->next_seq;
50 ok ($plength, $pseq2->length(), 
51     "written file was not same length as expected");
52 ok ($pseq->display_id(), $pseq2->display_id(), 
53     "display ids were not identical as expected");
54 ok ($pseq->desc(), $pseq2->desc() , 
55     "description was not identical (" . $pseq->desc() . 
56     "," . $pseq2->desc() . ")");