sync from trunk
[bioperl-live.git] / t / SeqIO / ace.t
blob911488b4805e1941374953a9c60d02aad693ca6d
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 => 7);
11         
12         use_ok('Bio::SeqIO');
15 my $verbose = test_debug();
17 my $t_file = test_input_file('test.ace');
18 my( $before );
20         local $/ = undef;
21         local *BEFORE;
22         open BEFORE, $t_file;
23         $before = <BEFORE>;
24         close BEFORE;
27 my $a_in = Bio::SeqIO->new( -FILE => $t_file,
28                                                                          -verbose => $verbose,
29                                                                          -FORMAT => 'ace');
30 my( @a_seq );
31 while (my $a = $a_in->next_seq) {
32         push(@a_seq, $a);
35 is @a_seq, 3, 'number of sequence objects';
37 my $esc_name = $a_seq[1]->display_id;
38 is( $esc_name , 'Name; 4% strewn with \ various / escaped characters',
39          "unescaping of characters, $esc_name");
41 is $a_seq[0]->alphabet, 'protein', 'alphabets detected';
42 is $a_seq[1]->alphabet, 'dna', 'alphabets detected';
44 my $o_file = test_output_file();
45 my $a_out = Bio::SeqIO->new(-FILE => "> $o_file",
46                                                                          -verbose => $verbose,
47                                                                          -FORMAT => 'ace');
48 my $a_out_ok = 1;
49 foreach my $a (@a_seq) {
50         $a_out->write_seq($a) or $a_out_ok = 0;
52 undef($a_out);  # Flush to disk
53 is $a_out_ok,1,'writing sequence';
55 my( $after );
57         local $/ = undef;
58         local *AFTER;
59         open AFTER, $o_file;
60         $after = <AFTER>;
61         close AFTER;
64 is( ($before and $after and ($before eq $after)),1,
65          'test output');