maint: remove Travis stuff which has been replaced with Github actions (#325)
[bioperl-live.git] / t / Tools / Signalp / ExtendedSignalp.t
blobb66f38d187dc6ea181802f42a9b0d680c1b06729
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
5 use Data::Dumper;
6 BEGIN {
7     use Bio::Root::Test;
8     
9     test_begin(-tests => 185);
10         
11     use_ok('Bio::Tools::Signalp::ExtendedSignalp');
14 ###############################################
15 ### TESTS ON SUMMARY OUTPUT FORMAT (NN+HMM) ###
16 ###############################################
18 my $res = {
19            '1' => {
20                    'id'     => 'BC1G_00003.1',
21                    'pred'   => 'Signal peptide',
22                    'nnpred' => 'signal-peptide',
23                    'end'    => '22',
24                    'prob'   => '0.999',
25                    'anchor' => '0.000',
26                   },
27         '2' => {
28                    'id'     => 'BC1G_00008.1',
29                    'pred'   => 'Non-secretory protein',
30                    'nnpred' => 'signal-peptide',
31                    'end'    => '83',
32                    'prob'   => '0.222',
33                    'anchor' => '0.067',
34                   },
35           };
37 # Test on filtered results
38 my $facts   = [qw(maxS D)];
39 my $in      = test_input_file("signalp.summary");
40 my $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
41                                                         -file => $in,
42                                                         -factors => $facts,
43                                                        );
45 ok($signalp);
46 my $i = 1;
48 while(my $feat = $signalp->next_feature()){
49     #print Dumper($feat);
50     is($feat->seq_id(), $res->{$i}->{id});
51     is($feat->end(), $res->{$i}->{end});
52     is(($feat->get_tag_values('peptideProb'))[0], $res->{$i}->{prob});
53     is(($feat->get_tag_values('anchorProb'))[0], $res->{$i}->{anchor});
54     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
55     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
56     $i++;
59 # Tests without filters.
60 # It should by default only parses results with Ymax and meanS to mimic default behavior
61 # from Bio::Tools::Signalp
62 $res = {
63         '1' => {
64                 'id'     => 'BC1G_00003.1',
65                 'pred'   => 'Signal peptide',
66                 'end'    => '22',
67                 'prob'   => '0.999',
68                 'anchor' => '0.000',
69                },
70         '2' => {
71                 'id'     => 'BC1G_00008.1',
72                 'pred'   => 'Non-secretory protein',
73                 'end'    => '83',
74                 'prob'   => '0.222',
75                 'anchor' => '0.067',
76                },
77        };
79 #No filters required
80 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
81                                                      -file => $in
82                                                     );
83 ok($signalp);
84 $i = 1;
86 while(my $feat = $signalp->next_feature()){
87     is($feat->seq_id(), $res->{$i}->{id});
88     is($feat->end(), $res->{$i}->{end});
89     is(($feat->get_tag_values('peptideProb'))[0], $res->{$i}->{prob});
90     is(($feat->get_tag_values('anchorProb'))[0], $res->{$i}->{anchor});
91     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
92     $i++;
95 #############################################
96 ### TESTS ON SHORT OUTPUT FORMAT (NN+HMM) ###
97 #############################################
99 $res = {
100         '1' => {
101                 'id'     => 'BC1G_00003.1',
102                 'pred'   => 'Signal peptide',
103                 'nnpred' => 'signal-peptide',
104                 'end'    => '22',
105                },
106         '2' => {
107                 'id'     => 'BC1G_00008.1',
108                 'nnpred' => 'signal-peptide',
109                 'pred'   => 'Non-secretory protein',
110                 'end'    => '83',
111                },
112         '3' => {
113                 'id'     => 'BC1G_00009.1',
114                 'nnpred' => 'signal-peptide',
115                 'pred'   => 'Non-secretory protein',
116                 'end'    => '28',
117                 },
118         '4' => {
119                 'id'     => 'BC1G_00010.1',
120                 'nnpred' => 'signal-peptide',
121                 'pred'   => 'Non-secretory protein',
122                 'end'    => '15',
123                 },
125        };
127 # Test on filtered results
128 $facts   = [qw(maxC)];
129 $in      = test_input_file("signalp.short");
130 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
131                                                      -file => $in,
132                                                      -factors => $facts,
133                                                     );
135 ok($signalp);
136 $i = 1;
138 while(my $feat = $signalp->next_feature()){
139     is($feat->seq_id(), $res->{$i}->{id});
140     is($feat->end(), $res->{$i}->{end});
141     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
142     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
143     $i++;
146 # Tests without filters.
147 # It should by default only parses results with Ymax and meanS to mimic default behavior
148 # from GPI::Bio::Tools::Signalp
149 $res = {
150         '1' => {
151                 'id'     => 'BC1G_00003.1',
152                 'pred'   => 'Signal peptide',
153         'prob' => 0.999,
154                 'nnpred' => 'signal-peptide',
155                 'end'    => '22',
156                },
157         '2' => {
158                 'id'     => 'BC1G_00008.1',
159                 'pred'   => 'Non-secretory protein',
160         'prob' => 0.222,
161                 'nnpred' => 'signal-peptide',
162                 'end'    => '83',
163                },
164        };
166 #No filters required
167 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
168                                                      -file => $in
169                                                     );
170 ok($signalp);
171 $i = 1;
173 while(my $feat = $signalp->next_feature()){
174     is($feat->seq_id(), $res->{$i}->{id});
175     is($feat->end(), $res->{$i}->{end});
176     is(($feat->get_tag_values('peptideProb'))[0], $res->{$i}->{prob});
177     is(($feat->get_tag_values('anchorProb'))[0], $res->{$i}->{anchor});
178     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
179     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
180     $i++;
184 ###########################################
185 ### TESTS ON SUMMARY OUTPUT FORMAT (NN) ###
186 ###########################################
188 $res = {
189         '1' => {
190                 'id'     => 'BC1G_00003.1',
191                 'nnpred' => 'signal-peptide',
192                 'end'    => '22',
193                },
194         '2' => {
195                 'id'     => 'BC1G_00008.1',
196                 'nnpred' => 'signal-peptide',
197                 'end'    => '83',
198                },
199        };
201 # Test on filtered results BROKEN
202 $facts   = [qw(maxC)];
203 $in      = test_input_file("signalp.nn.summary");
204 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
205                                                      -file => $in,
206                                                      -factors => $facts,
207                                                     );
209 ok($signalp);
210 $i = 1;
212 while(my $feat = $signalp->next_feature()){
214     is($feat->seq_id(), $res->{$i}->{id});
215     is($feat->end(), $res->{$i}->{end});
216     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
217     $i++;
219 # Tests without filters.
220 # It should by default only parses results with Ymax and meanS to mimic default behavior
221 # from GPI::Bio::Tools::Signalp
222 $res = {
223         '1' => {
224                 'id'     => 'BC1G_00003.1',
225                 'nnpred' => 'signal-peptide',
226                 'end'    => '22',
227                },
228         '2' => {
229                 'id'     => 'BC1G_00008.1',
230                 'nnpred' => 'signal-peptide',
231                 'end'    => '83',
232                },
233         '3' => {
234                 'id'     => 'BC1G_00009.1',
235                 'nnpred' => 'signal-peptide',
236                 'end'    => '28',
237                 },
238         '4' => {
239                 'id'     => 'BC1G_00010.1',
240                 'nnpred' => 'signal-peptide',
241                 'end'    => '15',
242                 },
243        };
245 #No filters required BROKEN
246 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
247                                                      -file => $in
248                                                     );
249 ok($signalp);
250 $i = 1;
252 while(my $feat = $signalp->next_feature()){
254     is($feat->seq_id(), $res->{$i}->{id});
255     is($feat->end(), $res->{$i}->{end});
256     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
257     $i++;
261 ############################################
262 ### TESTS ON SUMMARY OUTPUT FORMAT (HMM) ###
263 ############################################
265 $res = {
266         '1' => {
267                 'id'     => 'BC1G_00002.1',
268                 'prob'   => '0.000',
269                 'anchor' => '0.000',
270                 'cleav'  => '0.000',
271                 'pred'   => 'Non-secretory protein',
272                 'end'    => '22',
273                },
274         '2' => {
275                 'id'     => 'BC1G_00003.1',
276                 'prob'   => '0.999',
277                 'anchor' => '0.000',
278                 'cleav'  => '0.973',
279                 'pred'   => 'Signal peptide',
280                 'end'    => '22',
281                },
282         '3' => {
283                 'id'     => 'BC1G_00004.1',
284                 'prob'   => '0.003',
285                 'anchor' => '0.000',
286                 'cleav'  => '0.001',
287                 'pred'   => 'Non-secretory protein',
288                 'end'    => '19',
289                },
290         '4' => {
291                 'id'     => 'BC1G_00005.1',
292                 'prob'   => '0.008',
293                 'anchor' => '0.000',
294                 'cleav'  => '0.007',
295                 'pred'   => 'Non-secretory protein',
296                 'end'    => '22',
297                 },
298         '5' => {
299                 'id'     => 'BC1G_00006.1',
300                 'prob'   => '0.000',
301                 'anchor' => '0.000',
302                 'cleav'  => '0.000',
303                 'pred'   => 'Non-secretory protein',
304                 'end'    => '23',
305                 },
306         '6' => {
307                 'id'     => 'BC1G_00007.1',
308                 'prob'   => '0.240',
309                 'anchor' => '0.000',
310                 'cleav'  => '0.228',
311                 'pred'   => 'Non-secretory protein',
312                 'end'    => '22',
313                 },
314         '7' => {
315                 'id'     => 'BC1G_00008.1',
316                 'prob'   => '0.222',
317                 'anchor' => '0.067',
318                 'cleav'  => '0.061',
319                 'pred'   => 'Non-secretory protein',
320                 'end'    => '22',
321                 },
322         '8' => {
323                 'id'     => 'BC1G_00009.1',
324                 'prob'   => '0.000',
325                 'anchor' => '0.000',
326                 'cleav'  => '0.000',
327                 'pred'   => 'Non-secretory protein',
328                 'end'    => '20',
329                 },
330        };
332 # It is impossible to filter with hmm output...
333 $in      = test_input_file("signalp.hmm.summary");
334 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
335                                                      -file => $in,
336                                                     );
338 ok($signalp);
339 $i = 1;
341 while(my $feat = $signalp->next_feature()){
342     is($feat->seq_id(), $res->{$i}->{id});
343     is($feat->end(), $res->{$i}->{end});
344     is(($feat->get_tag_values('peptideProb'))[0], $res->{$i}->{prob});
345     is(($feat->get_tag_values('anchorProb'))[0], $res->{$i}->{anchor});
346     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
347     is(($feat->get_tag_values('cleavageSiteProb'))[0], $res->{$i}->{cleav});
348     $i++;
351 #########################################
352 ### TESTS ON SHORT OUTPUT FORMAT (NN) ###
353 #########################################
355 $res = {
356         '1' => {
357                 'id'     => 'BC1G_00003.1',
358                 'nnpred' => 'signal-peptide',
359                 'yprob'  => '0.866',
360                 'dprob'  => '0.902',
361                 'cprob'  => '0.934',
362                 'end'    => '22',
363                },
364         '2' => {
365                 'id'     => 'BC1G_00008.1',
366                 'yprob'  => '0.383',
367                 'dprob'  => '0.436',
368                 'cprob'  => '0.576',
369                 'nnpred' => 'signal-peptide',
370                 'end'    => '83',
371                },
372        };
374 # Test on filtered results
375 $facts   = [qw(maxY)];
376 $in      = test_input_file("signalp.nn.short");
377 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
378                                                      -file => $in,
379                                                      -factors => $facts,
380                                                     );
382 ok($signalp);
383 $i = 1;
385 while(my $feat = $signalp->next_feature()){
386     is($feat->seq_id(), $res->{$i}->{id});
387     is($feat->end(), $res->{$i}->{end});
388     is(($feat->get_tag_values('maxCprob'))[0], $res->{$i}->{cprob});
389     is(($feat->get_tag_values('Dprob'))[0], $res->{$i}->{dprob});
390     is(($feat->get_tag_values('maxYprob'))[0], $res->{$i}->{yprob});
391     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
392     $i++;
394 # Tests without filters.
395 # It should by default only parses results with Ymax and meanS to mimic default behavior
396 # from GPI::Bio::Tools::Signalp
397 $res = {
398         '1' => {
399                 'id'     => 'BC1G_00003.1',
400                 'nnpred' => 'signal-peptide',
401                 'yprob'  => '0.866',
402                 'dprob'  => '0.902',
403                 'cprob'  => '0.934',
404                 'end'    => '22',
405                },
406         '2' => {
407                 'id'     => 'BC1G_00008.1',
408                 'yprob'  => '0.383',
409                 'dprob'  => '0.436',
410                 'cprob'  => '0.576',
411                 'nnpred' => 'signal-peptide',
412                 'end'    => '83',
413                },
414        };
416 #No filters required
417 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
418                                                      -file => $in
419                                                     );
420 ok($signalp);
421 $i = 1;
423 while(my $feat = $signalp->next_feature()){
424     is($feat->seq_id(), $res->{$i}->{id});
425     is($feat->end(), $res->{$i}->{end});
426     is(($feat->get_tag_values('maxCprob'))[0], $res->{$i}->{cprob});
427     is(($feat->get_tag_values('Dprob'))[0], $res->{$i}->{dprob});
428     is(($feat->get_tag_values('maxYprob'))[0], $res->{$i}->{yprob});
429     is(($feat->get_tag_values('nnPrediction'))[0], $res->{$i}->{nnpred});
430     $i++;
433 ##########################################
434 ### TESTS ON SHORT OUTPUT FORMAT (HMM) ###
435 ##########################################
437 $res = {
438         '1' => {
439                 'id'     => 'BC1G_00002.1',
440                 'prob'   => '0.000',
441                 'cleav'  => '0.000',
442                 'pred'   => 'Non-secretory protein',
443                 'end'    => '22',
444                },
445         '2' => {
446                 'id'     => 'BC1G_00003.1',
447                 'prob'   => '0.999',
448                 'cleav'  => '0.973',
449                 'pred'   => 'Signal peptide',
450                 'end'    => '22',
451                },
452         '3' => {
453                 'id'     => 'BC1G_00004.1',
454                 'prob'   => '0.003',
455                 'cleav'  => '0.001',
456                 'pred'   => 'Non-secretory protein',
457                 'end'    => '19',
458                },
459         '4' => {
460                 'id'     => 'BC1G_00005.1',
461                 'prob'   => '0.008',
462                 'cleav'  => '0.007',
463                 'pred'   => 'Non-secretory protein',
464                 'end'    => '22',
465                 },
466         '5' => {
467                 'id'     => 'BC1G_00006.1',
468                 'prob'   => '0.000',
469                 'cleav'  => '0.000',
470                 'pred'   => 'Non-secretory protein',
471                 'end'    => '23',
472                 },
473         '6' => {
474                 'id'     => 'BC1G_00007.1',
475                 'prob'   => '0.240',
476                 'cleav'  => '0.228',
477                 'pred'   => 'Non-secretory protein',
478                 'end'    => '22',
479                 },
480         '7' => {
481                 'id'     => 'BC1G_00008.1',
482                 'prob'   => '0.222',
483                 'cleav'  => '0.061',
484                 'pred'   => 'Non-secretory protein',
485                 'end'    => '22',
486                 },
487         '8' => {
488                 'id'     => 'BC1G_00009.1',
489                 'prob'   => '0.000',
490                 'cleav'  => '0.000',
491                 'pred'   => 'Non-secretory protein',
492                 'end'    => '20',
493                 },
494        };
496 # No filters available with hmm on short output
497 $in      = test_input_file("signalp.hmm.short");
498 $signalp = Bio::Tools::Signalp::ExtendedSignalp->new(
499                                                      -file => $in,
500                                                     );
502 ok($signalp);
503 $i = 1;
505 while(my $feat = $signalp->next_feature()){
506     is($feat->seq_id(), $res->{$i}->{id});
507     is($feat->end(), $res->{$i}->{end});
508     is(($feat->get_tag_values('peptideProb'))[0], $res->{$i}->{prob});
509     is(($feat->get_tag_values('cleavageSiteProb'))[0], $res->{$i}->{cleav});
510     is(($feat->get_tag_values('signalpPrediction'))[0], $res->{$i}->{pred});
511     $i++;
515 exit 0;