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'
13 -requires_modules => [qw(XML::Twig)]
15 use_ok('Bio::Root::IO');
17 use_ok('Bio::AlignIO');
18 use_ok('Bio::Factory::EMBOSS');
21 my $compseqoutfile = test_output_file();
22 my $wateroutfile = test_output_file();
23 my $consoutfile = test_output_file();
24 my $verbose = test_debug();
26 ## End of black magic.
28 ## Insert additional test code below but remember to change
29 ## the print "1..x\n" in the BEGIN block to reflect the
30 ## total number of tests that will be run.
32 my $factory = Bio::Factory::EMBOSS->new();
36 my $compseqapp = $factory->program('compseq');
38 $factory->verbose($verbose);
40 skip( 'EMBOSS not installed', 26 ) if ! $compseqapp;
42 my $version = $factory->version;
46 -sequence => test_input_file('dna1.fa'),
47 -outfile => $compseqoutfile
49 $compseqapp->run( \%input );
50 ok( -e $compseqoutfile );
52 my $water = $factory->program('water');
55 # testing in-memory use of
56 my $in = Bio::SeqIO->new(
58 -file => test_input_file('cysprot1a.fa')
60 my $seq = $in->next_seq();
63 $in = Bio::SeqIO->new(
65 -file => test_input_file('amino.fa')
67 while ( my $s = $in->next_seq ) {
72 if ( $version ge '2.8.0' ) {
75 -bsequence => \@amino,
78 -outfile => $wateroutfile
93 -outfile => $wateroutfile
103 ok( -e $wateroutfile );
105 my $alnin = Bio::AlignIO->new(
107 -file => $wateroutfile
111 my $aln = $alnin->next_aln;
113 is( $aln->length, 43 );
114 is( $aln->overall_percentage_identity, 100 );
115 is( $aln->average_percentage_identity, 100 );
117 my ($first) = $aln->each_seq();
118 ok( $first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE' );
119 $aln = $alnin->next_aln;
122 is( $aln->length, $expected{'alnlen'} );
123 is( sprintf( "%.2f", $aln->overall_percentage_identity ),
125 is( sprintf( "%.2f", $aln->average_percentage_identity ),
128 my $cons = $factory->program('cons');
130 $in = Bio::AlignIO->new(
132 -file => test_input_file('cysprot.msf')
134 my $aln2 = $in->next_aln;
135 if ( $version ge '2.8.0' ) {
137 { -sequence => $aln2,
138 -outseq => $consoutfile
144 -outseq => $consoutfile
148 ok( -e $consoutfile );
150 # testing acd parsing and EMBOSSacd methods
152 $compseqapp = $factory->program('compseq');
154 ok my $acd = $compseqapp->acd;
155 is $compseqapp->acd->name, 'compseq';
156 ok my $compseq_mand_acd = $compseqapp->acd->mandatory;
157 ok $compseq_mand_acd->mandatory->qualifier('-word');
158 is $compseq_mand_acd->mandatory->qualifier('-supper1'), 0;
159 is $acd->qualifier('-ppppppp'), 0;
160 ok $acd->qualifier('-reverse');
161 is $acd->category('-reverse'), 'optional';
162 like $acd->values('-reverse'), qr/(?:Yes\/No|true)/;
163 like $acd->descr('-reverse'), qr/(?:boolean|true)/;
164 is $acd->unnamed('-reverse'), 0;
165 like $acd->default('-reverse'), qr/(?:Yes\/No|true)/;
170 ## comparing input and ACD qualifiers
171 ## commented out because verbose > 1 prints error messages
172 ## that would confuse users running tests
174 $compseqapp->verbose(1);
175 %input = ( '-word' => 4,
176 '-outfile' => $compseqoutfile);
178 my $a = $compseqapp->run(\%input);
180 ok 1 if $@; # '-sequence' missing
182 %input = ( '-word' => 4,
183 '-incorrect_option' => 'no value',
184 '-sequence' => test_input_file('dna1.fa'),
185 '-outfile' => $compseqoutfile);
187 $compseqapp->run(\%input);
189 ok 1 if $@; # -incorrect_option is incorrect