~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): Charles Plessy
  • Date: 2007-09-21 22:52:22 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070921225222-tt20m2yy6ycuy2d8
Tags: 1.5.2.102-1
* Developer release.
* Upgraded source package to debhelper 5 and standards-version 3.7.2.
* Added libmodule-build-perl and libtest-harness-perl to
  build-depends-indep.
* Disabled automatic CRAN download.
* Using quilt instead of .diff.gz to manage modifications.
* Updated Recommends list for the binary package.
* Moved the "production-quality" scripts to /usr/bin/.
* New maintainer: Debian-Med packaging team mailing list.
* New uploaders: Charles Plessy and Steffen Moeller.
* Updated Depends, Recommends and Suggests.
* Imported in Debian-Med's SVN repository on Alioth.
* Executing the regression tests during package building.
* Moved the Homepage: field out from the package's description.
* Updated watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    }
14
14
    use Test;
15
15
 
16
 
    plan tests => 42;
 
16
    plan tests => 63;
17
17
}
 
18
 
18
19
use Bio::Matrix::PSM::IO;
19
20
 
 
21
 
 
22
my $mmt= "chr04q        170164  170208  strong  -       0       Motif 3 occurrance in chr04q
 
23
chr04q  215755  215799  strong  +       0       Motif 4 occurrance in chr04q
 
24
chr04q  532530  532574  strong  +       2       Motif 2 occurrance in chr04q
 
25
chr04q  539492  539536  strong  -       1       Motif 1 occurrance in chr04q
 
26
chr04q  586113  586157  strong  +       2       Motif 2 occurrance in chr04q
 
27
chr04q  698245  698289  strong  -       0       Motif 4 occurrance in chr04q
 
28
chr04q  804412  804456  strong  -       0       Motif 3 occurrance in chr04q
 
29
chr04q  858870  858914  strong  -       2       Motif 3 occurrance in chr04q
 
30
chr04q  861561  861605  strong  -       2       Motif 3 occurrance in chr04q
 
31
chr04q  916898  916942  strong  -       1       Motif 1 occurrance in chr04q
 
32
chr04q  1146916 1146960 strong  -       0       Motif 1 occurrance in chr04q
 
33
chr04q  1315772 1315816 strong  +       1       Motif 1 occurrance in chr04q
 
34
chr04q  1636119 1636163 strong  +       2       Motif 3 occurrance in chr04q
 
35
chr04q  1636200 1636244 strong  +       2       Motif 1 occurrance in chr04q
 
36
chr04q  1636437 1636481 strong  +       2       Motif 4 occurrance in chr04q
 
37
chr04q  1637361 1637405 strong  +       2       Motif 2 occurrance in chr04q
 
38
chr04q  1652447 1652491 strong  +       1       Motif 4 occurrance in chr04q";
 
39
my @mmt=split(/\n/,$mmt);
 
40
 
20
41
ok(1);
 
42
 
21
43
#Let's try meme here
22
44
my $psmIO =  new Bio::Matrix::PSM::IO(-format=>'meme', 
23
 
                                      -file=>Bio::Root::IO->catfile(qw(t data meme.dat)));
 
45
             -file=>Bio::Root::IO->catfile(qw(t data meme.dat)));
24
46
ok $psmIO;
25
47
 
26
48
my @inputfile=grep(/datafile/i,$psmIO->unstructured);
43
65
my $psm = $psmIO->next_psm;
44
66
ok $psm;
45
67
 
 
68
#Lets try to compress and uncompress the log odds and the frequencies, see if there is no
 
69
#considerable loss of data.
 
70
my $fA=$psm->get_compressed_freq('A');
 
71
my @check=Bio::Matrix::PSM::SiteMatrix::_uncompress_string($fA,1,1);
 
72
my @A=$psm->get_array('A');
 
73
my ($var,$max) = (0,0);
 
74
for (my $i = 0; $i<@check;$i++) {
 
75
  my $diff=abs(abs($check[$i])-abs($A[$i]));
 
76
  $var += $diff;
 
77
  $max=$diff if ($diff>$max);
 
78
}
 
79
my $avg=$var/@check;
 
80
ok $avg<0.01; #Loss of data under 1 percent
 
81
#print $avg,"\n";
 
82
ok $psm->sequence_match_weight('CAGAAAAATAAAATGGCCACCACCC'),2015;
 
83
 
 
84
my $lA=$psm->get_compressed_logs('A');
 
85
@check=Bio::Matrix::PSM::SiteMatrix::_uncompress_string($lA,1000,2);
 
86
@A=$psm->get_logs_array('A');
 
87
($var,$max) = (0,0);
 
88
for (my $i = 0;$i<@check;$i++) {
 
89
  my $diff=abs(abs($check[$i])-abs($A[$i]));
 
90
  $var += $diff;
 
91
  $max=$diff if ($diff>$max);
 
92
}
 
93
$avg=$var/@check;
 
94
ok $avg<10; #Loss of data under 1 percent
 
95
 
46
96
my $matrix=$psm->matrix;
47
97
ok $matrix;
48
98
my $psm2=$psm;
58
108
 
59
109
#Quick check if returned object works
60
110
my $IUPAC=$psm->IUPAC;
61
 
ok $IUPAC,'CAGAAAAATWVAATYCCCACCHCCC';
 
111
ok $IUPAC,'CMKWMAAAKWVAWTYCMCASCHCCM';
62
112
ok $IUPAC,$psm2->IUPAC;
63
113
ok $IUPAC,$matrix->IUPAC;
64
114
 
67
117
 
68
118
foreach my $instance (@{$instances}) {
69
119
  my $id=$instance->primary_id;
 
120
  ok $instance->strand,1;
70
121
  last if (ok $id);
71
122
}
72
123
 
77
128
#Now we are going to try transfac
78
129
 
79
130
$psmIO =  new Bio::Matrix::PSM::IO(-format=>'transfac', 
80
 
                                   -file=> Bio::Root::IO->catfile(qw(t data transfac.dat)));
 
131
          -file=> Bio::Root::IO->catfile(qw(t data transfac.dat)));
81
132
ok $psmIO;
82
133
 
83
134
my $version=$psmIO->version;
85
136
 
86
137
ok $psmIO->release, '6.4--2002-12-02';
87
138
 
88
 
@ids     = $psmIO->hid;
89
 
ok @ids, '1';
90
 
 
91
139
$psm     = $psmIO->next_psm;
92
140
ok $psm;
93
141
 
 
142
# Lets try to compress and uncompress the the frequencies, see if
 
143
# there is no considerable loss of data.
 
144
$fA=$psm->get_compressed_freq('A');
 
145
@check=Bio::Matrix::PSM::SiteMatrix::_uncompress_string($fA,1,1);
 
146
@A=$psm->get_array('A');
 
147
($var,$max) = (0,0);
 
148
for (my $i = 0; $i<@check;$i++) {
 
149
  my $diff=abs(abs($check[$i])-abs($A[$i]));
 
150
  $var += $diff;
 
151
  $max=$diff if ($diff>$max);
 
152
}
 
153
$avg=$var/@check;
 
154
ok $avg<0.01; #Loss of data under 1 percent
 
155
 
94
156
%weights = $psmIO->weight;
95
157
ok !$weights{''};
96
158
 
99
161
 
100
162
#Quick check if returned object works
101
163
$IUPAC   = $psm->IUPAC;
102
 
ok $IUPAC,'NNNNNNNNNNNN';
 
164
ok $IUPAC,'VVDCAKSTGBYD';
103
165
 
104
166
#Now we are going to try mast
105
167
$psmIO =  new Bio::Matrix::PSM::IO(-format=>'mast', 
106
 
                                   -file=>Bio::Root::IO->catfile(qw(t data mast.dat)));
 
168
          -file=>Bio::Root::IO->catfile(qw(t data mast.dat)));
107
169
ok $psmIO;
108
170
 
109
171
@inputfile = grep(/datafile/i,$psmIO->unstructured);
129
191
 
130
192
ok $psmIO->version, '3.0';
131
193
 
 
194
my $mmastIO=new Bio::Matrix::PSM::IO(-format=>'mast',-file=>Bio::Root::IO->catfile(qw(t data mixedmast.dat)));
 
195
 
 
196
$psm = $mmastIO->next_psm; 
 
197
my $lastinstances = $psm->instances();
 
198
my $i=0;
 
199
foreach my $hit (@$lastinstances) {
 
200
    $hit -> end ( $hit-> start () + length ($hit->seq) - 1 ) ; # fix an old bug in InstanceSite.pm
 
201
    my $d=join("\t",$hit->{accession_number},$hit -> start () , $hit-> end (),$hit -> score (),
 
202
    $hit -> strand == 1 ? '+' : '-' , $hit -> frame,  $hit -> desc ( ));
 
203
    ok $d,$mmt[$i];
 
204
    $i++;
 
205
    last if ($hit -> start == 1652447);
 
206
}
 
207
 
132
208