18
19
use Bio::Matrix::PSM::IO;
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);
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)));
26
48
my @inputfile=grep(/datafile/i,$psmIO->unstructured);
43
65
my $psm = $psmIO->next_psm;
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]));
77
$max=$diff if ($diff>$max);
80
ok $avg<0.01; #Loss of data under 1 percent
82
ok $psm->sequence_match_weight('CAGAAAAATAAAATGGCCACCACCC'),2015;
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');
88
for (my $i = 0;$i<@check;$i++) {
89
my $diff=abs(abs($check[$i])-abs($A[$i]));
91
$max=$diff if ($diff>$max);
94
ok $avg<10; #Loss of data under 1 percent
46
96
my $matrix=$psm->matrix;
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;
77
128
#Now we are going to try transfac
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)));
83
134
my $version=$psmIO->version;
86
137
ok $psmIO->release, '6.4--2002-12-02';
91
139
$psm = $psmIO->next_psm;
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');
148
for (my $i = 0; $i<@check;$i++) {
149
my $diff=abs(abs($check[$i])-abs($A[$i]));
151
$max=$diff if ($diff>$max);
154
ok $avg<0.01; #Loss of data under 1 percent
94
156
%weights = $psmIO->weight;
100
162
#Quick check if returned object works
101
163
$IUPAC = $psm->IUPAC;
102
ok $IUPAC,'NNNNNNNNNNNN';
164
ok $IUPAC,'VVDCAKSTGBYD';
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)));
109
171
@inputfile = grep(/datafile/i,$psmIO->unstructured);
130
192
ok $psmIO->version, '3.0';
194
my $mmastIO=new Bio::Matrix::PSM::IO(-format=>'mast',-file=>Bio::Root::IO->catfile(qw(t data mixedmast.dat)));
196
$psm = $mmastIO->next_psm;
197
my $lastinstances = $psm->instances();
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 ( ));
205
last if ($hit -> start == 1652447);