2 ## Bioperl Test Harness Script for Modules
4 # Before `./Build install' is performed this script should be runnable with
5 # `./Build test'. After `./Build install' it should work as `perl test.t'
10 test_begin(-tests => 32,
11 -requires_modules => [qw(XML::Twig)]);
12 use_ok('Bio::Root::IO');
14 use_ok('Bio::AlignIO');
15 use_ok('Bio::Factory::EMBOSS');
18 my $compseqoutfile = test_output_file();
19 my $wateroutfile = test_output_file();
20 my $consoutfile = test_output_file();
21 my $verbose = test_debug();
23 ## End of black magic.
25 ## Insert additional test code below but remember to change
26 ## the print "1..x\n" in the BEGIN block to reflect the
27 ## total number of tests that will be run.
29 my $factory = Bio::Factory::EMBOSS->new();
33 my $compseqapp = $factory->program('compseq');
35 $factory->verbose($verbose);
37 skip('EMBOSS not installed',27) if !$compseqapp;
39 my $version = $factory->version;
41 my %input = ( '-word' => 4,
42 '-sequence' => test_input_file('dna1.fa'),
43 '-outfile' => $compseqoutfile);
44 $compseqapp->run(\%input);
45 ok(-e $compseqoutfile);
47 my $water = $factory->program('water');
51 # testing in-memory use of
52 my $in = Bio::SeqIO->new(-format => 'fasta',
53 -file => test_input_file('cysprot1a.fa'));
54 my $seq = $in->next_seq();
57 $in = Bio::SeqIO->new(-format => 'fasta',
58 -file => test_input_file('amino.fa'));
59 while( my $s = $in->next_seq) {
64 if( $version ge '2.8.0' ) {
65 $water->run({ '-asequence' => $seq,
66 '-bsequence' => \@amino,
68 '-gapextend' => '0.5',
69 '-outfile' => $wateroutfile});
70 %expected = ( 'alnlen' => 394,
75 $water->run({ '-sequencea' => $seq,
78 '-gapextend' => '0.5',
79 '-outfile' => $wateroutfile});
80 %expected = ( 'alnlen' => 339,
87 my $alnin = Bio::AlignIO->new(-format => 'emboss',
88 -file => $wateroutfile);
91 my $aln = $alnin->next_aln;
94 is($aln->overall_percentage_identity, 100);
95 is($aln->average_percentage_identity, 100);
97 my ($first) = $aln->each_seq();
98 ok($first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE');
99 $aln = $alnin->next_aln;
102 is($aln->length, $expected{'alnlen'});
103 is(sprintf("%.2f",$aln->overall_percentage_identity), $expected{'opid'});
104 is(sprintf("%.2f",$aln->average_percentage_identity), $expected{'apid'});
107 my $cons = $factory->program('cons');
109 $in = Bio::AlignIO->new(-format => 'msf',
110 -file => test_input_file('cysprot.msf'));
111 my $aln2 = $in->next_aln;
112 if( $version ge '2.8.0' ) {
113 $cons->run({ '-sequence' => $aln2,
114 '-outseq' => $consoutfile});
116 $cons->run({ '-msf' => $aln2,
117 '-outseq'=> $consoutfile});
121 # testing acd parsing and EMBOSSacd methods
123 $compseqapp = $factory->program('compseq');
125 ok my $acd = $compseqapp->acd;
126 is $compseqapp->acd->name, 'compseq';
127 ok my $compseq_mand_acd = $compseqapp->acd->mandatory;
128 ok $compseq_mand_acd->mandatory->qualifier('-word');
129 is $compseq_mand_acd->mandatory->qualifier('-supper1'), 0;
130 is $acd->qualifier('-ppppppp'), 0;
131 ok $acd->qualifier('-reverse');
132 is $acd->category('-reverse'), 'optional';
133 like $acd->values('-reverse'), qr/(?:Yes\/No|true)/;
134 like $acd->descr('-reverse'), qr/(?:boolean|true)/;
135 is $acd->unnamed('-reverse'), 0;
136 like $acd->default('-reverse'), qr/(?:Yes\/No|true)/;
141 ## comparing input and ACD qualifiers
142 ## commented out because verbose > 1 prints error messages
143 ## that would confuse users running tests
145 $compseqapp->verbose(1);
146 %input = ( '-word' => 4,
147 '-outfile' => $compseqoutfile);
149 my $a = $compseqapp->run(\%input);
151 ok 1 if $@; # '-sequence' missing
153 %input = ( '-word' => 4,
154 '-incorrect_option' => 'no value',
155 '-sequence' => test_input_file('dna1.fa'),
156 '-outfile' => $compseqoutfile);
158 $compseqapp->run(\%input);
160 ok 1 if $@; # -incorrect_option is incorrect