tests pass, find the right nodes more explicitly
[bioperl-run.git] / t / StandAloneFasta.t
blob9f973838aac32e8dcca65b44dc88235161a3a818
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
3 ## $Id$
6 use strict;
7 use constant NUMTESTS => 15;
8 BEGIN { 
9     eval { require Test; };
10     if( $@ ) {
11         use lib 't';
12     }
13     use Test;
14     plan tests => NUMTESTS; 
17 END { 
18     foreach( $Test::ntest..NUMTESTS) {
19         skip('Fasta or env variables not installed correctly',1);
20     }
21     unlink('blastreport.out');
24 use Bio::Tools::Run::Alignment::StandAloneFasta;
25 use Bio::SeqIO;
27 ok(1);
28 my $verbose = -1;
30 my $version = '34';
31 my @params = ( 'b' =>'15', 
32                'd' => 0,
33                'O' =>'resultfile', 
34                'm'=>'9',
35                "program"=>"fasta$version");
36 my $factory = Bio::Tools::Run::Alignment::StandAloneFasta->new
37     ('-verbose' => $verbose,
38      @params);
39 ok $factory;
40 my $inputfilename = Bio::Root::IO->catfile("t","data","fasta.fa");
42 my $fasta_present = $factory->executable();
43 if( ! $fasta_present ) {
44     skip('Fasta  not installed',1);
45     exit;
46 } else { 
47     ok($fasta_present);
49 my $lib = Bio::Root::IO->catfile("t","data","fastalib.fa");
50 $factory->library($lib);
51 my ($fastareport) = $factory->run($inputfilename);
52 my $result = $fastareport->next_result;
53 my $hit    = $result->next_hit();
54 my $hsp    = $hit->next_hsp();
55 ok $hsp->algorithm, 'FASTN';
56 ok $hsp->num_identical, 2982;
57 ok $hsp->length, 2982;
59 $factory->program_name('ssearch'.$version);
60 ($fastareport) = $factory->run($inputfilename);
61 $result = $fastareport->next_result;
62 $hit    = $result->next_hit();
63 $hsp    = $hit->next_hsp();
64 ok $hsp->algorithm, 'SMITH-WATERMAN';
65 ok $hsp->num_identical, 2982;
66 ok $hsp->length, 2982;
68 $factory->program_name('fastx'.$version);
69 $factory->library(Bio::Root::IO->catfile("t","data","fastaprot.fa"));
70 ($fastareport) = $factory->run($inputfilename);
71 $result = $fastareport->next_result;
72 $hit    = $result->next_hit();
73 $hsp    = $hit->next_hsp();
74 ok $hsp->algorithm, 'FASTX';
75 ok $hsp->num_identical, 994;
76 ok $hsp->length, 994;
78 my $sio = Bio::SeqIO->new(-file=>$inputfilename,
79                           -format=>"fasta");
80 my $seq = $sio->next_seq;
82 #test with objects
83 ($fastareport) = $factory->run($seq);
84 $result = $fastareport->next_result;
85 $hit    = $result->next_hit();
86 $hsp    = $hit->next_hsp();
87 ok $hsp->algorithm, 'FASTX';
88 ok $hsp->num_identical, 994;
89 ok $hsp->length, 994;