bug 1825
[bioperl-live.git] / t / Sim4.t
blob25bc1cfeb138464777bca25191f9dba85941f304
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
5 BEGIN {     
6     use lib 't/lib';
7     use BioperlTest;
8     
9     test_begin(-tests => 129);
10         
11         use_ok('Bio::Tools::Sim4::Results');
12         use_ok('Bio::SearchIO');
15 my $sim4 = Bio::Tools::Sim4::Results->new(-file=> test_input_file('sim4.rev'), -estisfirst=>0);
16 ok ( $sim4, 'new Sim4 results instance') ;
19 my $exonset = $sim4->next_exonset;
20 my @exons = $exonset->sub_SeqFeature(); 
22 is (scalar(@exons), 10);
24 my $exon = 1;
25 is $exons[$exon]->est_hit()->seq_id(), 'HSHNCPA1';
26 like($exons[$exon]->seq_id(), qr/human/);
27 is $exons[$exon]->strand(), -1;
28 is $exons[$exon]->start(), 1048;
29 is $exons[$exon]->end(), 1117;
30 is $exons[$exon]->score, 93;
31 is $exons[$exon]->est_hit()->seqlength(), 1198;
34 $sim4 = Bio::Tools::Sim4::Results->new(-file=> test_input_file('sim4.for.for'), -estisfirst=>0);
35 ok ( $sim4, 'new Sim4 results instance') ;
37 $exonset = $sim4->next_exonset;
38 @exons = $exonset->sub_SeqFeature(); 
40 is (scalar(@exons), 4);
42 $exon = 1;
43 is $exons[$exon]->est_hit()->seq_id(), 'hs_est';
44 is $exons[$exon]->seq_id(), 'human';
45 is $exons[$exon]->strand(), 1;
46 is $exons[$exon]->start(), 1377;
47 is $exons[$exon]->end(), 1500;
48 is $exons[$exon]->score, 99;
49 is $exons[$exon]->est_hit()->seqlength(), 479;
51 ok($sim4->next_exonset);
52 @exons = $exonset->sub_SeqFeature();
54 is $exons[$exon]->est_hit()->seq_id(), 'hs_est';
55 is $exons[$exon]->seq_id(), 'human';
56 is $exons[$exon]->strand(), 1;
57 is $exons[$exon]->est_hit->start(), 120;
58 is $exons[$exon]->est_hit->end(), 243;
59 is $exons[$exon]->score, 99;
60 is $exons[$exon]->est_hit()->seqlength(), 479;
63 # new SearchIO parser for Sim4
65 # parse align format 0
66 my $parser = Bio::SearchIO->new(-format => 'sim4',
67                                -file   => test_input_file('crypto.sim4-0')
68                                );
69 my $r = $parser->next_result;
70 is ($r->query_name, 'cn416');
71 is ($r->query_length, 630);
73 my $hit = $r->next_hit;
74 is ($hit->name, 'Contig147');
75 is ($hit->description, 'Contig147.fa');
76 is ($hit->length, 1086);
78 my $hsp = $hit->next_hsp;
79 is ($hsp->query->start, 36);
80 is ($hsp->query->end, 132);
81 is ($hsp->query->strand, 1);
82 is ($hsp->hit->start, 191);
83 is ($hsp->hit->end, 286);
84 is ($hsp->hit->strand, 1);
86 $hsp = $hit->next_hsp;
87 is ($hsp->query->start, 133);
88 is ($hsp->query->end, 191);
89 is ($hsp->query->strand, 1);
90 is ($hsp->hit->start, 343);
91 is ($hsp->hit->end, 401);
92 is ($hsp->hit->strand, 1);
94 # parse align format 3
95 $parser = Bio::SearchIO->new(-format => 'sim4',
96                             -file   => test_input_file('crypto.sim4-3')
97                             );
98 $r = $parser->next_result;
99 is ($r->query_name, 'cn416');
100 is ($r->query_length, 630);
101 $hit = $r->next_hit;
102 is ($hit->name, 'Contig147');
103 is ($hit->description, 'Contig147.fa');
104 is ($hit->length, 1086);
106 $hsp = $hit->next_hsp;
107 is ($hsp->query->start, 36);
108 is ($hsp->query->end, 132);
109 is ($hsp->query->strand, 1);
110 is ($hsp->hit->start, 191);
111 is ($hsp->hit->end, 286);
112 is ($hsp->hit->strand, 1);
114 $hsp = $hit->next_hsp;
115 is ($hsp->query->start, 133);
116 is ($hsp->query->end, 191);
117 is ($hsp->query->strand, 1);
118 is ($hsp->hit->start, 343);
119 is ($hsp->hit->end, 401);
120 is ($hsp->hit->strand, 1);
122 # parse align format 4
123 $parser = Bio::SearchIO->new(-format => 'sim4',
124                             -file   => test_input_file('crypto.sim4-4')
125                             );
126 $r = $parser->next_result;
127 is ($r->query_name, 'cn416');
128 is ($r->query_length, 630);
130 $hit = $r->next_hit;
131 is ($hit->name, 'Contig147');
132 is ($hit->length, 1086);
134 $hsp = $hit->next_hsp;
135 is ($hsp->query->start, 36);
136 is ($hsp->query->end, 132);
137 is ($hsp->query->strand, 1);
138 is ($hsp->hit->start, 191);
139 is ($hsp->hit->end, 286);
140 is ($hsp->hit->strand, 1);
142 $hsp = $hit->next_hsp;
143 is ($hsp->query->start, 133);
144 is ($hsp->query->end, 191);
145 is ($hsp->query->strand, 1);
146 is ($hsp->hit->start, 343);
147 is ($hsp->hit->end, 401);
148 is ($hsp->hit->strand, 1);
151 # do the other sim4 files
152 $parser = Bio::SearchIO->new(-format => 'sim4',
153                             -file   => test_input_file('sim4.rev')
154                             );
155 $r = $parser->next_result;
156 is ($r->query_name, '/nfs/disk21/birney/prog/wise2/example/human.rev');
157 is ($r->query_length, 5368);
158 $hit = $r->next_hit;
159 is ($hit->name, 'HSHNCPA1');
160 is ($hit->description, 'temp.cdna');
161 is ($hit->length, 1198);
163 $hsp = $hit->next_hsp;
164 is ($hsp->query->start, 486);
165 is ($hsp->query->end, 503);
166 is ($hsp->query->strand, 1);
167 is ($hsp->hit->start, 10);
168 is ($hsp->hit->end, 27);
169 is ($hsp->hit->strand, -1);
171 $hsp = $hit->next_hsp;
172 is ($hsp->query->start, 1048);
173 is ($hsp->query->end, 1117);
174 is ($hsp->query->strand, 1);
175 is ($hsp->hit->start, 194);
176 is ($hsp->hit->end, 265);
177 is ($hsp->hit->strand, -1);
179 # do the other sim4 files fwd
180 $parser = Bio::SearchIO->new(-format => 'sim4',
181                             -file   => test_input_file('sim4.for.for')
182                             );
183 $r = $parser->next_result;
184 is ($r->query_name, 'human.genomic');
185 is ($r->query_length, 5368);
186 $hit = $r->next_hit;
187 is ($hit->name, 'hs_est');
188 is ($hit->description, 'est.for');
189 is ($hit->length, 479);
191 $hsp = $hit->next_hsp;
192 is ($hsp->query->start, 695);
193 is ($hsp->query->end, 813);
194 is ($hsp->query->strand, 1);
195 is ($hsp->hit->start, 1);
196 is ($hsp->hit->end, 119);
197 is ($hsp->hit->strand, 1);
199 $hsp = $hit->next_hsp;
200 is ($hsp->query->start, 1377);
201 is ($hsp->query->end, 1500);
202 is ($hsp->query->strand, 1);
203 is ($hsp->hit->start, 120);
204 is ($hsp->hit->end, 243);
205 is ($hsp->hit->strand, 1);
207 # do the other sim4 files fwd rev
208 $parser = Bio::SearchIO->new(-format => 'sim4',
209                             -file   => test_input_file('sim4.for.rev')
210                             );
211 $r = $parser->next_result;
212 is ($r->query_name, 'human.genomic');
213 is ($r->query_length, 5368);
214 $hit = $r->next_hit;
215 is ($hit->name, 'REVCOMP');
216 is ($hit->description, 'hn_est.rev');
217 is ($hit->length, 479);
219 $hsp = $hit->next_hsp;
220 is ($hsp->query->start, 695);
221 is ($hsp->query->end, 813);
222 is ($hsp->query->strand, 1);
223 is ($hsp->hit->start, 1);
224 is ($hsp->hit->end, 119);
225 is ($hsp->hit->strand, -1);
227 $hsp = $hit->next_hsp;
228 is ($hsp->query->start, 1377);
229 is ($hsp->query->end, 1500);
230 is ($hsp->query->strand, 1);
231 is ($hsp->hit->start, 120);
232 is ($hsp->hit->end, 243);
233 is ($hsp->hit->strand, -1);