1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 28);
12 use_ok('Bio::Tools::SeqPattern');
15 my ( $pattern,$pattern_obj,$pattern_obj2, $pattern_obj3);
17 $pattern = '(CCCCT)N{1,200}(agyyg)N{1,80}(ag)';
18 ok $pattern_obj = Bio::Tools::SeqPattern->new(-SEQ =>$pattern, -TYPE =>'dna');
19 isa_ok $pattern_obj, 'Bio::Tools::SeqPattern';
21 $pattern_obj2 = $pattern_obj->revcom();
22 is $pattern_obj2->str, '(CT)N(CRRCT){1,80}N(AGGGG){1,200}';
24 $pattern_obj3 = $pattern_obj->revcom(1);
25 is $pattern_obj3->str, '(CT).{1,80}(C[GA][GA]CT).(AGGGG){1,200}';
27 $pattern = '(CCCCT)N{1,200}(agyyg)N{1,80}(bb)'; # test protein object expand
28 ok $pattern_obj = Bio::Tools::SeqPattern->new(-SEQ =>$pattern, -TYPE =>'protein');
29 isa_ok $pattern_obj, 'Bio::Tools::SeqPattern';
31 is $pattern_obj2->expand, '(CT).(C[AG][AG]CT){1,80}.(AGGGG){1,200}';
36 $pattern_obj2 = Bio::Tools::SeqPattern->new(-SEQ =>$pattern,
38 is $pattern_obj2->expand, 'A[EQ][DN]H';
41 test_skip(-tests => 19, -requires_module => 'List::MoreUtils');
42 # Test reverse complement
43 my $rev_pattern = $pattern_obj2->backtranslate;
44 isa_ok $rev_pattern, 'Bio::Tools::SeqPattern';
45 is $rev_pattern->str, 'GCNRAYSARCAY';
48 throws_ok { $pattern_obj2->revcom } qr/revcom for .+ sequence types/;
49 throws_ok { $rev_pattern->backtranslate } qr/backtranslate for .+ sequence types/;
51 # Test reverse translation more thoroughly
56 push @data, [ split ];
59 foreach my $line (@data) {
60 my $pattern_obj = Bio::Tools::SeqPattern->new(
65 isa_ok $pattern_obj, 'Bio::Tools::SeqPattern';
67 my $backtranslate = $pattern_obj->backtranslate;
68 isa_ok $backtranslate, 'Bio::Tools::SeqPattern';
69 is $backtranslate->str, $line->[1],
74 MAEELKAVAP ATGGCNGARGARYTNAARGCNGTNGCNCCN
75 LKGHB[WhYq]Q YTNAARGGNCAYRAYYRNCAR
76 (LK){2,3}[^GHB][WHYQ]Q (YTNAAR){2,3}HBNYRNCAR
77 LK[^GHB][WHYQ]Q YTNAARHBNYRNCAR
78 (LK){2,3}[^GHB][WHYQ]QX.X (YTNAAR){2,3}HBNYRNCARNNNNNNNNN