Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / FootPrinter.t
blobf4245be986a413aba1943cbd843fa45989fe767d
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
4 use strict;
6 BEGIN {
7     use Bio::Root::Test;
8     test_begin(-tests => 24);
9     use_ok('Bio::Tools::Run::FootPrinter');
10     use_ok('Bio::SeqIO');
13 SKIP: {
14     my $treefile = test_input_file("tree_of_life");
15     
16     my @params = (
17                   'size'=>10,
18                   'sequence_type'=>'upstream',
19                   'subregion_size'=>30,
20                   'position_change_cost'=>5,
21                   'triplet_filtering'=>1,
22                   'pair_filtering'=>1,
23                   'post_filtering'=>1,
24                   'inversion_cost'=>1,
25                   'tree'   =>$treefile,
26                   'details'=>0,
27                   'verbose'=>0);
28     
29     my $fact = Bio::Tools::Run::FootPrinter->new(@params);
30     test_skip(-requires_executable => $fact, -tests => 22);
31     
32     is $fact->size, 10;
33     is $fact->sequence_type, 'upstream';
34     is $fact->subregion_size, 30;
35     is $fact->position_change_cost, 5;
36     is $fact->triplet_filtering,1;
37     is $fact->pair_filtering,1;
38     is $fact->post_filtering,1;
39     is $fact->inversion_cost,1;
40     is $fact->tree, $treefile;
41     
42     my $input= test_input_file("FootPrinter.seq.fa");
43     
44     my $in  = Bio::SeqIO->new(-file => "$input" , '-format' => 'fasta');
45     my @seq;
46     while (my $seq = $in->next_seq){
47       push @seq, $seq; # 6 sequences
48     }
49     my @fp= $fact->run(@seq);
50     is @fp, 6;
51     
52     my $first = shift @fp;
53     
54     my @motifs = $first->sub_SeqFeature;
55     if (@motifs == 2) {
56         # older version of FootPrinter? or version 2.1 is buggy with its silly first
57         # motif of 1 bp below
58         is $motifs[0]->seq_id,'TETRAODON-motif1';
59         is $motifs[0]->seq->seq, 'tacaggatgca';
60         is $motifs[0]->start, 352;
61         is $motifs[0]->end, 362;
62         is $motifs[1]->seq_id,'TETRAODON-motif2';
63         is $motifs[1]->seq->seq, 'ccatatttgga';
64         is $motifs[1]->start, 363;
65         is $motifs[1]->end, 373;
66         ok 1 for 1..4;
67     }
68     elsif (@motifs == 3) {
69         is $motifs[0]->seq_id,'TETRAODON-motif1';
70         is $motifs[0]->seq->seq, 't';
71         is $motifs[0]->start, 352;
72         is $motifs[0]->end, 352;
73         is $motifs[1]->seq_id,'TETRAODON-motif2';
74         is $motifs[1]->seq->seq, 'acaggatgca';
75         is $motifs[1]->start, 353;
76         is $motifs[1]->end, 362;
77         is $motifs[2]->seq_id,'TETRAODON-motif3';
78         is $motifs[2]->seq->seq, 'ccatatttgga';
79         is $motifs[2]->start, 363;
80         is $motifs[2]->end, 373;
81     }