~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to t/psm.t

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*-
 
2
#Some simple tests for meme and transfac parsers
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN {
 
7
    # to handle systems with no installed Test module
 
8
    # we include the t dir (where a copy of Test.pm is located)
 
9
    # as a fallback
 
10
    eval { require Test; };
 
11
    if( $@ ) {
 
12
        use lib 't';
 
13
    }
 
14
    use Test;
 
15
 
 
16
    plan tests => 42;
 
17
}
 
18
use Bio::Matrix::PSM::IO;
 
19
 
 
20
ok(1);
 
21
#Let's try meme here
 
22
my $psmIO =  new Bio::Matrix::PSM::IO(-format=>'meme', 
 
23
                                      -file=>Bio::Root::IO->catfile(qw(t data meme.dat)));
 
24
ok $psmIO;
 
25
 
 
26
my @inputfile=grep(/datafile/i,$psmIO->unstructured);
 
27
ok @inputfile;
 
28
 
 
29
my $release=$psmIO->release;
 
30
ok $release;
 
31
 
 
32
my @ids=$psmIO->hid;
 
33
ok @ids,4;
 
34
 
 
35
my %weights=$psmIO->weight;
 
36
ok %weights;
 
37
 
 
38
my %seq = $psmIO->seq;
 
39
ok %seq,'0';#Meme doesn't have seq
 
40
 
 
41
ok $psmIO->version,'3.0';
 
42
 
 
43
my $psm = $psmIO->next_psm;
 
44
ok $psm;
 
45
 
 
46
my $matrix=$psm->matrix;
 
47
ok $matrix;
 
48
my $psm2=$psm;
 
49
$psm2->matrix($matrix);
 
50
ok $psm,$psm2;
 
51
 
 
52
my %psm_header=$psm->header;
 
53
ok $psm_header{IC},38.1;
 
54
ok $psm_header{sites},4;
 
55
ok $psm_header{width},25;
 
56
ok $psm_header{e_val},'1.2e-002';
 
57
 
 
58
 
 
59
#Quick check if returned object works
 
60
my $IUPAC=$psm->IUPAC;
 
61
ok $IUPAC,'CAGAAAAATWVAATYCCCACCHCCC';
 
62
ok $IUPAC,$psm2->IUPAC;
 
63
ok $IUPAC,$matrix->IUPAC;
 
64
 
 
65
my $instances=$psm->instances;
 
66
ok $instances;
 
67
 
 
68
foreach my $instance (@{$instances}) {
 
69
  my $id=$instance->primary_id;
 
70
  last if (ok $id);
 
71
}
 
72
 
 
73
ok $psm->header('e_val');
 
74
#Meme parser should be OK if tests passed
 
75
 
 
76
 
 
77
#Now we are going to try transfac
 
78
 
 
79
$psmIO =  new Bio::Matrix::PSM::IO(-format=>'transfac', 
 
80
                                   -file=> Bio::Root::IO->catfile(qw(t data transfac.dat)));
 
81
ok $psmIO;
 
82
 
 
83
my $version=$psmIO->version;
 
84
ok !$version;
 
85
 
 
86
ok $psmIO->release, '6.4--2002-12-02';
 
87
 
 
88
@ids     = $psmIO->hid;
 
89
ok @ids, '1';
 
90
 
 
91
$psm     = $psmIO->next_psm;
 
92
ok $psm;
 
93
 
 
94
%weights = $psmIO->weight;
 
95
ok !$weights{''};
 
96
 
 
97
%seq     = $psmIO->seq;
 
98
ok scalar keys %seq, 0;
 
99
 
 
100
#Quick check if returned object works
 
101
$IUPAC   = $psm->IUPAC;
 
102
ok $IUPAC,'NNNNNNNNNNNN';
 
103
 
 
104
#Now we are going to try mast
 
105
$psmIO =  new Bio::Matrix::PSM::IO(-format=>'mast', 
 
106
                                   -file=>Bio::Root::IO->catfile(qw(t data mast.dat)));
 
107
ok $psmIO;
 
108
 
 
109
@inputfile = grep(/datafile/i,$psmIO->unstructured);
 
110
ok !@inputfile;
 
111
 
 
112
ok( $psmIO->release, '2002/04/02 0:11:59');
 
113
 
 
114
@ids     = $psmIO->hid;
 
115
ok @ids,4;
 
116
 
 
117
%weights = $psmIO->weight;
 
118
ok !%weights; #Mast doesn't have weights
 
119
 
 
120
ok %seq    = $psmIO->seq;
 
121
 
 
122
foreach my $id ($psmIO->hid) {
 
123
    ok $seq{$id};
 
124
}
 
125
ok $psm=$psmIO->next_psm;
 
126
 
 
127
my %instances=$psmIO->instances;
 
128
ok %instances;
 
129
 
 
130
ok $psmIO->version, '3.0';
 
131
 
 
132