Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / Amap.t
blobc46989cf41c688e3e8854e273b50e395d58bde86
1 # -*-Perl-*-
2 # $Id$
4 use strict;
6 BEGIN { 
7   use Bio::Root::Test;
8   test_begin(-tests => 18);
9   
10   use_ok('Bio::Tools::Run::Alignment::Amap');
11   use_ok('Bio::SeqIO');
12   use_ok('File::Spec');
15 END {
16   # Things to do right at the very end, just
17   # when the  interpreter finishes/exits
18   # E.g. deleting intermediate files produced during the test
19   foreach my $file ( qw(cysprot.dnd cysprot1a.dnd mlc) ) {
20     unlink $file;
21   }
24 # if we got to here, thats OK!
25 # is this really needed?
26 #ok( 1, 'All the required modules are present');
28 # setup input files etc
29 my $inputfilename = test_input_file("cysprot.fa");
30 ok( -e $inputfilename, 'Found input file' );
32 # setup output files etc
33 # none in this test
35 # setup global objects that are to be used in more than one test
36 # Also test they were initialised correctly
37 my @params = ();
38 my $factory = Bio::Tools::Run::Alignment::Amap->new(@params);
39 isa_ok( $factory, 'Bio::Tools::Run::Alignment::Amap');
41 # test factory default values
42 is( $factory->program_dir, undef,                        'program_dir returned correct default' );
43 is( $factory->error_string, '',                          'error_string returned correct default' );
44 is( $factory->aformat, 'fasta',                          'aformat returned correct default' );
45 is( $factory->outfile_name, 'mlc',                       'outfile_name returned correct default' );
47 # Now onto the nitty gritty tests of the modules methods
48 is( $factory->program_name(), 'amap',                    'Correct exe default name' );
50 # block of tests to skip if you know the tests will fail
51 # under some condition. E.g.:
52 #   Need network access,
53 #   Wont work on particular OS,
54 #   Cant find the exectuable
55 # DO NOT just skip tests that seem to fail for an unknown reason
57 SKIP: {
58   # condition used to skip this block of tests
59   #skip($why, $how_many_in_block);
60   test_skip(-requires_executable => $factory,
61                         -tests => 8);
63   # test all factory methods that depend on the executable
64   # TODO: isnt( $factory->program_dir, undef,              'program found in ENV variable' );
65   ok( $factory->version >= 2.0,                            'Correct minimum program version' );
66   
67   # test execution using filename
68   my $aln = $factory->align($inputfilename);
69   
70   # now test the factory error methods etc
71   is( $factory->error_string, '',                          'No error occured' );
72   isnt( $factory->outfile_name, undef,                     'outfile_name returned something' );
73   
74   # now test its output
75   isa_ok( $aln, 'Bio::SimpleAlign');
76   is( $aln->num_sequences, 7,                               'Correct number of seqs returned' );
77   
78   # test execution using an array of Seq objects
79   my $str = Bio::SeqIO->new(
80                         '-file' => $inputfilename,
81                         '-format' => 'Fasta',
82   );
83   my @seq_array =();
84   while ( my $seq = $str->next_seq() ) {
85     push (@seq_array, $seq) ;
86   }
87   $aln = $factory->align(\@seq_array);
88   # now test its output
89   isa_ok( $aln, 'Bio::SimpleAlign');
90   is( $aln->num_sequences, 7,                            'Correct number of seqs returned' );
92   # Use this alignment to fully test the methods
93   is( int($aln->average_percentage_identity), 45,       'Got the correct ave % identity' );
94   
97 # TODO: test factory methods that change parameters
98 #TODO: {
99 #  local $TODO = 'program_name setting is unfinished';
100 #  $factory->program_name('something_silly');
101 #  is( $factory->program_name, 'something_silly',        'Set and got program_name correctly') ;