1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SeqWords.t 11525 2007-06-27 10:16:38Z sendu $
10 test_begin(-tests => 22);
13 use_ok('Bio::Tools::SeqWords');
16 my ($seqobj, $count, $seqobj_stats, $wt);
18 my $str = Bio::SeqIO->new(-file=> test_input_file('multifa.seq'), '-format' => 'Fasta');
19 $seqobj= $str->next_seq();
20 ok defined $seqobj, 'new Bio::Root::IO object';
22 my $words = Bio::Tools::SeqWords->new('-seq' => $seqobj);
23 my $hash = $words->count_words(6);
24 ok (defined $words, 'new Bio::Tools::SeqWords object');
25 ok (defined $hash, 'count_words');
27 $seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTGACTGGC',
28 -alphabet=>'dna', -id=>'test');
29 ok $seqobj_stats = Bio::Tools::SeqWords->new(-seq=>$seqobj);
30 isa_ok $seqobj_stats, 'Bio::Tools::SeqWords';
32 $count = $seqobj_stats->count_words(4);
33 is $count->{'ACTG'}, 3;
34 is $count->{'TGGC'}, 1;
35 is $count->{'GTCA'}, 1;
37 $count = $seqobj_stats->count_overlap_words(4);
38 is $count->{'ACTG'}, 3;
39 is $count->{'TGGC'}, 2;
40 is $count->{'GTCA'}, 1;
41 is $count->{'GTGG'}, 1;
44 $seqobj = Bio::PrimarySeq->new(-seq=>'MQSERGITIDISLWKFETSKYYVTIDISSLWKF',
45 -alphabet=>'protein', -id=>'test');
46 ok $seqobj_stats = Bio::Tools::SeqWords->new('-seq' => $seqobj);
47 isa_ok $seqobj_stats, 'Bio::Tools::SeqWords';
49 $count = $seqobj_stats->count_words(4);
50 is $count->{'MQSE'}, 1;
51 is $count->{'LWKF'}, 1;
52 is $count->{'IDIS'}, 2;
54 $count = $seqobj_stats->count_overlap_words(4);
55 is $count->{'MQSE'}, 1;
56 is $count->{'LWKF'}, 2;
57 is $count->{'IDIS'}, 2;