3 ## Bioperl Test Harness Script for Modules
6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.t'
10 use vars qw($error $NTESTS);
13 # to handle systems with no installed Test module
14 # we include the t dir (where a copy of Test.pm is located)
16 eval { require Test; };
22 plan tests => $NTESTS;
25 require Bio::EMBOSS::Factory;
35 my $compseqoutfile = 'dna1.4.compseq';
36 my $wateroutfile = 'cysprot.water';
37 my $consoutfile = 'cysprot.cons';
39 foreach ( $Test::ntest..$NTESTS ) {
40 skip("EMBOSS not installed locally or XML::Twig not installed",1);
42 unlink($compseqoutfile);
43 unlink($wateroutfile);
47 my $verbose = $ENV{'BIOPERLDEBUG'} || -1;
50 ## End of black magic.
52 ## Insert additional test code below but remember to change
53 ## the print "1..x\n" in the BEGIN block to reflect the
54 ## total number of tests that will be run.
56 my $factory = new Bio::Factory::EMBOSS(-verbose => $verbose);
58 my $compseqapp = $factory->program('compseq');
59 exit if( $compseqapp->executable ) ;
61 my $version = $factory->version;
69 my %input = ( '-word' => 4,
70 '-sequence' => Bio::Root::IO->catfile('t',
73 '-outfile' => $compseqoutfile);
74 $compseqapp->run(\%input);
75 ok(-e $compseqoutfile);
76 #if( open(IN, $compseqoutfile) ) {
77 # while(<IN>) { print }
80 my $water = $factory->program('water');
84 # testing in-memory use of
85 my $in = new Bio::SeqIO(-format => 'fasta',
86 -file => Bio::Root::IO->catfile('t',
89 my $seq = $in->next_seq();
92 $in = new Bio::SeqIO(-format => 'fasta',
93 -file => Bio::Root::IO->catfile('t',
96 while( my $s = $in->next_seq) {
101 if( $version ge '2.8.0' ) {
102 $water->run({ '-asequence' => $seq,
103 '-bsequence' => \@amino,
104 '-gapopen' => '10.0',
105 '-gapextend' => '0.5',
106 '-outfile' => $wateroutfile});
107 %expected = ( 'alnlen' => 394,
112 $water->run({ '-sequencea' => $seq,
113 '-seqall' => \@amino,
114 '-gapopen' => '10.0',
115 '-gapextend' => '0.5',
116 '-outfile' => $wateroutfile});
117 %expected = ( 'alnlen' => 339,
122 ok(-e $wateroutfile);
124 my $alnin = new Bio::AlignIO(-format => 'emboss',
125 -file => $wateroutfile);
128 my $aln = $alnin->next_aln;
130 ok($aln->length, 43);
131 ok($aln->overall_percentage_identity, 100);
132 ok($aln->average_percentage_identity, 100);
134 my ($first) = $aln->each_seq();
135 ok($first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE');
136 $aln = $alnin->next_aln;
139 ok($aln->length, $expected{'alnlen'});
140 ok(sprintf("%.2f",$aln->overall_percentage_identity), $expected{'opid'});
141 ok(sprintf("%.2f",$aln->average_percentage_identity), $expected{'apid'});
144 my $cons = $factory->program('cons');
146 $in = new Bio::AlignIO(-format => 'msf',
147 -file => Bio::Root::IO->catfile('t',
150 my $aln2 = $in->next_aln;
151 if( $version ge '2.8.0' ) {
152 $cons->run({ '-sequence' => $aln2,
153 '-outseq' => $consoutfile});
155 $cons->run({ '-msf' => $aln2,
156 '-outseq'=> $consoutfile});
161 # testing acd parsing and EMBOSSacd methods
163 $compseqapp = $factory->program('compseq');
165 exit unless $compseqapp->acd;
166 ok my $acd = $compseqapp->acd;
167 ok $compseqapp->acd->name, 'compseq';
168 ok my $compseq_mand_acd = $compseqapp->acd->mandatory;
169 ok $compseq_mand_acd->mandatory->qualifier('-word');
170 ok $compseq_mand_acd->mandatory->qualifier('-supper1'), 0;
171 ok $acd->qualifier('-ppppppp'), 0;
172 ok $acd->qualifier('-reverse');
173 ok $acd->category('-reverse'), 'optional';
174 ok $acd->values('-reverse'), qr/Yes\/No/;
175 ok $acd->descr('-reverse'), 'Set this to be true if you also wish to also count words in the reverse complement of a nucleic sequence.';
176 ok $acd->unnamed('-reverse'), 0;
177 ok $acd->default('-reverse'), 'No';
179 ## comparing input and ACD qualifiers
180 ## commented out because verbose > 1 prints error messages
181 ## that would confuse users running tests
183 #$compseqapp->verbose(1);
184 #%input = ( '-word' => 4,
185 # '-outfile' => $compseqoutfile);
187 # my $a = $compseqapp->run(\%input);
189 #ok 1 if $@; # '-sequence' missing
191 #%input = ( '-word' => 4,
192 # '-incorrect_option' => 'no value',
193 # '-sequence' => Bio::Root::IO->catfile('t',
196 # '-outfile' => $compseqoutfile);
198 # $compseqapp->run(\%input);
200 #ok 1 if $@; # -incorrect_option is incorrect