1# -*-Perl-*- Test Harness script for Bioperl
2# $Id: Sim4.t 11525 2007-06-27 10:16:38Z sendu $
3
4use strict;
5BEGIN {
6    use Bio::Root::Test;
7
8    test_begin(-tests => 102);
9
10	use_ok('Bio::SearchIO');
11}
12
13# parse align format 0
14my $parser = Bio::SearchIO->new(-format => 'sim4',
15			       -file   => test_input_file('crypto.sim4-0')
16			       );
17my $r = $parser->next_result;
18is ($r->query_name, 'cn416');
19is ($r->query_length, 630);
20
21my $hit = $r->next_hit;
22is ($hit->name, 'Contig147');
23is ($hit->description, 'Contig147.fa');
24is ($hit->length, 1086);
25
26my $hsp = $hit->next_hsp;
27is ($hsp->query->start, 36);
28is ($hsp->query->end, 132);
29is ($hsp->query->strand, 1);
30is ($hsp->hit->start, 191);
31is ($hsp->hit->end, 286);
32is ($hsp->hit->strand, 1);
33
34$hsp = $hit->next_hsp;
35is ($hsp->query->start, 133);
36is ($hsp->query->end, 191);
37is ($hsp->query->strand, 1);
38is ($hsp->hit->start, 343);
39is ($hsp->hit->end, 401);
40is ($hsp->hit->strand, 1);
41
42# parse align format 3
43$parser = Bio::SearchIO->new(-format => 'sim4',
44			    -file   => test_input_file('crypto.sim4-3')
45			    );
46$r = $parser->next_result;
47is ($r->query_name, 'cn416');
48is ($r->query_length, 630);
49$hit = $r->next_hit;
50is ($hit->name, 'Contig147');
51is ($hit->description, 'Contig147.fa');
52is ($hit->length, 1086);
53
54$hsp = $hit->next_hsp;
55is ($hsp->query->start, 36);
56is ($hsp->query->end, 132);
57is ($hsp->query->strand, 1);
58is ($hsp->hit->start, 191);
59is ($hsp->hit->end, 286);
60is ($hsp->hit->strand, 1);
61
62$hsp = $hit->next_hsp;
63is ($hsp->query->start, 133);
64is ($hsp->query->end, 191);
65is ($hsp->query->strand, 1);
66is ($hsp->hit->start, 343);
67is ($hsp->hit->end, 401);
68is ($hsp->hit->strand, 1);
69
70# parse align format 4
71$parser = Bio::SearchIO->new(-format => 'sim4',
72			    -file   => test_input_file('crypto.sim4-4')
73			    );
74$r = $parser->next_result;
75is ($r->query_name, 'cn416');
76is ($r->query_length, 630);
77
78$hit = $r->next_hit;
79is ($hit->name, 'Contig147');
80is ($hit->length, 1086);
81
82$hsp = $hit->next_hsp;
83is ($hsp->query->start, 36);
84is ($hsp->query->end, 132);
85is ($hsp->query->strand, 1);
86is ($hsp->hit->start, 191);
87is ($hsp->hit->end, 286);
88is ($hsp->hit->strand, 1);
89
90$hsp = $hit->next_hsp;
91is ($hsp->query->start, 133);
92is ($hsp->query->end, 191);
93is ($hsp->query->strand, 1);
94is ($hsp->hit->start, 343);
95is ($hsp->hit->end, 401);
96is ($hsp->hit->strand, 1);
97
98
99# do the other sim4 files
100$parser = Bio::SearchIO->new(-format => 'sim4',
101			    -file   => test_input_file('sim4.rev')
102			    );
103$r = $parser->next_result;
104is ($r->query_name, '/nfs/disk21/birney/prog/wise2/example/human.rev');
105is ($r->query_length, 5368);
106$hit = $r->next_hit;
107is ($hit->name, 'HSHNCPA1');
108is ($hit->description, 'temp.cdna');
109is ($hit->length, 1198);
110
111$hsp = $hit->next_hsp;
112is ($hsp->query->start, 486);
113is ($hsp->query->end, 503);
114is ($hsp->query->strand, 1);
115is ($hsp->hit->start, 10);
116is ($hsp->hit->end, 27);
117is ($hsp->hit->strand, -1);
118
119$hsp = $hit->next_hsp;
120is ($hsp->query->start, 1048);
121is ($hsp->query->end, 1117);
122is ($hsp->query->strand, 1);
123is ($hsp->hit->start, 194);
124is ($hsp->hit->end, 265);
125is ($hsp->hit->strand, -1);
126
127# do the other sim4 files fwd
128$parser = Bio::SearchIO->new(-format => 'sim4',
129			    -file   => test_input_file('sim4.for.for')
130			    );
131$r = $parser->next_result;
132is ($r->query_name, 'human.genomic');
133is ($r->query_length, 5368);
134$hit = $r->next_hit;
135is ($hit->name, 'hs_est');
136is ($hit->description, 'est.for');
137is ($hit->length, 479);
138
139$hsp = $hit->next_hsp;
140is ($hsp->query->start, 695);
141is ($hsp->query->end, 813);
142is ($hsp->query->strand, 1);
143is ($hsp->hit->start, 1);
144is ($hsp->hit->end, 119);
145is ($hsp->hit->strand, 1);
146
147$hsp = $hit->next_hsp;
148is ($hsp->query->start, 1377);
149is ($hsp->query->end, 1500);
150is ($hsp->query->strand, 1);
151is ($hsp->hit->start, 120);
152is ($hsp->hit->end, 243);
153is ($hsp->hit->strand, 1);
154
155# do the other sim4 files fwd rev
156$parser = Bio::SearchIO->new(-format => 'sim4',
157			    -file   => test_input_file('sim4.for.rev')
158			    );
159$r = $parser->next_result;
160is ($r->query_name, 'human.genomic');
161is ($r->query_length, 5368);
162$hit = $r->next_hit;
163is ($hit->name, 'REVCOMP');
164is ($hit->description, 'hn_est.rev');
165is ($hit->length, 479);
166
167$hsp = $hit->next_hsp;
168is ($hsp->query->start, 695);
169is ($hsp->query->end, 813);
170is ($hsp->query->strand, 1);
171is ($hsp->hit->start, 1);
172is ($hsp->hit->end, 119);
173is ($hsp->hit->strand, -1);
174
175$hsp = $hit->next_hsp;
176is ($hsp->query->start, 1377);
177is ($hsp->query->end, 1500);
178is ($hsp->query->strand, 1);
179is ($hsp->hit->start, 120);
180is ($hsp->hit->end, 243);
181is ($hsp->hit->strand, -1);
182