File: SeqWords.t

package info (click to toggle)
bioperl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 35,788 kB
  • sloc: perl: 94,019; xml: 14,811; makefile: 20
file content (56 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*-Perl-*- Test Harness script for Bioperl
# $Id: SeqWords.t 11525 2007-06-27 10:16:38Z sendu $

use strict;

BEGIN { 
    use Bio::Root::Test;
    
    test_begin(-tests => 22);
	
	use_ok('Bio::SeqIO');
	use_ok('Bio::Tools::SeqWords');
}

my ($seqobj, $count, $seqobj_stats, $wt);

my $str = Bio::SeqIO->new(-file=> test_input_file('multifa.seq'), '-format' => 'Fasta');
$seqobj= $str->next_seq();
ok defined $seqobj, 'new Bio::Root::IO object';

my $words = Bio::Tools::SeqWords->new('-seq' => $seqobj);
my $hash = $words->count_words(6);
ok (defined $words, 'new Bio::Tools::SeqWords object');
ok (defined $hash, 'count_words');

$seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTGACTGGC',
			       -alphabet=>'dna', -id=>'test');
ok $seqobj_stats  =  Bio::Tools::SeqWords->new(-seq=>$seqobj);
isa_ok $seqobj_stats, 'Bio::Tools::SeqWords';

$count = $seqobj_stats->count_words(4);
is $count->{'ACTG'}, 3;
is $count->{'TGGC'}, 1;
is $count->{'GTCA'}, 1;

$count = $seqobj_stats->count_overlap_words(4);
is $count->{'ACTG'}, 3;
is $count->{'TGGC'}, 2;
is $count->{'GTCA'}, 1;
is $count->{'GTGG'}, 1;

# now test a protein
$seqobj = Bio::PrimarySeq->new(-seq=>'MQSERGITIDISLWKFETSKYYVTIDISSLWKF',
                               -alphabet=>'protein', -id=>'test');
ok $seqobj_stats  =  Bio::Tools::SeqWords->new('-seq' => $seqobj);
isa_ok $seqobj_stats, 'Bio::Tools::SeqWords';

$count = $seqobj_stats->count_words(4);
is $count->{'MQSE'}, 1;
is $count->{'LWKF'}, 1;
is $count->{'IDIS'}, 2;

$count = $seqobj_stats->count_overlap_words(4);
is $count->{'MQSE'}, 1;
is $count->{'LWKF'}, 2;
is $count->{'IDIS'}, 2;