[BUG] bug 2598
[bioperl-live.git] / t / masta.t
blob201fa773a2114fbeda826afbf96901b87f581389
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN {
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 16);
11         
12         use_ok('Bio::Matrix::PSM::IO');
15 #Let's try masta formats here
16 my $mio =  Bio::Matrix::PSM::IO->new(-format=>'masta', 
17                                       -file=>test_input_file('masta.dat'));
18 my $masta_w_dat = test_output_file();
19 my $wmio=Bio::Matrix::PSM::IO->new(-format=>'masta', 
20                                       -file=>">".$masta_w_dat);
21 $wmio->_flush_on_write(1);
22 ok $mio;
23 ok $wmio;
24 my @cons;
25 my $carry;
26 while (my $site=$mio->next_matrix) {
27         ok $site;
28         push @cons,$site->consensus;    
29         $carry=$site if ($site->id eq 'm1logs');
30
31 is $cons[0],'CAGAAAAATNGAATNCCCACCCCCC';
32 is $cons[1],'CAGAAAAATAGAATCCCCACCCCCC';
33 is $cons[2],'CAGAAAAATNNAATNCCCACCNCCC';
35 $wmio->write_psm($carry,'PWM');
36 $carry->id('m1freq');
37 $wmio->write_psm($carry,'PFM');
38 $carry->id('m1seq');
39 $wmio->write_psm($carry,'SEQ');
40 $wmio->DESTROY;
41 my $chio=Bio::Matrix::PSM::IO->new(-format=>'masta', 
42                                       -file=>$masta_w_dat);
43 ok $chio;
44 my $site=$chio->next_matrix;
45 is $site->id,'m1logs';
46 is $site->consensus,'CAGAAAAATAGAATCCCCACCCCCC';        
47 $site=$chio->next_matrix;
48 is $site->id,'m1freq';
49 is $site->consensus,'CAGAAAAATAGAATCCCCACCCCCC';  
50 $site=$chio->next_matrix;
51 is $site->id,'m1seq';
52 is $site->consensus,'CAGAAAAATAGAATCCCCACCCCCC';