2 ## Bioperl Test Harness Script for Modules
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
11 test_begin(-tests => 31,
12 -requires_modules => [qw(XML::Twig Bio::Factory::EMBOSS)]);
13 use_ok('Bio::Root::IO');
15 use_ok('Bio::AlignIO');
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(-verbose => $verbose);
33 my $compseqapp = $factory->program('compseq');
35 skip('EMBOSS not installed',27) if !$compseqapp;
37 my $version = $factory->version;
39 my %input = ( '-word' => 4,
40 '-sequence' => test_input_file('dna1.fa'),
41 '-outfile' => $compseqoutfile);
42 $compseqapp->run(\%input);
43 ok(-e $compseqoutfile);
45 my $water = $factory->program('water');
49 # testing in-memory use of
50 my $in = Bio::SeqIO->new(-format => 'fasta',
51 -file => test_input_file('cysprot1a.fa'));
52 my $seq = $in->next_seq();
55 $in = Bio::SeqIO->new(-format => 'fasta',
56 -file => test_input_file('amino.fa'));
57 while( my $s = $in->next_seq) {
62 if( $version ge '2.8.0' ) {
63 $water->run({ '-asequence' => $seq,
64 '-bsequence' => \@amino,
66 '-gapextend' => '0.5',
67 '-outfile' => $wateroutfile});
68 %expected = ( 'alnlen' => 394,
73 $water->run({ '-sequencea' => $seq,
76 '-gapextend' => '0.5',
77 '-outfile' => $wateroutfile});
78 %expected = ( 'alnlen' => 339,
85 my $alnin = Bio::AlignIO->new(-format => 'emboss',
86 -file => $wateroutfile);
89 my $aln = $alnin->next_aln;
92 is($aln->overall_percentage_identity, 100);
93 is($aln->average_percentage_identity, 100);
95 my ($first) = $aln->each_seq();
96 ok($first->seq(), 'SCWSFSTTGNVEGQHFISQNKLVSLSEQNLVDCDHECMEYEGE');
97 $aln = $alnin->next_aln;
100 is($aln->length, $expected{'alnlen'});
101 is(sprintf("%.2f",$aln->overall_percentage_identity), $expected{'opid'});
102 is(sprintf("%.2f",$aln->average_percentage_identity), $expected{'apid'});
105 my $cons = $factory->program('cons');
107 $in = Bio::AlignIO->new(-format => 'msf',
108 -file => test_input_file('cysprot.msf'));
109 my $aln2 = $in->next_aln;
110 if( $version ge '2.8.0' ) {
111 $cons->run({ '-sequence' => $aln2,
112 '-outseq' => $consoutfile});
114 $cons->run({ '-msf' => $aln2,
115 '-outseq'=> $consoutfile});
119 # testing acd parsing and EMBOSSacd methods
121 $compseqapp = $factory->program('compseq');
123 ok my $acd = $compseqapp->acd;
124 is $compseqapp->acd->name, 'compseq';
125 ok my $compseq_mand_acd = $compseqapp->acd->mandatory;
126 ok $compseq_mand_acd->mandatory->qualifier('-word');
127 is $compseq_mand_acd->mandatory->qualifier('-supper1'), 0;
128 is $acd->qualifier('-ppppppp'), 0;
129 ok $acd->qualifier('-reverse');
130 is $acd->category('-reverse'), 'optional';
131 like $acd->values('-reverse'), qr/Yes\/No/;
132 is $acd->descr('-reverse'), 'Set this to be true if you also wish to also count words in the reverse complement of a nucleic sequence.';
133 is $acd->unnamed('-reverse'), 0;
134 is $acd->default('-reverse'), 'No';
139 ## comparing input and ACD qualifiers
140 ## commented out because verbose > 1 prints error messages
141 ## that would confuse users running tests
143 $compseqapp->verbose(1);
144 %input = ( '-word' => 4,
145 '-outfile' => $compseqoutfile);
147 my $a = $compseqapp->run(\%input);
149 ok 1 if $@; # '-sequence' missing
151 %input = ( '-word' => 4,
152 '-incorrect_option' => 'no value',
153 '-sequence' => test_input_file('dna1.fa'),
154 '-outfile' => $compseqoutfile);
156 $compseqapp->run(\%input);
158 ok 1 if $@; # -incorrect_option is incorrect