2 # ## Bioperl Test Harness Script for Modules
8 test_begin(-tests => 39);
10 use_ok 'Bio::Tools::Run::Alignment::Blat';
15 my $db = test_input_file('blat_dna.fa');
16 my $query = test_input_file('blat_dna.fa');
18 my $factory = Bio::Tools::Run::Alignment::Blat->new(-db => $db);
19 ok $factory->isa('Bio::Tools::Run::Alignment::Blat');
22 test_skip(-requires_executable => $factory,
25 my $searchio = $factory->align($query);
26 isa_ok $searchio, 'Bio::SearchIO';
28 my $result = $searchio->next_result;
29 my $hit = $result->next_hit;
30 my $hsp = $hit->next_hsp;
31 isa_ok($hsp, "Bio::Search::HSP::HSPI");
32 is $hsp->query->start, 1;
33 is $hsp->query->end, 1775;
34 is $hsp->hit->start, 1;
35 is $hsp->hit->end, 1775;
36 is $hsp->hsp_length, 1775;
38 my $sio = Bio::SeqIO->new(-file => $query, -format => 'fasta');
39 my $seq = $sio->next_seq ;
41 $searchio = $factory->align($seq);
42 like $searchio, qr/psl/, 'PSL parser (default)';
43 $result = $searchio->next_result;
44 $hit = $result->next_hit;
45 $hsp = $hit->next_hsp;
46 isa_ok $hsp, 'Bio::Search::HSP::HSPI';
47 is $hsp->query->start, 1;
48 is $hsp->query->end, 1775;
49 is $hsp->hit->start, 1;
50 is $hsp->hit->end, 1775;
52 # test alternate formats (not all of these work!)
53 $factory->reset_parameters(#-quiet => 1,
56 $searchio = $factory->align($query);
58 like $searchio, qr/blast/, 'BLAST parser';
60 $result = $searchio->next_result;
61 $hit = $result->next_hit;
62 $hsp = $hit->next_hsp;
63 isa_ok $hsp, 'Bio::Search::HSP::HSPI';
64 is $hsp->query->start, 1;
65 is $hsp->query->end, 1775;
66 is $hsp->hit->start, 1;
67 is $hsp->hit->end, 1775;
69 $factory->reset_parameters(#-quiet => 1,
72 $searchio = $factory->align($query);
74 like $searchio, qr/blasttable/, 'Tabular BLAST parser';
76 $result = $searchio->next_result;
77 $hit = $result->next_hit;
78 $hsp = $hit->next_hsp;
79 isa_ok $hsp, 'Bio::Search::HSP::HSPI';
80 is $hsp->query->start, 1;
81 is $hsp->query->end, 1775;
82 is $hsp->hit->start, 1;
83 is $hsp->hit->end, 1775;
86 # new wrapper; regions
88 $db = test_input_file('blat_dna.2bit');
90 $factory = Bio::Tools::Run::Alignment::Blat->new(
93 -qsegment => 'sequence_10:0-100',
94 -tsegment => 'sequence_10:0-100',
95 # 0-based, Blat-compatible coordinates (start, end]
97 ok $factory->isa('Bio::Tools::Run::Alignment::Blat');
100 skip("tests that require file named blat_dna.2bit and executable", 10) if ! -e $db;
102 test_skip(-requires_executable => $factory,
105 my $searchio = $factory->align($db);
106 my $result = $searchio->next_result;
107 my $hit = $result->next_hit;
108 my $hsp = $hit->next_hsp;
109 isa_ok $hsp, 'Bio::Search::HSP::HSPI';
110 is $hsp->query->start, 1;
111 is $hsp->query->end, 100;
112 is $hsp->hit->start, 1;
113 is $hsp->hit->end, 100;
115 # No on-the-fly conversion of Bio::Seq yet
116 my $sio = Bio::SeqIO->new(-file=>$query,-format=>'fasta');
117 my $seq = $sio->next_seq ;
119 $searchio = $factory->align($seq);
120 $result = $searchio->next_result;
121 $hit = $result->next_hit;
122 $hsp = $hit->next_hsp;
123 isa_ok $hsp, 'Bio::Search::HSP::HSPI';
124 is $hsp->query->start, 1;
125 is $hsp->query->end, 1775;
126 is $hsp->hit->start, 1;
127 is $hsp->hit->end, 1775;