Supply TEMPLATE and SUFFIX for temporary query sequence files.
[bioperl-run.git] / t / MSAProbs.t
blob2a2ec6fb83854b7c26a68c6fcf59164f54532872
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
3 ## $Id$
5 use strict;
6 BEGIN {
7     use Bio::Root::Test;
8     test_begin(-tests => 19);
9         use_ok('Bio::Tools::Run::Alignment::MSAProbs');
10         use_ok('Bio::Tools::GuessSeqFormat');   
11         use_ok('Bio::AlignIO');
12         use_ok('Bio::SeqIO');
13         use_ok('Bio::Root::IO');
14         use_ok('POSIX');
17 END {     
18         unlink('muscle.log', 'muscle.out');
19         unlink qw(cysprot.dnd cysprot1a.dnd);
22 my @params = ('quiet' => 1);
23 my $factory = Bio::Tools::Run::Alignment::MSAProbs->new(@params);
24 is($factory->quiet, 1);
25 my $inputfilename = test_input_file("cysprot.fa");
26 my $aln;
28 SKIP: {
29         test_skip(-requires_executable => $factory,
30                           -tests => 12);
31         my $version = $factory->version;
32         unless ($version >= 0.94) {
33                 skip("Only muscle version 0.9.4 or higher is supported by these tests. Skipping tests", 7);
34                 exit(0);
35         }
36         cmp_ok ($version, '>=', 0.94, "Code tested only on msaprobs versions > 0.9.4" );
37         $aln = $factory->align($inputfilename);
38         ok($aln);
39         is( $aln->num_sequences, 7);
41         my $str = Bio::SeqIO->new('-file' => 
42                                   test_input_file("cysprot.fa"), 
43                                   '-format' => 'Fasta');
44         my @seq_array =();
45         
46         while ( my $seq = $str->next_seq() ) {
47                 push (@seq_array, $seq) ;
48         }
49         
50         my $seq_array_ref = \@seq_array;
51         
52         $aln = $factory->align($seq_array_ref);
53         is $aln->num_sequences, 7;
54         my $s1_perid = POSIX::ceil($aln->average_percentage_identity);
55         is($s1_perid == 43, 1);
56         
57         my $annotfile = test_output_file();
58         my $outfile = test_output_file();
59         # add some more params
60         @params = ('-quiet'           => 1,
61                        '-verbose'         => 0,
62                    '-outfile'         => $outfile,
63                        '-iterations'      => 5,
64                        '-clustalw'        => 1,
65                        '-consistency'     => 2,
66                        '-alignment_order' => 1,
67                        '-annot_file'      => $annotfile,
68         
69                    );
70         $factory = Bio::Tools::Run::Alignment::MSAProbs->new(@params);
71         my @methods = qw(quiet verbose outfile iterations clustalw consistency
72                          alignment_order annot_file version num_threads);
73         can_ok($factory, @methods);
74         is($factory->annot_file, $annotfile,'annotation file');
75         $aln = $factory->align($seq_array_ref);
76         is $aln->num_sequences, 7;
77         $s1_perid = POSIX::ceil($aln->average_percentage_identity);
78         is($s1_perid == 43, 1 );
79         
80         my $guesser = Bio::Tools::GuessSeqFormat->new(-file => $outfile);
81         my $type = $guesser->guess;
82         is($type, 'clustalw', "Expected output is clustalw formatted");
83         $inputfilename = test_input_file("cysprot1a.fa");
84         $aln = $factory->align($inputfilename);
85         is $aln->num_sequences, 3;
86         $s1_perid = POSIX::ceil($aln->average_percentage_identity);
87         
88         is($s1_perid == 42, 1 );