4 test_begin(-tests => 185);
6 use_ok 'Bio::PrimarySeq';
7 use_ok 'Bio::SeqFeature::Primer';
8 use_ok 'Bio::Tools::AmpliconSearch';
12 my ($search, $amplicon, $seq, $seq2, $forward, $forward2, $reverse, $reverse2,
13 $primer, $primer_seq, $annotated, $num_feats, $template_seq, $rna);
18 ok $search = Bio::Tools::AmpliconSearch->new(), 'Basic';
19 isa_ok $search, 'Bio::Tools::AmpliconSearch';
24 $seq = Bio::PrimarySeq->new(
25 -seq => 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac',
28 $rna = Bio::PrimarySeq->new(
29 -seq => 'acgAAACUUAAAGGAAUUGACGGacguacguacguGUACACACCGCCCGUacguac',
33 $forward = Bio::PrimarySeq->new(
34 -seq => 'AAACTTAAAGGAATTGACGG',
36 ok $search = Bio::Tools::AmpliconSearch->new(
38 -fwd_primer => $forward,
40 ), 'Forward primer only';
41 is $search->fwd_primer->seq, 'AAACTTAAAGGAATTGACGG';
42 is $search->rev_primer, undef;
43 ok $template_seq = $search->template;
44 isa_ok $template_seq, 'Bio::Seq';
45 is $template_seq->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
46 ok $amplicon = $search->next_amplicon;
47 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
48 is $amplicon->start, 4;
49 is $amplicon->end, 56;
50 is $amplicon->strand, 1;
51 is $amplicon->seq->seq, 'AAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
52 ok $primer = $amplicon->fwd_primer;
53 ok $primer_seq = $primer->seq;
54 is $primer_seq->seq, 'AAACTTAAAGGAATTGACGG';
57 is $primer->strand, 1;
58 is $amplicon = $search->next_amplicon, undef;
63 $seq = Bio::PrimarySeq->new(
64 -seq => 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac',
66 $reverse = Bio::SeqFeature::Primer->new(
67 -seq => 'ACGGGCGGTGTGTAC',
69 ok $search = Bio::Tools::AmpliconSearch->new(
71 -rev_primer => $reverse,
73 ), 'Reverse primer only';
74 is $search->fwd_primer, undef;
75 is $search->rev_primer->seq->seq, 'ACGGGCGGTGTGTAC';
76 is $search->template->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
77 ok $amplicon = $search->next_amplicon;
78 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
79 is $amplicon->start, 1;
80 is $amplicon->end, 50;
81 is $amplicon->strand, 1;
82 is $amplicon->seq->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGT';
83 is $amplicon->fwd_primer, undef;
84 is $amplicon->rev_primer, undef;
85 is $search->next_amplicon, undef;
88 # Forward and reverse primers, no amplicon
90 $seq = Bio::PrimarySeq->new(
91 -seq => 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac',
93 $forward = Bio::PrimarySeq->new(
94 -seq => 'AAACTTAAAGGAATTGACGG',
96 $reverse = Bio::PrimarySeq->new(
99 ok $search = Bio::Tools::AmpliconSearch->new(
101 -fwd_primer => $forward,
102 -rev_primer => $reverse,
103 ), 'Two primers, no match';
104 is $search->fwd_primer->seq, 'AAACTTAAAGGAATTGACGG';
105 is $search->rev_primer->seq, 'CCCCCCCCCC';
106 is $search->template->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
107 is $search->next_amplicon, undef;
110 # Degenerate forward and reverse primers from file, single amplicon
112 ok $search = Bio::Tools::AmpliconSearch->new(
114 -primer_file => test_input_file('forward_reverse_primers.fa'),
115 ), 'Two degenerate primers from a file';
116 is $search->fwd_primer->seq, 'AAACTYAAAKGAATTGRCGG';
117 is $search->rev_primer->seq, 'ACGGGCGGTGTGTRC';
118 is $search->template->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
119 ok $amplicon = $search->next_amplicon;
120 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
121 is $amplicon->start, 4;
122 is $amplicon->end, 50;
123 is $amplicon->strand, 1;
124 is $amplicon->seq->seq, 'AAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGT';
125 is $search->next_amplicon, undef;
128 # Same thing but with RNA template
130 ok $search = Bio::Tools::AmpliconSearch->new(
132 -primer_file => test_input_file('forward_reverse_primers.fa'),
134 is $search->fwd_primer->seq, 'AAACTYAAAKGAATTGRCGG';
135 is $search->rev_primer->seq, 'ACGGGCGGTGTGTRC';
136 is $search->template->seq, 'acgAAACUUAAAGGAAUUGACGGacguacguacguGUACACACCGCCCGUacguac';
137 ok $amplicon = $search->next_amplicon;
138 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
139 is $amplicon->start, 4;
140 is $amplicon->end, 50;
141 is $amplicon->strand, 1;
142 is $amplicon->seq->seq, 'AAACUUAAAGGAAUUGACGGacguacguacguGUACACACCGCCCGU';
143 is $search->next_amplicon, undef;
146 # Forward primer only, in sequence file
148 ok $search = Bio::Tools::AmpliconSearch->new(
149 -primer_file => test_input_file('forward_primer.fa'),
150 ), 'Forward primer from file';
151 ok $search->template($seq);
152 is $search->fwd_primer->seq, 'AAACTTAAAGGAATTGACGG';
153 is $search->rev_primer, undef;
154 ok $template_seq = $search->template;
155 isa_ok $template_seq, 'Bio::Seq';
156 is $template_seq->seq, 'acgAAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
157 ok $amplicon = $search->next_amplicon;
158 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
159 is $amplicon->start, 4;
160 is $amplicon->end, 56;
161 is $amplicon->strand, 1;
162 is $amplicon->seq->seq, 'AAACTTAAAGGAATTGACGGacgtacgtacgtGTACACACCGCCCGTacgtac';
163 is $amplicon = $search->next_amplicon, undef;
168 $seq = Bio::PrimarySeq->new(
169 -seq => 'acgtaCCCCacgtacgtacTTTTTTacgtaCCCCacgtaTTTTTTacgtacgtac',
171 $forward = Bio::PrimarySeq->new(
174 $reverse = Bio::PrimarySeq->new(
177 ok $search = Bio::Tools::AmpliconSearch->new(
179 -fwd_primer => $forward,
180 -rev_primer => $reverse,
181 ), 'Multiple amplicons';
182 ok $amplicon = $search->next_amplicon;
183 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
184 is $amplicon->start, 6;
185 is $amplicon->end, 25;
186 is $amplicon->strand, 1;
187 is $amplicon->seq->seq, 'CCCCacgtacgtacTTTTTT';
188 ok $amplicon = $search->next_amplicon;
189 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
190 is $amplicon->start, 31;
191 is $amplicon->end, 45;
192 is $amplicon->strand, 1;
193 is $amplicon->seq->seq, 'CCCCacgtaTTTTTT';
194 is $search->next_amplicon, undef;
197 # Amplicon on reverse strand
199 $seq = Bio::PrimarySeq->new(
200 # Reverse-complement of previous sequence... should have same amplicons
201 -seq => 'gtacgtacgtAAAAAAtacgtGGGGtacgtAAAAAAgtacgtacgtGGGGtacgt',
203 $forward = Bio::PrimarySeq->new(
206 $reverse = Bio::PrimarySeq->new(
209 ok $search = Bio::Tools::AmpliconSearch->new(
211 -fwd_primer => $forward,
212 -rev_primer => $reverse,
213 ), 'Amplicon on reverse strand';
214 ok $amplicon = $search->next_amplicon;
215 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
216 is $amplicon->start, 11;
217 is $amplicon->end, 25;
218 is $amplicon->strand, -1;
219 is $amplicon->seq->seq, 'CCCCacgtaTTTTTT';
220 ok $amplicon = $search->next_amplicon;
221 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
222 is $amplicon->start, 31;
223 is $amplicon->end, 50;
224 is $amplicon->strand, -1;
225 is $amplicon->seq->seq, 'CCCCacgtacgtacTTTTTT';
226 is $search->next_amplicon, undef;
229 # Overlapping amplicons (1)
231 $seq = Bio::PrimarySeq->new(
232 -seq => 'acgtaCCCCacgtacgtacgtacgCCCCacgtaTTTTTTacgtacgtac',
234 $forward = Bio::PrimarySeq->new(
237 $reverse = Bio::PrimarySeq->new(
240 ok $search = Bio::Tools::AmpliconSearch->new(
242 -fwd_primer => $forward,
243 -rev_primer => $reverse,
244 ), 'Overlapping amplicons (1)';
245 ok $amplicon = $search->next_amplicon;
246 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
247 is $amplicon->start, 25;
248 is $amplicon->end, 39;
249 is $amplicon->strand, 1;
250 is $amplicon->seq->seq, 'CCCCacgtaTTTTTT';
251 is $search->next_amplicon, undef;
254 # Overlapping amplicons (2)
256 $seq = Bio::PrimarySeq->new(
257 -seq => 'acgtaCCCCacgtacgtacgtacgTTTTTTacgtaTTTTTTacgtacgtac',
259 $forward = Bio::PrimarySeq->new(
262 $reverse = Bio::PrimarySeq->new(
265 ok $search = Bio::Tools::AmpliconSearch->new(
267 -fwd_primer => $forward,
268 -rev_primer => $reverse,
269 ), 'Overlapping amplicons (2)';
270 ok $amplicon = $search->next_amplicon;
271 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
272 is $amplicon->start, 6;
273 is $amplicon->end, 30;
274 is $amplicon->strand, 1;
275 is $amplicon->seq->seq, 'CCCCacgtacgtacgtacgTTTTTT';
276 is $search->next_amplicon, undef;
279 # Overlapping amplicons (3)
281 $seq = Bio::PrimarySeq->new(
282 -seq => 'acgtaCCCCacgtacgCCCCacgtacgaTTTTTTacgtaTTTTTTaaaaaaaaaa',
284 $forward = Bio::PrimarySeq->new(
287 $reverse = Bio::PrimarySeq->new(
290 ok $search = Bio::Tools::AmpliconSearch->new(
292 -fwd_primer => $forward,
293 -rev_primer => $reverse,
294 ), 'Overlapping amplicons (3)';
295 ok $amplicon = $search->next_amplicon;
296 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
297 is $amplicon->start, 17;
298 is $amplicon->end, 34;
299 is $amplicon->strand, 1;
300 is $amplicon->seq->seq, 'CCCCacgtacgaTTTTTT';
301 is $search->next_amplicon, undef;
304 # Amplicons on both strands
306 $seq = Bio::PrimarySeq->new(
307 -seq => 'acgtaCCCCacgtaacgtaTTTTTTacAAAAAAgtGGGGacgtaacgta',
309 $forward = Bio::PrimarySeq->new(
312 $reverse = Bio::PrimarySeq->new(
315 ok $search = Bio::Tools::AmpliconSearch->new(
317 -fwd_primer => $forward,
318 -rev_primer => $reverse,
319 ), 'Amplicons on both strands';
320 ok $amplicon = $search->next_amplicon;
321 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
322 is $amplicon->start, 6;
323 is $amplicon->end, 25;
324 is $amplicon->strand, 1;
325 is $amplicon->seq->seq, 'CCCCacgtaacgtaTTTTTT';
326 ok $amplicon = $search->next_amplicon;
327 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
328 is $amplicon->start, 28;
329 is $amplicon->end, 39;
330 is $amplicon->strand, -1;
331 is $amplicon->seq->seq, 'CCCCacTTTTTT';
332 is $search->next_amplicon, undef;
335 # Overlapping amplicons on both strands
337 $seq = Bio::PrimarySeq->new(
338 -seq => 'acgtaCCCCacgtacgtacagAAAAAATTTTTTacgtGGGGacgtacgtac',
340 $forward = Bio::PrimarySeq->new(
343 $reverse = Bio::PrimarySeq->new(
346 ok $search = Bio::Tools::AmpliconSearch->new(
348 -fwd_primer => $forward,
349 -rev_primer => $reverse,
350 ), 'Overlapping amplicons on both strands';
351 ok $amplicon = $search->next_amplicon;
352 isa_ok $amplicon, 'Bio::SeqFeature::Amplicon';
353 is $amplicon->start, 22;
354 is $amplicon->end, 41;
355 is $amplicon->strand, -1;
356 is $amplicon->seq->seq, 'CCCCacgtAAAAAATTTTTT';
357 is $search->next_amplicon, undef;
362 $seq = Bio::PrimarySeq->new(
363 -seq => 'acgtaCCCCacgtacgtacTTTTTTacAAAAAAgtGGGGacgtacgtac',
365 $forward = Bio::PrimarySeq->new(
368 $reverse = Bio::PrimarySeq->new(
371 ok $search = Bio::Tools::AmpliconSearch->new(
373 -fwd_primer => $forward,
374 -rev_primer => $reverse,
375 ), 'Annotated template';
376 ok $annotated = $search->annotate_template;
377 isa_ok $annotated, 'Bio::Seq';
379 for my $feat ( $annotated->get_SeqFeatures ) {
381 isa_ok $feat, 'Bio::SeqFeature::Amplicon';
384 is $search->next_amplicon, undef;
389 $seq = Bio::PrimarySeq->new(
390 -seq => 'acgtaCCCCacgtacgtacTTTTTTacCTCTCTgtTGTGTGacgtacgtac',
392 $forward = Bio::PrimarySeq->new(
395 $reverse = Bio::PrimarySeq->new(
398 $forward2 = Bio::PrimarySeq->new(
401 $reverse2 = Bio::PrimarySeq->new(
404 ok $search = Bio::Tools::AmpliconSearch->new(
407 ok $search->fwd_primer($forward);
408 is $search->fwd_primer->seq, 'CTCTCT';
409 ok $search->rev_primer($reverse);
410 is $search->rev_primer->seq, 'CACACA';
411 ok $amplicon = $search->next_amplicon;
412 is $amplicon->seq->seq, 'CTCTCTgtTGTGTG';
413 is $search->next_amplicon, undef;
414 ok $search->fwd_primer($forward2);
415 ok $search->rev_primer($reverse2);
416 is $search->fwd_primer->seq, 'CCCC';
417 is $search->rev_primer->seq, 'AAAAAA';
418 ok $amplicon = $search->next_amplicon;
419 is $amplicon->seq->seq, 'CCCCacgtacgtacTTTTTT';
420 is $search->next_amplicon, undef;
425 $seq = Bio::PrimarySeq->new(
426 -seq => 'acgtaCCCCacgtacgtacTTTTTTa',
428 $seq2 = Bio::PrimarySeq->new(
429 -seq => 'aCCCCgaTTTTTTgacgtacgtac',
431 $forward = Bio::PrimarySeq->new(
434 $reverse = Bio::PrimarySeq->new(
437 ok $search = Bio::Tools::AmpliconSearch->new(
438 -fwd_primer => $forward,
439 -rev_primer => $reverse,
440 ), 'Update template';
441 ok $search->template($seq);
442 is $search->template->seq, 'acgtaCCCCacgtacgtacTTTTTTa';
443 ok $amplicon = $search->next_amplicon;
444 is $amplicon->seq->seq, 'CCCCacgtacgtacTTTTTT';
445 is $search->next_amplicon, undef;
446 ok $search->template($seq2);
447 is $search->template->seq, 'aCCCCgaTTTTTTgacgtacgtac';
448 ok $amplicon = $search->next_amplicon;
449 is $amplicon->seq->seq, 'CCCCgaTTTTTT';
450 is $search->next_amplicon, undef;