Fix bug 253 testing for defined
[bioperl-live.git] / t / Tools / PrositeScan.t
blobbd983c598442aefc3a7687127ada34780f7cffc7
1 use strict;
3 BEGIN {
4     use lib '.';
5     use Bio::Root::Test;
7     test_begin(-tests => 3);
9     use_ok('Bio::Tools::PrositeScan');
10     use_ok('Bio::SeqFeature::FeaturePair');
13 # Note: data generated by running
15 #   ./ps_scan.pl --pfscan ./pfscan -d prosite.dat -o fasta \
16 #       t/data/test.fasta > t/data/ps_scan/out.PrositeScan
18 # followed by a manual removal of some of the output to simplify the test.
20 subtest "Predictions" => sub {
21     my $factory = Bio::Tools::PrositeScan->new(
22           '-file'   => test_input_file('ps_scan/out.PrositeScan'),
23           '-format' => 'fasta'
24     );
26     my $expected_matches = [
27         { seq_id => 'roa1_drome', coords => [253, 256], psac => 'PS00001', subseq => 'NNSF' },
28         { seq_id => 'roa1_drome', coords => [270, 273], psac => 'PS00001', subseq => 'NNSW' },
29         { seq_id => 'roa2_drome', coords => [344, 349], psac => 'PS00008', subseq => 'GNNQGF' },
30         { seq_id => 'roa2_drome', coords => [217, 355], psac => 'PS50321', subseq => re(qr/NR.{135}NN/) },
31     ];
33     my $actual_matches = [];
34     while( my $match = $factory->next_prediction ) {
35         push @$actual_matches, {
36             seq_id  =>   $match->seq_id,
37             coords  => [ $match->start, $match->end ],
38             psac    =>   $match->hseq_id,
39             subseq  =>   $match->feature1->seq->seq,
40         };
41     }
43     cmp_deeply( $actual_matches, $expected_matches, 'Comparing parsed prediction input' );